diff --git a/typescript/testdata/catalogue_client.ts b/typescript/testdata/catalogue_client.ts index 1b4614b..c91e189 100644 --- a/typescript/testdata/catalogue_client.ts +++ b/typescript/testdata/catalogue_client.ts @@ -18,7 +18,7 @@ export interface IGroup { title: string, nodes: Array, groups: Array, - child?: IGroup, + child?: IGroup | null, sub: ISubGroup } diff --git a/typescript/testdata/catalogue_with_classes.ts b/typescript/testdata/catalogue_with_classes.ts index adf1c56..49d7da0 100755 --- a/typescript/testdata/catalogue_with_classes.ts +++ b/typescript/testdata/catalogue_with_classes.ts @@ -18,7 +18,7 @@ export interface IGroup { title: string, nodes: Array, groups: Array, - child?: IGroup, + child?: IGroup | null, sub: ISubGroup } @@ -32,38 +32,38 @@ export class Campaign implements ICampaign { static entityName = "campaign"; id: number = 0; - groups: Array = null; + groups: Array = null!; } export class CatalogueFirstParams implements ICatalogueFirstParams { static entityName = "cataloguefirstparams"; - groups: Array = null; + groups: Array = null!; } export class CatalogueSecondParams implements ICatalogueSecondParams { static entityName = "cataloguesecondparams"; - campaigns: Array = null; + campaigns: Array = null!; } export class Group implements IGroup { static entityName = "group"; id: number = 0; - title: string = null; - nodes: Array = null; - groups: Array = null; - child?: IGroup = null; - sub: ISubGroup = null; + title: string = null!; + nodes: Array = null!; + groups: Array = null!; + child?: IGroup | null = null; + sub: ISubGroup = null!; } export class SubGroup implements ISubGroup { static entityName = "subgroup"; id: number = 0; - title: string = null; - nodes: Array = null; + title: string = null!; + nodes: Array = null!; } export const factory = (send: any) => ({ diff --git a/typescript/testdata/catalogue_with_types_only.ts b/typescript/testdata/catalogue_with_types_only.ts index 5cdc864..31e6d3e 100755 --- a/typescript/testdata/catalogue_with_types_only.ts +++ b/typescript/testdata/catalogue_with_types_only.ts @@ -18,7 +18,7 @@ export interface IGroup { title: string, nodes: Array, groups: Array, - child?: IGroup, + child?: IGroup | null, sub: ISubGroup } diff --git a/typescript/typescript_client.go b/typescript/typescript_client.go index 09cfb61..a16c044 100644 --- a/typescript/typescript_client.go +++ b/typescript/typescript_client.go @@ -147,6 +147,10 @@ func (t Type) DefaultTmpl() string { } } + if result == "null" && !t.Optional { + result = "null!" + } + return result } @@ -339,6 +343,10 @@ func convertTSType(models *tsModels, interfacesCache map[string]interface{}, in }, typeMapper) } + if result.Optional { + result.Type += " | null" + } + // apply hook if typeMapper != nil { result = typeMapper(in, result)