diff --git a/src/generators/typescript/fetch/project_files/runtime.ts.txt b/src/generators/typescript/fetch/project_files/runtime.ts.txt index 6ab25fe8..1af5e43c 100644 --- a/src/generators/typescript/fetch/project_files/runtime.ts.txt +++ b/src/generators/typescript/fetch/project_files/runtime.ts.txt @@ -14,9 +14,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -85,9 +89,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -266,22 +272,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -405,8 +420,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -415,8 +432,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/src/generators/typescript/fetch/sigil_emit_api.rs b/src/generators/typescript/fetch/sigil_emit_api.rs index a2bb190b..fcd53d14 100644 --- a/src/generators/typescript/fetch/sigil_emit_api.rs +++ b/src/generators/typescript/fetch/sigil_emit_api.rs @@ -1160,13 +1160,21 @@ fn build_convenience_method(op: &IrOperation) -> Result { } fn is_void_type(ty: &TypeName) -> bool { + is_primitive_type(ty, "void") +} + +fn is_unknown_type(ty: &TypeName) -> bool { + is_primitive_type(ty, "unknown") +} + +fn is_primitive_type(ty: &TypeName, primitive: &str) -> bool { let Ok(val) = serde_json::to_value(ty) else { return false; }; - let Ok(void_val) = serde_json::to_value(TypeName::primitive("void")) else { + let Ok(primitive_val) = serde_json::to_value(TypeName::primitive(primitive)) else { return false; }; - val == void_val + val == primitive_val } // ============================================================================ @@ -1312,6 +1320,9 @@ fn dedup_union_members(members: Vec) -> Vec { fn dedup_union(members: Vec) -> TypeName { let mut out = dedup_union_members(members); + if out.iter().any(is_unknown_type) { + return TypeName::primitive("unknown"); + } if out.len() == 1 { out.pop().unwrap() } else { @@ -1777,3 +1788,22 @@ fn collect_convertible_named_refs( _ => {} } } + +#[cfg(test)] +mod tests { + use super::*; + + fn type_json(ty: &TypeName) -> serde_json::Value { + serde_json::to_value(ty).expect("TypeName serializes") + } + + #[test] + fn dedup_union_collapses_unknown_members() { + let ty = dedup_union(vec![ + TypeName::primitive("unknown"), + TypeName::importable_type("../models/ErrorResponse", "ErrorResponse"), + ]); + + assert_eq!(type_json(&ty), type_json(&TypeName::primitive("unknown"))); + } +} diff --git a/tests/golden/typescript/typescript-fetch/additional-properties/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/additional-properties/runtime/runtime.ts.golden index 92614571..471777a9 100644 --- a/tests/golden/typescript/typescript-fetch/additional-properties/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/additional-properties/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/binary-transfer-media-types/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/binary-transfer-media-types/runtime/runtime.ts.golden index e1a47408..3f861e7b 100644 --- a/tests/golden/typescript/typescript-fetch/binary-transfer-media-types/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/binary-transfer-media-types/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -124,9 +128,11 @@ function isFile(value: UploadFileInput): value is File { export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -305,22 +311,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -444,8 +459,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -454,8 +471,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/comprehensive-schemas/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/comprehensive-schemas/runtime/runtime.ts.golden index f5de55d5..8b83b3b9 100644 --- a/tests/golden/typescript/typescript-fetch/comprehensive-schemas/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/comprehensive-schemas/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/delete-with-response-schema/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/delete-with-response-schema/runtime/runtime.ts.golden index e76d1b63..8dfdd50b 100644 --- a/tests/golden/typescript/typescript-fetch/delete-with-response-schema/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/delete-with-response-schema/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/duplicate-param-names/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/duplicate-param-names/runtime/runtime.ts.golden index 159640f4..2a596c54 100644 --- a/tests/golden/typescript/typescript-fetch/duplicate-param-names/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/duplicate-param-names/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/enum-repr/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/enum-repr/runtime/runtime.ts.golden index df88c849..018ddb55 100644 --- a/tests/golden/typescript/typescript-fetch/enum-repr/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/enum-repr/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/interface-with-enum-reference/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/interface-with-enum-reference/runtime/runtime.ts.golden index 025c8a96..e6b6f111 100644 --- a/tests/golden/typescript/typescript-fetch/interface-with-enum-reference/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/interface-with-enum-reference/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/media-type-selection/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/media-type-selection/runtime/runtime.ts.golden index c51ce860..bfc3a72c 100644 --- a/tests/golden/typescript/typescript-fetch/media-type-selection/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/media-type-selection/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -124,9 +128,11 @@ function isFile(value: UploadFileInput): value is File { export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -305,22 +311,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -444,8 +459,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -454,8 +471,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/minimal/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/minimal/runtime/runtime.ts.golden index 9bf8631d..173f8541 100644 --- a/tests/golden/typescript/typescript-fetch/minimal/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/minimal/runtime/runtime.ts.golden @@ -19,9 +19,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -90,9 +94,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -271,22 +277,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -410,8 +425,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -420,8 +437,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/multipart-edge-cases/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/multipart-edge-cases/runtime/runtime.ts.golden index 27245db2..e1019d0c 100644 --- a/tests/golden/typescript/typescript-fetch/multipart-edge-cases/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/multipart-edge-cases/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -124,9 +128,11 @@ function isFile(value: UploadFileInput): value is File { export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -305,22 +311,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -444,8 +459,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -454,8 +471,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/multipart-explicit-encoding/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/multipart-explicit-encoding/runtime/runtime.ts.golden index 311e2bbc..16f7d18b 100644 --- a/tests/golden/typescript/typescript-fetch/multipart-explicit-encoding/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/multipart-explicit-encoding/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -124,9 +128,11 @@ function isFile(value: UploadFileInput): value is File { export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -305,22 +311,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -444,8 +459,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -454,8 +471,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/multipart-nested-object-parts/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/multipart-nested-object-parts/runtime/runtime.ts.golden index 437168e0..d3ddacb0 100644 --- a/tests/golden/typescript/typescript-fetch/multipart-nested-object-parts/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/multipart-nested-object-parts/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -124,9 +128,11 @@ function isFile(value: UploadFileInput): value is File { export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -305,22 +311,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -444,8 +459,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -454,8 +471,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/multipart-unsupported-schema/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/multipart-unsupported-schema/runtime/runtime.ts.golden index fd1f1901..d8334670 100644 --- a/tests/golden/typescript/typescript-fetch/multipart-unsupported-schema/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/multipart-unsupported-schema/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/multiple-similar-request-schemas/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/multiple-similar-request-schemas/runtime/runtime.ts.golden index 14a167b8..db41c2e5 100644 --- a/tests/golden/typescript/typescript-fetch/multiple-similar-request-schemas/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/multiple-similar-request-schemas/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/naming-conventions/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/naming-conventions/runtime/runtime.ts.golden index 64999985..30ea49d8 100644 --- a/tests/golden/typescript/typescript-fetch/naming-conventions/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/naming-conventions/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/optional-request-bodies/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/optional-request-bodies/runtime/runtime.ts.golden index 3e764044..e0b74880 100644 --- a/tests/golden/typescript/typescript-fetch/optional-request-bodies/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/optional-request-bodies/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/petstore/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/petstore/runtime/runtime.ts.golden index 1f9dffc9..d4a05475 100644 --- a/tests/golden/typescript/typescript-fetch/petstore/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/petstore/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/query-param-enum/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/query-param-enum/runtime/runtime.ts.golden index dbc1f734..fa84c173 100644 --- a/tests/golden/typescript/typescript-fetch/query-param-enum/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/query-param-enum/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-all-optional-properties/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-all-optional-properties/runtime/runtime.ts.golden index 93140f7f..2baa272e 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-all-optional-properties/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-all-optional-properties/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-array-of-inline-objects/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-array-of-inline-objects/runtime/runtime.ts.golden index 7b722e56..8cc5266b 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-array-of-inline-objects/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-array-of-inline-objects/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-array-of-referenced-types/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-array-of-referenced-types/runtime/runtime.ts.golden index 6ed1c8d6..48480a56 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-array-of-referenced-types/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-array-of-referenced-types/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-array-with-reference-property/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-array-with-reference-property/runtime/runtime.ts.golden index 669907a1..9b9da881 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-array-with-reference-property/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-array-with-reference-property/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-complex-array-structure/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-complex-array-structure/runtime/runtime.ts.golden index c361c361..d450b290 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-complex-array-structure/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-complex-array-structure/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-deeply-nested-inline/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-deeply-nested-inline/runtime/runtime.ts.golden index eaaa0add..9a90e631 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-deeply-nested-inline/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-deeply-nested-inline/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-empty-array/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-empty-array/runtime/runtime.ts.golden index 2ad3a6ca..cf1e1c1d 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-empty-array/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-empty-array/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-inline-object-with-array/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-inline-object-with-array/runtime/runtime.ts.golden index 5c69f794..26fe150b 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-inline-object-with-array/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-inline-object-with-array/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-inline-object/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-inline-object/runtime/runtime.ts.golden index e789fd43..ea5ab6c6 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-inline-object/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-inline-object/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-mixed-property-types/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-mixed-property-types/runtime/runtime.ts.golden index 2795ece7..6a5fc004 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-mixed-property-types/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-mixed-property-types/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-nested-object-reference/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-nested-object-reference/runtime/runtime.ts.golden index 286c06c7..9ca956b8 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-nested-object-reference/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-nested-object-reference/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-optional-array-of-inline-objects/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-optional-array-of-inline-objects/runtime/runtime.ts.golden index 11f8cc3a..7d1ec6ad 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-optional-array-of-inline-objects/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-optional-array-of-inline-objects/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-optional-array-of-referenced-types/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-optional-array-of-referenced-types/runtime/runtime.ts.golden index 17e569c9..1eaab3d6 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-optional-array-of-referenced-types/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-optional-array-of-referenced-types/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-optional-inline-object/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-optional-inline-object/runtime/runtime.ts.golden index 02833e53..9e7cacfe 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-optional-inline-object/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-optional-inline-object/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-optional-nested-object-reference/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-optional-nested-object-reference/runtime/runtime.ts.golden index e1737c20..28217dd8 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-optional-nested-object-reference/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-optional-nested-object-reference/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/recursive-json-primitive-array/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/recursive-json-primitive-array/runtime/runtime.ts.golden index 0fa6f4a4..0727fff1 100644 --- a/tests/golden/typescript/typescript-fetch/recursive-json-primitive-array/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/recursive-json-primitive-array/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/request-body-content-types/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/request-body-content-types/runtime/runtime.ts.golden index c2ae91d3..5f2f50d1 100644 --- a/tests/golden/typescript/typescript-fetch/request-body-content-types/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/request-body-content-types/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/response-body-default-and-exact/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/response-body-default-and-exact/runtime/runtime.ts.golden index c7b7b021..c74222f1 100644 --- a/tests/golden/typescript/typescript-fetch/response-body-default-and-exact/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/response-body-default-and-exact/runtime/runtime.ts.golden @@ -19,9 +19,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -90,9 +94,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -271,22 +277,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -410,8 +425,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -420,8 +437,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/response-body-fallback/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/response-body-fallback/runtime/runtime.ts.golden index 87a7d6f4..798eda29 100644 --- a/tests/golden/typescript/typescript-fetch/response-body-fallback/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/response-body-fallback/runtime/runtime.ts.golden @@ -19,9 +19,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -90,9 +94,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -271,22 +277,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -410,8 +425,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -420,8 +437,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/response-body-multi-status-responses/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/response-body-multi-status-responses/runtime/runtime.ts.golden index 4f58994f..85f31988 100644 --- a/tests/golden/typescript/typescript-fetch/response-body-multi-status-responses/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/response-body-multi-status-responses/runtime/runtime.ts.golden @@ -19,9 +19,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -90,9 +94,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -271,22 +277,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -410,8 +425,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -420,8 +437,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/response-body-no-response-body/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/response-body-no-response-body/runtime/runtime.ts.golden index 0e1c6c31..6d7f65c9 100644 --- a/tests/golden/typescript/typescript-fetch/response-body-no-response-body/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/response-body-no-response-body/runtime/runtime.ts.golden @@ -19,9 +19,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -90,9 +94,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -271,22 +277,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -410,8 +425,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -420,8 +437,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/server-object/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/server-object/runtime/runtime.ts.golden index f2907d41..b0ec5806 100644 --- a/tests/golden/typescript/typescript-fetch/server-object/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/server-object/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/server-path-prefix/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/server-path-prefix/runtime/runtime.ts.golden index 211e5edc..3739f618 100644 --- a/tests/golden/typescript/typescript-fetch/server-path-prefix/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/server-path-prefix/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-enum-const/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-enum-const/runtime/runtime.ts.golden index b1fb6046..506433b6 100644 --- a/tests/golden/typescript/typescript-fetch/ts-enum-const/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-enum-const/runtime/runtime.ts.golden @@ -19,9 +19,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -90,9 +94,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -271,22 +277,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -410,8 +425,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -420,8 +437,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-enum-ref/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-enum-ref/runtime/runtime.ts.golden index 025c8a96..e6b6f111 100644 --- a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-enum-ref/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-enum-ref/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-externally-tagged/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-externally-tagged/runtime/runtime.ts.golden index f382a082..7dbe972a 100644 --- a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-externally-tagged/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-externally-tagged/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-intersection-enum-ref/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-intersection-enum-ref/runtime/runtime.ts.golden index 5900a987..a86d93ca 100644 --- a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-intersection-enum-ref/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-intersection-enum-ref/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-intersection/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-intersection/runtime/runtime.ts.golden index d9697812..21260372 100644 --- a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-intersection/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-intersection/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-multipart-parts/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-multipart-parts/runtime/runtime.ts.golden index 437168e0..d3ddacb0 100644 --- a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-multipart-parts/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-multipart-parts/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -124,9 +128,11 @@ function isFile(value: UploadFileInput): value is File { export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -305,22 +311,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -444,8 +459,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -454,8 +471,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-response-only-types/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-response-only-types/runtime/runtime.ts.golden index e76d1b63..8dfdd50b 100644 --- a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-response-only-types/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-response-only-types/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-tagged-union-variant-with-discriminator/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-tagged-union-variant-with-discriminator/runtime/runtime.ts.golden index b604773d..cb0e136e 100644 --- a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-tagged-union-variant-with-discriminator/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-tagged-union-variant-with-discriminator/runtime/runtime.ts.golden @@ -23,9 +23,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -94,9 +98,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -275,22 +281,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -414,8 +429,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -424,8 +441,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-tagged-union/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-tagged-union/runtime/runtime.ts.golden index 314484e2..d975c5b8 100644 --- a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-tagged-union/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-tagged-union/runtime/runtime.ts.golden @@ -21,9 +21,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -92,9 +96,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -273,22 +279,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -412,8 +427,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -422,8 +439,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-union/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-union/runtime/runtime.ts.golden index 45c7a6b7..faf9e2ed 100644 --- a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-union/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case-union/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case/runtime/runtime.ts.golden index 64999985..30ea49d8 100644 --- a/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-property-naming-camel-case/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-camel-case-tagged-nullable-unions/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-camel-case-tagged-nullable-unions/runtime/runtime.ts.golden index 398a8cf4..470b7499 100644 --- a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-camel-case-tagged-nullable-unions/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-camel-case-tagged-nullable-unions/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-comprehensive/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-comprehensive/runtime/runtime.ts.golden index f5de55d5..8b83b3b9 100644 --- a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-comprehensive/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-comprehensive/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-delete-response/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-delete-response/runtime/runtime.ts.golden index e76d1b63..8dfdd50b 100644 --- a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-delete-response/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-delete-response/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-enum-repr/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-enum-repr/runtime/runtime.ts.golden index df88c849..018ddb55 100644 --- a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-enum-repr/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-enum-repr/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-petstore/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-petstore/runtime/runtime.ts.golden index 1f9dffc9..d4a05475 100644 --- a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-petstore/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp-petstore/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp/runtime/runtime.ts.golden index 314484e2..d975c5b8 100644 --- a/tests/golden/typescript/typescript-fetch/ts-toolchain-vp/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-toolchain-vp/runtime/runtime.ts.golden @@ -21,9 +21,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -92,9 +96,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -273,22 +279,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -412,8 +427,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -422,8 +439,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/ts-type-guards/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/ts-type-guards/runtime/runtime.ts.golden index 32bad89a..5eb8c3b1 100644 --- a/tests/golden/typescript/typescript-fetch/ts-type-guards/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/ts-type-guards/runtime/runtime.ts.golden @@ -19,9 +19,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -90,9 +94,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -271,22 +277,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -410,8 +425,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -420,8 +437,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-complex-union/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-complex-union/runtime/runtime.ts.golden index 99ca4347..2c477b99 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-complex-union/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-complex-union/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-inline-discriminator-only/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-inline-discriminator-only/runtime/runtime.ts.golden index 6cef61ab..d3ae2696 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-inline-discriminator-only/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-inline-discriminator-only/runtime/runtime.ts.golden @@ -29,9 +29,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -100,9 +104,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -281,22 +287,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -420,8 +435,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -430,8 +447,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-internally-tagged/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-internally-tagged/runtime/runtime.ts.golden index c1868760..23546a88 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-internally-tagged/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-internally-tagged/runtime/runtime.ts.golden @@ -22,9 +22,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -93,9 +97,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -274,22 +280,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -413,8 +428,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -423,8 +440,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-long-names/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-long-names/runtime/runtime.ts.golden index 8d3b74f0..33289da2 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-long-names/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-long-names/runtime/runtime.ts.golden @@ -22,9 +22,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -93,9 +97,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -274,22 +280,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -413,8 +428,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -423,8 +440,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-mixed-unit-and-allof/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-mixed-unit-and-allof/runtime/runtime.ts.golden index b6f7ede4..ba137763 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-mixed-unit-and-allof/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-mixed-unit-and-allof/runtime/runtime.ts.golden @@ -25,9 +25,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -96,9 +100,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -277,22 +283,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -416,8 +431,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -426,8 +443,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-multiple/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-multiple/runtime/runtime.ts.golden index 2f9220ab..7992a711 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-multiple/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-multiple/runtime/runtime.ts.golden @@ -23,9 +23,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -94,9 +98,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -275,22 +281,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -414,8 +429,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -424,8 +441,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-with-refs/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-with-refs/runtime/runtime.ts.golden index 314484e2..d975c5b8 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-with-refs/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-discriminated-union-with-refs/runtime/runtime.ts.golden @@ -21,9 +21,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -92,9 +96,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -273,22 +279,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -412,8 +427,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -422,8 +439,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-intersection-allof/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-intersection-allof/runtime/runtime.ts.golden index d9697812..21260372 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-intersection-allof/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-intersection-allof/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-intersection-with-nullable-reference/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-intersection-with-nullable-reference/runtime/runtime.ts.golden index 38cd91ba..8464e1a6 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-intersection-with-nullable-reference/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-intersection-with-nullable-reference/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-nested-union/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-nested-union/runtime/runtime.ts.golden index f2853050..aa56fa10 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-nested-union/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-nested-union/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-simple-type-alias/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-simple-type-alias/runtime/runtime.ts.golden index 966b422c..21ac1ce2 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-simple-type-alias/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-simple-type-alias/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-union-mixed/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-union-mixed/runtime/runtime.ts.golden index 4a290fa0..14e44705 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-union-mixed/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-union-mixed/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-union-with-any/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-union-with-any/runtime/runtime.ts.golden index 285a1305..6fa6e315 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-union-with-any/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-union-with-any/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-union-with-inline-objects/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-union-with-inline-objects/runtime/runtime.ts.golden index a611817b..f5c92145 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-union-with-inline-objects/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-union-with-inline-objects/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-union-with-interfaces/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-union-with-interfaces/runtime/runtime.ts.golden index 45c7a6b7..faf9e2ed 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-union-with-interfaces/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-union-with-interfaces/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise { diff --git a/tests/golden/typescript/typescript-fetch/type-aliases-union-with-primitives/runtime/runtime.ts.golden b/tests/golden/typescript/typescript-fetch/type-aliases-union-with-primitives/runtime/runtime.ts.golden index 04eb88c6..9e93da8d 100644 --- a/tests/golden/typescript/typescript-fetch/type-aliases-union-with-primitives/runtime/runtime.ts.golden +++ b/tests/golden/typescript/typescript-fetch/type-aliases-union-with-primitives/runtime/runtime.ts.golden @@ -20,9 +20,13 @@ export interface ConfigurationParameters { } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} + private configuration: ConfigurationParameters; - set config(configuration: Configuration) { + constructor(configuration: ConfigurationParameters = {}) { + this.configuration = configuration; + } + + set config(configuration: ConfigurationParameters) { this.configuration = configuration; } @@ -91,9 +95,11 @@ export const DefaultConfig = new Configuration(); export class BaseAPI { private static readonly jsonRegex = new RegExp('^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + protected configuration: Configuration; private middleware: Middleware[]; - constructor(protected configuration = DefaultConfig) { + constructor(configuration: Configuration = DefaultConfig) { + this.configuration = configuration; this.middleware = configuration.middleware; } @@ -272,22 +278,31 @@ function isFormData(value: unknown): value is FormData { export class ResponseError extends Error { override name = "ResponseError" as const; - constructor(public response: Response, msg?: string) { + public response: Response; + + constructor(response: Response, msg?: string) { super(msg); + this.response = response; } } export class FetchError extends Error { override name = "FetchError" as const; - constructor(public cause: Error, msg?: string) { + public cause: Error; + + constructor(cause: Error, msg?: string) { super(msg); + this.cause = cause; } } export class RequiredError extends Error { override name = "RequiredError" as const; - constructor(public field: string, msg?: string) { + public field: string; + + constructor(field: string, msg?: string) { super(msg); + this.field = field; } } @@ -411,8 +426,10 @@ class ApiResponseBase { public readonly ok: boolean; public readonly statusText: string; public readonly headers: Headers; + public readonly raw: Response; - constructor(public readonly raw: Response) { + constructor(raw: Response) { + this.raw = raw; this.status = raw.status; this.ok = raw.ok; this.statusText = raw.statusText; @@ -421,8 +438,11 @@ class ApiResponseBase { } export class JSONApiResponse extends ApiResponseBase { - constructor(raw: Response, private transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { + private transformer: ResponseTransformer; + + constructor(raw: Response, transformer: ResponseTransformer = (jsonValue: unknown) => jsonValue as T) { super(raw); + this.transformer = transformer; } async value(): Promise {