Closed nabilfreeman closed 1 year ago
I figured this out last night - It's because I typed TestSchema
as JSONSchema
instead of using satisfies
.
Here is the working code:
import { JSONSchema, FromSchema } from 'json-schema-to-ts';
export const TestSchema = {
type: 'object',
properties: {
id: { type: 'number' },
},
additionalProperties: false,
} as const satisfies JSONSchema;
export type TestColumns = FromSchema<typeof TestSchema>;
// TestColumns is type `{ id: number }`
Closing. I think this should help unblock somebody searching for "unknown" in the future. 👍
Nice !
Code to reproduce:
TS version: 5.0.4 Library version: ^2.9.1
Also tried downgrading to 2.8.2
A bit sad as I was very excited to use this library! 🥺