Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript-fetch] - Fix Nullable Types #18887

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
{{#allParams.0}}
export interface {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request {
{{#allParams}}
{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{#hasReadOnly}}Omit<{{{dataType}}}, {{#readOnlyVars}}'{{baseName}}'{{^-last}}|{{/-last}}{{/readOnlyVars}}>{{/hasReadOnly}}{{^hasReadOnly}}{{{dataType}}}{{/hasReadOnly}}{{#isNullable}}{{#required}} | null{{/required}}{{/isNullable}}{{/isEnum}};
{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{#hasReadOnly}}Omit<{{{dataType}}}, {{#readOnlyVars}}'{{baseName}}'{{^-last}}|{{/-last}}{{/readOnlyVars}}>{{/hasReadOnly}}{{^hasReadOnly}}{{{dataType}}}{{/hasReadOnly}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};
{{/allParams}}
}

Expand Down Expand Up @@ -70,7 +70,7 @@ export interface {{classname}}Interface {
{{/isDeprecated}}
*/
{{^useSingleRequestParameter}}
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}}{{#required}} | null{{/required}}{{/isNullable}}{{/isEnum}}, {{/allParams}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{^returnType}}void{{/returnType}}>;
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{^returnType}}void{{/returnType}}>;
{{/useSingleRequestParameter}}
{{#useSingleRequestParameter}}
{{nickname}}({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{^returnType}}void{{/returnType}}>;
Expand Down Expand Up @@ -354,7 +354,7 @@ export class {{classname}} extends runtime.BaseAPI {
{{/isDeprecated}}
*/
{{^useSingleRequestParameter}}
async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}}{{#required}} | null{{/required}}{{/isNullable}}{{/isEnum}}, {{/allParams}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{#returnType}}{{#isResponseOptional}} | null | undefined {{/isResponseOptional}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{#returnType}}{{#isResponseOptional}} | null | undefined {{/isResponseOptional}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
{{#returnType}}
const response = await this.{{nickname}}Raw({{#allParams.0}}{ {{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}} }, {{/allParams.0}}initOverrides);
{{#isResponseOptional}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
* @deprecated
{{/deprecated}}
*/
{{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{#isNullable}}{{#required}} | null{{/required}}{{/isNullable}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{#isNullable}}{{#required}} | null{{/required}}{{/isNullable}}{{/isEnum}};
{{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};
{{/vars}}
}{{#hasEnums}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface Club {
* @type {Owner}
* @memberof Club
*/
owner?: Owner;
owner?: Owner | null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface EnumTest {
* @type {OuterEnum}
* @memberof EnumTest
*/
outerEnum?: OuterEnum;
outerEnum?: OuterEnum | null;
/**
*
* @type {OuterEnumInteger}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface HealthCheckResult {
* @type {string}
* @memberof HealthCheckResult
*/
nullableMessage?: string;
nullableMessage?: string | null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,49 @@ export interface NullableClass {
* @type {number}
* @memberof NullableClass
*/
integerProp?: number;
integerProp?: number | null;
/**
*
* @type {number}
* @memberof NullableClass
*/
numberProp?: number;
numberProp?: number | null;
/**
*
* @type {boolean}
* @memberof NullableClass
*/
booleanProp?: boolean;
booleanProp?: boolean | null;
/**
*
* @type {string}
* @memberof NullableClass
*/
stringProp?: string;
stringProp?: string | null;
/**
*
* @type {Date}
* @memberof NullableClass
*/
dateProp?: Date;
dateProp?: Date | null;
/**
*
* @type {Date}
* @memberof NullableClass
*/
datetimeProp?: Date;
datetimeProp?: Date | null;
/**
*
* @type {Array<object>}
* @memberof NullableClass
*/
arrayNullableProp?: Array<object>;
arrayNullableProp?: Array<object> | null;
/**
*
* @type {Array<object>}
* @memberof NullableClass
*/
arrayAndItemsNullableProp?: Array<object>;
arrayAndItemsNullableProp?: Array<object> | null;
/**
*
* @type {Array<object>}
Expand All @@ -79,13 +79,13 @@ export interface NullableClass {
* @type {{ [key: string]: object; }}
* @memberof NullableClass
*/
objectNullableProp?: { [key: string]: object; };
objectNullableProp?: { [key: string]: object; } | null;
/**
*
* @type {{ [key: string]: object | null; }}
* @memberof NullableClass
*/
objectAndItemsNullableProp?: { [key: string]: object | null; };
objectAndItemsNullableProp?: { [key: string]: object | null; } | null;
/**
*
* @type {{ [key: string]: object | null; }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface ParentWithNullable {
* @type {string}
* @memberof ParentWithNullable
*/
nullableProperty?: string;
nullableProperty?: string | null;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export interface FakeEnumRequestGetInlineRequest {

export interface FakeEnumRequestGetRefRequest {
stringEnum?: StringEnum;
nullableStringEnum?: StringEnum;
nullableStringEnum?: StringEnum | null;
numberEnum?: NumberEnum;
nullableNumberEnum?: NumberEnum;
nullableNumberEnum?: NumberEnum | null;
}

export interface FakeEnumRequestPostInlineRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface EnumPatternObject {
* @type {StringEnum}
* @memberof EnumPatternObject
*/
nullableStringEnum?: StringEnum;
nullableStringEnum?: StringEnum | null;
/**
*
* @type {NumberEnum}
Expand All @@ -55,7 +55,7 @@ export interface EnumPatternObject {
* @type {NumberEnum}
* @memberof EnumPatternObject
*/
nullableNumberEnum?: NumberEnum;
nullableNumberEnum?: NumberEnum | null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface EnumTest {
* @type {OuterEnum}
* @memberof EnumTest
*/
outerEnum?: OuterEnum;
outerEnum?: OuterEnum | null;
/**
*
* @type {OuterEnumInteger}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface HealthCheckResult {
* @type {string}
* @memberof HealthCheckResult
*/
nullableMessage?: string;
nullableMessage?: string | null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,49 @@ export interface NullableClass {
* @type {number}
* @memberof NullableClass
*/
integerProp?: number;
integerProp?: number | null;
/**
*
* @type {number}
* @memberof NullableClass
*/
numberProp?: number;
numberProp?: number | null;
/**
*
* @type {boolean}
* @memberof NullableClass
*/
booleanProp?: boolean;
booleanProp?: boolean | null;
/**
*
* @type {string}
* @memberof NullableClass
*/
stringProp?: string;
stringProp?: string | null;
/**
*
* @type {Date}
* @memberof NullableClass
*/
dateProp?: Date;
dateProp?: Date | null;
/**
*
* @type {Date}
* @memberof NullableClass
*/
datetimeProp?: Date;
datetimeProp?: Date | null;
/**
*
* @type {Array<object>}
* @memberof NullableClass
*/
arrayNullableProp?: Array<object>;
arrayNullableProp?: Array<object> | null;
/**
*
* @type {Array<object>}
* @memberof NullableClass
*/
arrayAndItemsNullableProp?: Array<object>;
arrayAndItemsNullableProp?: Array<object> | null;
/**
*
* @type {Array<object>}
Expand All @@ -79,13 +79,13 @@ export interface NullableClass {
* @type {{ [key: string]: object; }}
* @memberof NullableClass
*/
objectNullableProp?: { [key: string]: object; };
objectNullableProp?: { [key: string]: object; } | null;
/**
*
* @type {{ [key: string]: object | null; }}
* @memberof NullableClass
*/
objectAndItemsNullableProp?: { [key: string]: object | null; };
objectAndItemsNullableProp?: { [key: string]: object | null; } | null;
/**
*
* @type {{ [key: string]: object | null; }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export interface FakeEnumRequestGetInlineRequest {

export interface FakeEnumRequestGetRefRequest {
stringEnum?: StringEnum;
nullableStringEnum?: StringEnum;
nullableStringEnum?: StringEnum | null;
numberEnum?: NumberEnum;
nullableNumberEnum?: NumberEnum;
nullableNumberEnum?: NumberEnum | null;
}

export interface FakeEnumRequestPostInlineRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface EnumPatternObject {
* @type {StringEnum}
* @memberof EnumPatternObject
*/
nullableStringEnum?: StringEnum;
nullableStringEnum?: StringEnum | null;
/**
*
* @type {NumberEnum}
Expand All @@ -55,7 +55,7 @@ export interface EnumPatternObject {
* @type {NumberEnum}
* @memberof EnumPatternObject
*/
nullableNumberEnum?: NumberEnum;
nullableNumberEnum?: NumberEnum | null;
}

/**
Expand Down
Loading