diff --git a/core/data/tests/boxed_value/output.ts b/core/data/tests/boxed_value/output.ts index 7c8a2234..0b45e704 100644 --- a/core/data/tests/boxed_value/output.ts +++ b/core/data/tests/boxed_value/output.ts @@ -1,6 +1,6 @@ /** This is a comment. */ export type Colors = - | { type: "Red", content?: undefined } - | { type: "Blue", content?: undefined } + | { type: "Red", content: null } + | { type: "Blue", content: null } | { type: "Green", content: string }; diff --git a/core/data/tests/can_generate_algebraic_enum_with_skipped_variants/output.ts b/core/data/tests/can_generate_algebraic_enum_with_skipped_variants/output.ts index 3b48f75f..0ef92931 100644 --- a/core/data/tests/can_generate_algebraic_enum_with_skipped_variants/output.ts +++ b/core/data/tests/can_generate_algebraic_enum_with_skipped_variants/output.ts @@ -1,4 +1,4 @@ export type SomeEnum = - | { type: "A", content?: undefined } + | { type: "A", content: null } | { type: "C", content: number }; diff --git a/core/data/tests/can_generate_empty_algebraic_enum/output.ts b/core/data/tests/can_generate_empty_algebraic_enum/output.ts index 10b3ce78..3d2273ff 100644 --- a/core/data/tests/can_generate_empty_algebraic_enum/output.ts +++ b/core/data/tests/can_generate_empty_algebraic_enum/output.ts @@ -3,5 +3,5 @@ export interface AddressDetails { export type Address = | { type: "FixedAddress", content: AddressDetails } - | { type: "NoFixedAddress", content?: undefined }; + | { type: "NoFixedAddress", content: null }; diff --git a/core/data/tests/can_generate_generic_struct/output.ts b/core/data/tests/can_generate_generic_struct/output.ts index 38a129b9..0b6bc2cd 100644 --- a/core/data/tests/can_generate_generic_struct/output.ts +++ b/core/data/tests/can_generate_generic_struct/output.ts @@ -13,5 +13,5 @@ export type EnumUsingGenericStruct = | { type: "VariantA", content: GenericStruct } | { type: "VariantB", content: GenericStruct } | { type: "VariantC", content: GenericStruct } - | { type: "VariantD", content: GenericStructUsingGenericStruct }; + | { type: "VariantD", content: GenericStructUsingGenericStruct }; diff --git a/core/data/tests/can_handle_anonymous_struct/output.ts b/core/data/tests/can_handle_anonymous_struct/output.ts index 4417ec51..b33267fa 100644 --- a/core/data/tests/can_handle_anonymous_struct/output.ts +++ b/core/data/tests/can_handle_anonymous_struct/output.ts @@ -15,13 +15,13 @@ export type AutofilledBy = /** This is a comment (yareek sameek wuz here) */ export type EnumWithManyVariants = - | { type: "UnitVariant", content?: undefined } + | { type: "UnitVariant", content: null } | { type: "TupleVariantString", content: string } | { type: "AnonVariant", content: { uuid: string; }} | { type: "TupleVariantInt", content: number } - | { type: "AnotherUnitVariant", content?: undefined } + | { type: "AnotherUnitVariant", content: null } | { type: "AnotherAnonVariant", content: { uuid: string; thing: number; diff --git a/core/data/tests/can_handle_unit_type/output.ts b/core/data/tests/can_handle_unit_type/output.ts index 430935d6..d7508d1f 100644 --- a/core/data/tests/can_handle_unit_type/output.ts +++ b/core/data/tests/can_handle_unit_type/output.ts @@ -1,9 +1,9 @@ /** This struct has a unit field */ export interface StructHasVoidType { - thisIsAUnit: undefined; + thisIsAUnit: null; } /** This enum has a variant associated with unit data */ export type EnumHasVoidType = - | { type: "hasAUnit", content: undefined }; + | { type: "hasAUnit", content: null }; diff --git a/core/src/language/typescript.rs b/core/src/language/typescript.rs index 32bf7ae6..74879d71 100644 --- a/core/src/language/typescript.rs +++ b/core/src/language/typescript.rs @@ -52,7 +52,7 @@ impl Language for TypeScript { }, self.format_type(rtype2, generic_types)? )), - SpecialRustType::Unit => Ok("undefined".into()), + SpecialRustType::Unit => Ok("null".into()), SpecialRustType::String => Ok("string".into()), SpecialRustType::I8 | SpecialRustType::U8 @@ -188,7 +188,7 @@ impl TypeScript { match v { RustEnumVariant::Unit(shared) => write!( w, - "\t| {{ {}: {:?}, {}?: undefined }}", + "\t| {{ {}: {:?}, {}: null }}", tag_key, shared.id.renamed, content_key ), RustEnumVariant::Tuple { ty, shared } => {