Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ fn try_match_with_args(ident: &str, args: &syn::PathArguments) -> Result<TsType,
_ => "unknown".to_owned(),
},
}),
"Box" => Ok(TsType {
is_optional: false,
ts_type: match &args {
syn::PathArguments::Parenthesized(parenthesized_argument) => {
format!("{:?}", parenthesized_argument)
}
syn::PathArguments::AngleBracketed(angle_bracketed_argument) => {
convert_generic(angle_bracketed_argument.args.first().unwrap()).ts_type
}
_ => "unknown".to_owned(),
},
}),
"Vec" => Ok(match &args {
syn::PathArguments::Parenthesized(parenthesized_argument) => {
format!("{:?}", parenthesized_argument).into()
Expand Down Expand Up @@ -196,6 +208,7 @@ pub fn convert_type(ty: &syn::Type) -> TsType {
is_optional: false,
}
}

_ => "unknown".to_owned().into(),
}
}
13 changes: 13 additions & 0 deletions test/issue-63/rust.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#[tsync]
struct TestStruct {
size: Box<i32>,
}

#[tsync]
const v: Box<i32> = 23;

#[tsync]
struct TestStruct2 {
inner: Box<TestStruct>,
inner_unboxed: TestStruct,
}
8 changes: 8 additions & 0 deletions test/issue-63/tsync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

cd $SCRIPT_DIR

cargo run -- -i rust.rs -o typescript.d.ts
cargo run -- -i rust.rs -o typescript.ts
10 changes: 10 additions & 0 deletions test/issue-63/typescript.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* This file is generated and managed by tsync */

interface TestStruct {
size: number;
}

interface TestStruct2 {
inner: TestStruct;
inner_unboxed: TestStruct;
}
12 changes: 12 additions & 0 deletions test/issue-63/typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* This file is generated and managed by tsync */

export interface TestStruct {
size: number;
}

export const v = 23;

export interface TestStruct2 {
inner: TestStruct;
inner_unboxed: TestStruct;
}
1 change: 1 addition & 0 deletions test/test_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ cd $SCRIPT_DIR
./issue-43/tsync.sh
./issue-55/tsync.sh
./issue-58/tsync.sh
./issue-63/tsync.sh
./issue-65-untagged-enums/tsync.sh
./raw_identifiers/tsync.sh