File tree Expand file tree Collapse file tree 7 files changed +11
-11
lines changed
can_generate_algebraic_enum_with_skipped_variants
can_generate_empty_algebraic_enum
can_generate_generic_struct
can_handle_anonymous_struct Expand file tree Collapse file tree 7 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 11/** This is a comment. */
22export type Colors =
3- | { type : "Red" , content ?: undefined }
4- | { type : "Blue" , content ?: undefined }
3+ | { type : "Red" , content : null }
4+ | { type : "Blue" , content : null }
55 | { type : "Green" , content : string } ;
66
Original file line number Diff line number Diff line change 11export type SomeEnum =
2- | { type : "A" , content ?: undefined }
2+ | { type : "A" , content : null }
33 | { type : "C" , content : number } ;
44
Original file line number Diff line number Diff line change @@ -3,5 +3,5 @@ export interface AddressDetails {
33
44export type Address =
55 | { type : "FixedAddress" , content : AddressDetails }
6- | { type : "NoFixedAddress" , content ?: undefined } ;
6+ | { type : "NoFixedAddress" , content : null } ;
77
Original file line number Diff line number Diff line change @@ -13,5 +13,5 @@ export type EnumUsingGenericStruct =
1313 | { type : "VariantA" , content : GenericStruct < string , number > }
1414 | { type : "VariantB" , content : GenericStruct < string , number > }
1515 | { type : "VariantC" , content : GenericStruct < string , boolean > }
16- | { type : "VariantD" , content : GenericStructUsingGenericStruct < undefined > } ;
16+ | { type : "VariantD" , content : GenericStructUsingGenericStruct < null > } ;
1717
Original file line number Diff line number Diff line change @@ -15,13 +15,13 @@ export type AutofilledBy =
1515
1616/** This is a comment (yareek sameek wuz here) */
1717export type EnumWithManyVariants =
18- | { type : "UnitVariant" , content ?: undefined }
18+ | { type : "UnitVariant" , content : null }
1919 | { type : "TupleVariantString" , content : string }
2020 | { type : "AnonVariant" , content : {
2121 uuid : string ;
2222} }
2323 | { type : "TupleVariantInt" , content : number }
24- | { type : "AnotherUnitVariant" , content ?: undefined }
24+ | { type : "AnotherUnitVariant" , content : null }
2525 | { type : "AnotherAnonVariant" , content : {
2626 uuid : string ;
2727 thing : number ;
Original file line number Diff line number Diff line change 11/** This struct has a unit field */
22export interface StructHasVoidType {
3- thisIsAUnit : undefined ;
3+ thisIsAUnit : null ;
44}
55
66/** This enum has a variant associated with unit data */
77export type EnumHasVoidType =
8- | { type : "hasAUnit" , content : undefined } ;
8+ | { type : "hasAUnit" , content : null } ;
99
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ impl Language for TypeScript {
5252 } ,
5353 self . format_type( rtype2, generic_types) ?
5454 ) ) ,
55- SpecialRustType :: Unit => Ok ( "undefined " . into ( ) ) ,
55+ SpecialRustType :: Unit => Ok ( "null " . into ( ) ) ,
5656 SpecialRustType :: String => Ok ( "string" . into ( ) ) ,
5757 SpecialRustType :: I8
5858 | SpecialRustType :: U8
@@ -188,7 +188,7 @@ impl TypeScript {
188188 match v {
189189 RustEnumVariant :: Unit ( shared) => write ! (
190190 w,
191- "\t | {{ {}: {:?}, {}?: undefined }}" ,
191+ "\t | {{ {}: {:?}, {}: null }}" ,
192192 tag_key, shared. id. renamed, content_key
193193 ) ,
194194 RustEnumVariant :: Tuple { ty, shared } => {
You can’t perform that action at this time.
0 commit comments