Skip to content

Commit

Permalink
Revert "Revert "Merge pull request #82 from 1Password/jane/undefined-…
Browse files Browse the repository at this point in the history
…to-null""

This reverts commit 08769e5.
  • Loading branch information
CerulanLumina authored and CerulanLumina committed Apr 13, 2023
1 parent 58e4c02 commit dbcb456
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions core/data/tests/boxed_value/output.ts
Original file line number Diff line number Diff line change
@@ -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 };

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type SomeEnum =
| { type: "A", content?: undefined }
| { type: "A", content: null }
| { type: "C", content: number };

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export interface AddressDetails {

export type Address =
| { type: "FixedAddress", content: AddressDetails }
| { type: "NoFixedAddress", content?: undefined };
| { type: "NoFixedAddress", content: null };

2 changes: 1 addition & 1 deletion core/data/tests/can_generate_generic_struct/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export type EnumUsingGenericStruct =
| { type: "VariantA", content: GenericStruct<string, number> }
| { type: "VariantB", content: GenericStruct<string, number> }
| { type: "VariantC", content: GenericStruct<string, boolean> }
| { type: "VariantD", content: GenericStructUsingGenericStruct<undefined> };
| { type: "VariantD", content: GenericStructUsingGenericStruct<null> };

4 changes: 2 additions & 2 deletions core/data/tests/can_handle_anonymous_struct/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions core/data/tests/can_handle_unit_type/output.ts
Original file line number Diff line number Diff line change
@@ -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 };

4 changes: 2 additions & 2 deletions core/src/language/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 } => {
Expand Down

0 comments on commit dbcb456

Please sign in to comment.