Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion typescript/testdata/catalogue_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface IGroup {
title: string,
nodes: Array<IGroup>,
groups: Array<IGroup>,
child?: IGroup,
child?: IGroup | null,
sub: ISubGroup
}

Expand Down
22 changes: 11 additions & 11 deletions typescript/testdata/catalogue_with_classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface IGroup {
title: string,
nodes: Array<IGroup>,
groups: Array<IGroup>,
child?: IGroup,
child?: IGroup | null,
sub: ISubGroup
}

Expand All @@ -32,38 +32,38 @@ export class Campaign implements ICampaign {
static entityName = "campaign";

id: number = 0;
groups: Array<IGroup> = null;
groups: Array<IGroup> = null!;
}

export class CatalogueFirstParams implements ICatalogueFirstParams {
static entityName = "cataloguefirstparams";

groups: Array<IGroup> = null;
groups: Array<IGroup> = null!;
}

export class CatalogueSecondParams implements ICatalogueSecondParams {
static entityName = "cataloguesecondparams";

campaigns: Array<ICampaign> = null;
campaigns: Array<ICampaign> = null!;
}

export class Group implements IGroup {
static entityName = "group";

id: number = 0;
title: string = null;
nodes: Array<IGroup> = null;
groups: Array<IGroup> = null;
child?: IGroup = null;
sub: ISubGroup = null;
title: string = null!;
nodes: Array<IGroup> = null!;
groups: Array<IGroup> = null!;
child?: IGroup | null = null;
sub: ISubGroup = null!;
}

export class SubGroup implements ISubGroup {
static entityName = "subgroup";

id: number = 0;
title: string = null;
nodes: Array<IGroup> = null;
title: string = null!;
nodes: Array<IGroup> = null!;
}

export const factory = (send: any) => ({
Expand Down
2 changes: 1 addition & 1 deletion typescript/testdata/catalogue_with_types_only.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface IGroup {
title: string,
nodes: Array<IGroup>,
groups: Array<IGroup>,
child?: IGroup,
child?: IGroup | null,
sub: ISubGroup
}

Expand Down
8 changes: 8 additions & 0 deletions typescript/typescript_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ func (t Type) DefaultTmpl() string {
}
}

if result == "null" && !t.Optional {
result = "null!"
}

return result
}

Expand Down Expand Up @@ -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)
Expand Down
Loading