Repository: 1Password/typeshare (rust)

Issue:
null content is no longer optional
https://github.com/1Password/typeshare/pull/82/

This PR changed `undefined` to `null` however it removed the optional operator (from `content?: undefined` to `content: null`)

This seems like a change that should at the very least be a setting. 

This is useful if a rust FFI interface allows optional parameters to be passed. 

Before one could express an interface that did not require `content: null` to be passed (as this is useless) and now it is required. 

I propose `content?: null` be allowed. While this does mean that the type is effectively `content?: null | undefined` this allows for a better quality of life when allowing to not send an empty content over FFI 

Pull request:
Revert "Merge pull request #82 from 1Password/jane/undefined-to-null"
This reverts commit 07e6220ef062dc269ee07a1ab7137761e6bdcf77, reversing changes made to 3d7aa59b0e6b6b318cbf8b633dba9691a1cbc808.

Fixes #96.

Patch:
diff --git a/core/src/language/typescript.rs b/core/src/language/typescript.rs
index 74879d7..32bf7ae 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("null".into()),
+            SpecialRustType::Unit => Ok("undefined".into()),
             SpecialRustType::String => Ok("string".into()),
             SpecialRustType::I8
             | SpecialRustType::U8
@@ -188,7 +188,7 @@ impl TypeScript {
                 match v {
                     RustEnumVariant::Unit(shared) => write!(
                         w,
-                        "\t| {{ {}: {:?}, {}: null }}",
+                        "\t| {{ {}: {:?}, {}?: undefined }}",
                         tag_key, shared.id.renamed, content_key
                     ),
                     RustEnumVariant::Tuple { ty, shared } => {


Test patch:
diff --git a/core/data/tests/boxed_value/output.ts b/core/data/tests/boxed_value/output.ts
index 0b45e70..7c8a223 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: null }
-	| { type: "Blue", content: null }
+	| { type: "Red", content?: undefined }
+	| { type: "Blue", content?: undefined }
 	| { 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 0ef9293..3b48f75 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: null }
+	| { type: "A", content?: undefined }
 	| { 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 3d2273f..10b3ce7 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: null };
+	| { type: "NoFixedAddress", content?: undefined };
 
diff --git a/core/data/tests/can_generate_generic_struct/output.ts b/core/data/tests/can_generate_generic_struct/output.ts
index 0b6bc2c..38a129b 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<string, number> }
 	| { type: "VariantB", content: GenericStruct<string, number> }
 	| { type: "VariantC", content: GenericStruct<string, boolean> }
-	| { type: "VariantD", content: GenericStructUsingGenericStruct<null> };
+	| { type: "VariantD", content: GenericStructUsingGenericStruct<undefined> };
 
diff --git a/core/data/tests/can_handle_anonymous_struct/output.ts b/core/data/tests/can_handle_anonymous_struct/output.ts
index b33267f..4417ec5 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: null }
+	| { type: "UnitVariant", content?: undefined }
 	| { type: "TupleVariantString", content: string }
 	| { type: "AnonVariant", content: {
 	uuid: string;
 }}
 	| { type: "TupleVariantInt", content: number }
-	| { type: "AnotherUnitVariant", content: null }
+	| { type: "AnotherUnitVariant", content?: undefined }
 	| { 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 d7508d1..430935d 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: null;
+	thisIsAUnit: undefined;
 }
 
 /** This enum has a variant associated with unit data */
 export type EnumHasVoidType = 
-	| { type: "hasAUnit", content: null };
+	| { type: "hasAUnit", content: undefined };