diff --git a/language-support/ts/codegen/src/TsCodeGenMain.hs b/language-support/ts/codegen/src/TsCodeGenMain.hs index c935b009a925..8efd77a706ca 100644 --- a/language-support/ts/codegen/src/TsCodeGenMain.hs +++ b/language-support/ts/codegen/src/TsCodeGenMain.hs @@ -167,7 +167,6 @@ genDefDataType curPkgId conName mod tpls def = body = map (" " <>) $ -- The variant deserializer. ["decoder: () => jtv.oneOf<" <> typ <> ">("] ++ sers ++ ["),"] ++ - ["isOptional: false,"] ++ -- Remember how we dropped the first line of each -- associated serializer above? This replaces them. concatMap (\(n, ser) -> n <> ": ({" : onLast (<> ",") ser) assocSers @@ -230,7 +229,6 @@ genDefDataType curPkgId conName mod tpls def = ," keyDecoder: " <> keySer <> "," ] ++ map (" " <>) (onLast (<> ",") (onHead ("decoder: " <>) serDesc)) ++ - [" isOptional: false,"] ++ concat [ [" " <> x <> ": {" ," template: () => " <> conName <> "," @@ -269,14 +267,12 @@ genDefDataType curPkgId conName mod tpls def = makeSer serDesc = ["export const " <> conName <> serHeader <> " ({"] ++ map (" " <>) (onLast (<> ",") (onHead ("decoder: " <>) serDesc)) ++ - [" isOptional: false,"] ++ ["})"] makeNameSpace serDesc = [ "// eslint-disable-next-line @typescript-eslint/no-namespace" , "export namespace " <> conName <> " {" ] ++ map (" " <>) (onHead ("export const decoder = " <>) serDesc) ++ - [" export const isOptional = false;"] ++ ["}"] genBranch (VariantConName cons, t) = let (typ, ser) = genType (moduleName mod) t in diff --git a/language-support/ts/daml-json-types/index.test.ts b/language-support/ts/daml-json-types/index.test.ts index 37a9c331d62d..73e4d6f62370 100644 --- a/language-support/ts/daml-json-types/index.test.ts +++ b/language-support/ts/daml-json-types/index.test.ts @@ -19,7 +19,6 @@ describe('daml-json-types', () => { expect(dict.decoder().run('X').ok).toBe(false); expect(dict.decoder().run([['X']]).ok).toBe(false); expect(dict.decoder().run([[]]).ok).toBe(false); - // FIXME(MH): The decoder for `Optional` is slightly off in this case. - // expect(dict.decoder().run([null]).ok).toBe(false); + expect(dict.decoder().run([null]).ok).toBe(false); }); }); diff --git a/language-support/ts/daml-json-types/index.ts b/language-support/ts/daml-json-types/index.ts index 3b383da085bd..fa19b5a09550 100644 --- a/language-support/ts/daml-json-types/index.ts +++ b/language-support/ts/daml-json-types/index.ts @@ -9,7 +9,6 @@ import * as jtv from '@mojotech/json-type-validation'; export interface Serializable { // NOTE(MH): This must be a function to allow for mutually recursive decoders. decoder: () => jtv.Decoder; - isOptional: boolean; } /** @@ -72,7 +71,6 @@ export type Unit = {}; */ export const Unit: Serializable = { decoder: () => jtv.object({}), - isOptional: false, } /** @@ -85,7 +83,6 @@ export type Bool = boolean; */ export const Bool: Serializable = { decoder: jtv.boolean, - isOptional: false, } /** @@ -99,7 +96,6 @@ export type Int = string; */ export const Int: Serializable = { decoder: jtv.string, - isOptional: false, } /** @@ -117,7 +113,6 @@ export type Decimal = Numeric; export const Numeric = (_: number): Serializable => ({ decoder: jtv.string, - isOptional: false, }) export const Decimal: Serializable = Numeric(10) @@ -132,7 +127,6 @@ export type Text = string; */ export const Text: Serializable = { decoder: jtv.string, - isOptional: false, } /** @@ -146,7 +140,6 @@ export type Time = string; */ export const Time: Serializable