diff --git a/.changeset/red-lamps-tickle.md b/.changeset/red-lamps-tickle.md new file mode 100644 index 000000000..67b912cfa --- /dev/null +++ b/.changeset/red-lamps-tickle.md @@ -0,0 +1,7 @@ +--- +"@hey-api/openapi-ts": patch +--- + +Add explicit type annotations to `Interceptors` + +This allows the generated code to work with TypeScript 5.5's new `isolatedDeclarations` configuration. diff --git a/packages/openapi-ts/src/templates/core/OpenAPI.hbs b/packages/openapi-ts/src/templates/core/OpenAPI.hbs index 2fcf933bf..9b501bf08 100644 --- a/packages/openapi-ts/src/templates/core/OpenAPI.hbs +++ b/packages/openapi-ts/src/templates/core/OpenAPI.hbs @@ -20,14 +20,14 @@ export class Interceptors { this._fns = []; } - eject(fn: Middleware) { + eject(fn: Middleware): void { const index = this._fns.indexOf(fn); if (index !== -1) { this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; } } - use(fn: Middleware) { + use(fn: Middleware): void { this._fns = [...this._fns, fn]; } } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/OpenAPI.ts.snap index 7286660a4..438d879ee 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/core/OpenAPI.ts.snap @@ -11,14 +11,14 @@ export class Interceptors { this._fns = []; } - eject(fn: Middleware) { + eject(fn: Middleware): void { const index = this._fns.indexOf(fn); if (index !== -1) { this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; } } - use(fn: Middleware) { + use(fn: Middleware): void { this._fns = [...this._fns, fn]; } } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/OpenAPI.ts.snap index 7286660a4..438d879ee 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/core/OpenAPI.ts.snap @@ -11,14 +11,14 @@ export class Interceptors { this._fns = []; } - eject(fn: Middleware) { + eject(fn: Middleware): void { const index = this._fns.indexOf(fn); if (index !== -1) { this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; } } - use(fn: Middleware) { + use(fn: Middleware): void { this._fns = [...this._fns, fn]; } } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/OpenAPI.ts.snap index 5f049af07..eda4c9d4b 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/core/OpenAPI.ts.snap @@ -12,14 +12,14 @@ export class Interceptors { this._fns = []; } - eject(fn: Middleware) { + eject(fn: Middleware): void { const index = this._fns.indexOf(fn); if (index !== -1) { this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; } } - use(fn: Middleware) { + use(fn: Middleware): void { this._fns = [...this._fns, fn]; } } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/OpenAPI.ts.snap index f08bd7576..4bbc86a7f 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_axios/core/OpenAPI.ts.snap @@ -12,14 +12,14 @@ export class Interceptors { this._fns = []; } - eject(fn: Middleware) { + eject(fn: Middleware): void { const index = this._fns.indexOf(fn); if (index !== -1) { this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; } } - use(fn: Middleware) { + use(fn: Middleware): void { this._fns = [...this._fns, fn]; } } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/OpenAPI.ts.snap index 7286660a4..438d879ee 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_client/core/OpenAPI.ts.snap @@ -11,14 +11,14 @@ export class Interceptors { this._fns = []; } - eject(fn: Middleware) { + eject(fn: Middleware): void { const index = this._fns.indexOf(fn); if (index !== -1) { this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; } } - use(fn: Middleware) { + use(fn: Middleware): void { this._fns = [...this._fns, fn]; } } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/OpenAPI.ts.snap index 7286660a4..438d879ee 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/core/OpenAPI.ts.snap @@ -11,14 +11,14 @@ export class Interceptors { this._fns = []; } - eject(fn: Middleware) { + eject(fn: Middleware): void { const index = this._fns.indexOf(fn); if (index !== -1) { this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; } } - use(fn: Middleware) { + use(fn: Middleware): void { this._fns = [...this._fns, fn]; } } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/OpenAPI.ts.snap index 7286660a4..438d879ee 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_legacy_positional_args/core/OpenAPI.ts.snap @@ -11,14 +11,14 @@ export class Interceptors { this._fns = []; } - eject(fn: Middleware) { + eject(fn: Middleware): void { const index = this._fns.indexOf(fn); if (index !== -1) { this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; } } - use(fn: Middleware) { + use(fn: Middleware): void { this._fns = [...this._fns, fn]; } } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/OpenAPI.ts.snap index 091d25a4e..e62d0c4ce 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/core/OpenAPI.ts.snap @@ -12,14 +12,14 @@ export class Interceptors { this._fns = []; } - eject(fn: Middleware) { + eject(fn: Middleware): void { const index = this._fns.indexOf(fn); if (index !== -1) { this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; } } - use(fn: Middleware) { + use(fn: Middleware): void { this._fns = [...this._fns, fn]; } } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/OpenAPI.ts.snap index 7286660a4..438d879ee 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_options/core/OpenAPI.ts.snap @@ -11,14 +11,14 @@ export class Interceptors { this._fns = []; } - eject(fn: Middleware) { + eject(fn: Middleware): void { const index = this._fns.indexOf(fn); if (index !== -1) { this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; } } - use(fn: Middleware) { + use(fn: Middleware): void { this._fns = [...this._fns, fn]; } } diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/OpenAPI.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/OpenAPI.ts.snap index ec476fed8..afe4ec663 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/OpenAPI.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_xhr/core/OpenAPI.ts.snap @@ -11,14 +11,14 @@ export class Interceptors { this._fns = []; } - eject(fn: Middleware) { + eject(fn: Middleware): void { const index = this._fns.indexOf(fn); if (index !== -1) { this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; } } - use(fn: Middleware) { + use(fn: Middleware): void { this._fns = [...this._fns, fn]; } }