You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tested with typescript=5.4.5 and json-schema-to-ts=3.1.0
At least in my example:
importtype{FromSchema,JSONSchema}from'json-schema-to-ts';exportconsthealthCode={$id: 'HealthCode',type: 'string',enum: ['healthy','degraded'],}asconstsatisfiesJSONSchema;exportconsthealthRes={type: 'object',properties: {code: {$ref: 'HealthCode#',},},required: ['code'],additionalProperties: false,}asconstsatisfiesJSONSchema;exporttypeHealthRes=FromSchema<typeofhealthRes;consth: HealthRes={};// Type '{}' is not assignable to type 'never'.
all I need to do to make it working is to hydrate the ref like this:
- export type HealthRes = FromSchema<typeof healthRes;+ export type HealthRes = FromSchema<typeof healthRes, { references: [typeof healthCode] }>;
I try to refer to a definition and after that make additionalProperties: false. The expected result would be a TS type without [x: string]: unknown;
Simplified example:
It is possible to make it work if I already set additionalProperties:false in the definition, but curious if that could be done as the last step.
The text was updated successfully, but these errors were encountered: