Skip to content

Fix TypeScript index signatures for mixed properties - #3127

Open
yhuikzdtguioaert wants to merge 1 commit into
glideapps:masterfrom
yhuikzdtguioaert:fix/typescript-additional-properties
Open

Fix TypeScript index signatures for mixed properties#3127
yhuikzdtguioaert wants to merge 1 commit into
glideapps:masterfrom
yhuikzdtguioaert:fix/typescript-additional-properties

Conversation

@yhuikzdtguioaert

Copy link
Copy Markdown

Fixes #3123.

What changed

TypeScript now widens a typed additionalProperties index signature with the declared property types. If any declared property is optional, the index signature also includes undefined, which is required by tsc --strict.

The ordinary unconstrained additionalProperties path remains unchanged (any/unknown), so common generated output does not gain redundant unions. Flow keeps its existing rendering through the base hook.

A JSON Schema fixture includes both a valid mixed object and an invalid additional property, covering generation, strict compilation, successful conversion, and runtime rejection.

Verification

  • npm run build — passed
  • generated --just-types output + tsc --ignoreConfig --noEmit --strict — passed for default, --prefer-types, and --prefer-unknown
  • generated converter positive round-trip and negative schema rejection — passed
  • scoped biome check for all changed source/fixture files — passed
  • Vitest on Windows: 230 passed; 6 existing platform-specific path/spawn tests failed outside the changed renderer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: TS compile error when properties and additionalProperties are incompatible

1 participant