Skip to content

Commit 128e322

Browse files
Copilotmrlubos
andcommitted
fix: remove redundant union of property types in index signature for unknown additionalProperties
When a schema has both `properties` and `additionalProperties: {}` (or `true`), the generator now emits `[key: string]: unknown` instead of the redundant union `[key: string]: unknown | string | null | ... | undefined`. - When additionalProperties is `unknown`, only use it for the index signature type (since `unknown` already subsumes all types including `undefined`) - For typed additionalProperties (e.g. `{ type: 'string' }`), keep current behavior of including named property types to satisfy TypeScript's index constraint - Update all affected test snapshots Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
1 parent 726eab2 commit 128e322

137 files changed

Lines changed: 166 additions & 171 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-true/types.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type ClientOptions = {
66

77
export type Foo = {
88
foo: string;
9-
[key: string]: unknown | string;
9+
[key: string]: unknown;
1010
};
1111

1212
export type Bar = Foo & {
@@ -15,7 +15,7 @@ export type Bar = Foo & {
1515

1616
export type Baz = Foo & {
1717
bar: string;
18-
[key: string]: unknown | string;
18+
[key: string]: unknown;
1919
};
2020

2121
export type Qux = {

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-true/types.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type ClientOptions = {
66

77
export type Foo = {
88
foo: string;
9-
[key: string]: unknown | string;
9+
[key: string]: unknown;
1010
};
1111

1212
export type Bar = Foo & {
@@ -15,7 +15,7 @@ export type Bar = Foo & {
1515

1616
export type Baz = Foo & {
1717
bar: string;
18-
[key: string]: unknown | string;
18+
[key: string]: unknown;
1919
};
2020

2121
export type Qux = {

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ export type ModelWithAdditionalPropertiesEqTrue = {
703703
* This is a simple string property
704704
*/
705705
prop?: string;
706-
[key: string]: unknown | string | undefined;
706+
[key: string]: unknown;
707707
};
708708

709709
export type NestedAnyOfArraysNullable = {

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ export type ModelWithAdditionalPropertiesEqTrue = {
703703
* This is a simple string property
704704
*/
705705
prop?: string;
706-
[key: string]: unknown | string | undefined;
706+
[key: string]: unknown;
707707
};
708708

709709
export type NestedAnyOfArraysNullable = {

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ export type ModelWithAdditionalPropertiesEqTrue = {
703703
* This is a simple string property
704704
*/
705705
prop?: string;
706-
[key: string]: unknown | string | undefined;
706+
[key: string]: unknown;
707707
};
708708

709709
export type NestedAnyOfArraysNullable = {

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ export type ModelWithAdditionalPropertiesEqTrue = {
703703
* This is a simple string property
704704
*/
705705
prop?: string;
706-
[key: string]: unknown | string | undefined;
706+
[key: string]: unknown;
707707
};
708708

709709
export type NestedAnyOfArraysNullable = {

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ export type ModelWithAdditionalPropertiesEqTrue = {
703703
* This is a simple string property
704704
*/
705705
prop?: string;
706-
[key: string]: unknown | string | undefined;
706+
[key: string]: unknown;
707707
};
708708

709709
export type NestedAnyOfArraysNullable = {

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ export type ModelWithAdditionalPropertiesEqTrue = {
703703
* This is a simple string property
704704
*/
705705
prop?: string;
706-
[key: string]: unknown | string | undefined;
706+
[key: string]: unknown;
707707
};
708708

709709
export type NestedAnyOfArraysNullable = {

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ export type ModelWithAdditionalPropertiesEqTrue = {
703703
* This is a simple string property
704704
*/
705705
prop?: string;
706-
[key: string]: unknown | string | undefined;
706+
[key: string]: unknown;
707707
};
708708

709709
export type NestedAnyOfArraysNullable = {

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ export type ModelWithAdditionalPropertiesEqTrue = {
703703
* This is a simple string property
704704
*/
705705
prop?: string;
706-
[key: string]: unknown | string | undefined;
706+
[key: string]: unknown;
707707
};
708708

709709
export type NestedAnyOfArraysNullable = {

0 commit comments

Comments
 (0)