Skip to content

Commit 43f2775

Browse files
CerulanLuminaCerulanLumina
authored andcommitted
Revert "Revert "Merge pull request #82 from 1Password/jane/undefined-to-null""
This reverts commit 08769e5.
1 parent 08769e5 commit 43f2775

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** This is a comment. */
22
export 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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export type SomeEnum =
2-
| { type: "A", content?: undefined }
2+
| { type: "A", content: null }
33
| { type: "C", content: number };
44

core/data/tests/can_generate_empty_algebraic_enum/output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ export interface AddressDetails {
33

44
export type Address =
55
| { type: "FixedAddress", content: AddressDetails }
6-
| { type: "NoFixedAddress", content?: undefined };
6+
| { type: "NoFixedAddress", content: null };
77

core/data/tests/can_generate_generic_struct/output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

core/data/tests/can_handle_anonymous_struct/output.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ export type AutofilledBy =
1515

1616
/** This is a comment (yareek sameek wuz here) */
1717
export 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;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** This struct has a unit field */
22
export interface StructHasVoidType {
3-
thisIsAUnit: undefined;
3+
thisIsAUnit: null;
44
}
55

66
/** This enum has a variant associated with unit data */
77
export type EnumHasVoidType =
8-
| { type: "hasAUnit", content: undefined };
8+
| { type: "hasAUnit", content: null };
99

core/src/language/typescript.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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 } => {

0 commit comments

Comments
 (0)