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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ A major release with breaking changes. Involves updating type signatures to matc
### 3.5.4

- Fix for @tanstack/query v5.89.0 onError, onSuccess and onSettled signature change referenced in issue 9660

### 3.5.5

- Fix `nullable: true` not being honored for `object` types with `additionalProperties` (dictionary types). Both code paths in `src/common/util.ts` now wrap the dictionary type with `appendNullToUnion` so `| null` is appended when `nullable: true` is set.
18 changes: 18 additions & 0 deletions spec/common/types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ export type MyDictionaryValueNested = {
};
};
};
export type MyNullableDictionary = {
[key: string]: any;
} | null;
export type MyNullableDictionaryString = {
[key: string]: string;
} | null;
`;

describe("makeTypes", () => {
Expand Down Expand Up @@ -293,6 +299,18 @@ describe("makeTypes", () => {
},
},
},
MyNullableDictionary: {
type: "object",
additionalProperties: true,
nullable: true,
},
MyNullableDictionaryString: {
type: "object",
additionalProperties: {
type: "string",
},
nullable: true,
},
},
},
};
Expand Down
7 changes: 5 additions & 2 deletions src/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function schemaObjectTypeNode(
}

if (item.additionalProperties) {
return createDictionaryType($refs, item);
return appendNullToUnion(createDictionaryType($refs, item), item.nullable);
}

if (item.properties) {
Expand Down Expand Up @@ -253,7 +253,10 @@ export function nonArraySchemaObjectTypeToTs(
);
case "object": {
if (item.additionalProperties) {
return createDictionaryType($refs, item);
return appendNullToUnion(
createDictionaryType($refs, item),
item.nullable
);
}

return appendNullToUnion(
Expand Down