1: Some earlier versions required type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; to also be defined (it was added in later versions of TypeScript).
With typescript-json-schema version 0.37.0, a test file of:
type result = "ok" | "fail" | "abort" | "";
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type not_ok = Omit<result, "ok">;
class MyObject {
foo: not_ok;
bar: result | string;
}
Is the original array type expected in version 0.37.0?
Is the new array-like object expected from version 0.38.0 onwards?
It looks like https://github.com/YousefED/typescript-json-schema/pull/277 changed this behaviour, and indeed when I checked out version 0.38.0 and removed the ts.ObjectFlags.Mapped that was added in typescript-json-schema.ts, the original array type is generated for my test file above.
Starting from https://github.com/YousefED/typescript-json-schema/blob/1b65adb0cd56cbad61200533ebe5982e85d87c5b/test/programs/string-literals/main.ts , I created a version that uses
Omit
:With
typescript-json-schema
version 0.54.0 (and in fact from version 0.38.0 onwards1), this code generates this JSON schema:1: Some earlier versions required
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
to also be defined (it was added in later versions of TypeScript).With
typescript-json-schema
version 0.37.0, a test file of:... generates this JSON schema:
Is the original array type expected in version 0.37.0? Is the new array-like object expected from version 0.38.0 onwards?
It looks like https://github.com/YousefED/typescript-json-schema/pull/277 changed this behaviour, and indeed when I checked out version 0.38.0 and removed the
ts.ObjectFlags.Mapped
that was added intypescript-json-schema.ts
, the original array type is generated for my test file above.