From 33193b57ee318cf5b2857e9078d7ce796f51adcf Mon Sep 17 00:00:00 2001 From: kriz Date: Wed, 5 Jun 2024 19:40:56 +0300 Subject: [PATCH] Add support for experimentalDecorators ts options. To use with TS5 decorators proposal 3 --- README.md | 2 ++ typescript-json-schema-cli.ts | 3 +++ typescript-json-schema.ts | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 021428cc..3586ba6b 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ Options: --defaultNumberType Default number type. [choices: "number", "integer"] [default: "number"] --tsNodeRegister Use ts-node/register (needed for require typescript files). [boolean] [default: false] --constAsEnum Use enums with a single value when declaring constants. [boolean] [default: false] + --experimentalDecorators Use experimentalDecorators when loading typescript modules. + [boolean] [default: true] ``` ### Programmatic use diff --git a/typescript-json-schema-cli.ts b/typescript-json-schema-cli.ts index 97418620..c1bb17ba 100644 --- a/typescript-json-schema-cli.ts +++ b/typescript-json-schema-cli.ts @@ -32,6 +32,8 @@ export function run() { .describe("esModuleInterop", "Use esModuleInterop when loading typescript modules.") .boolean("skipLibCheck").default("skipLibCheck", defaultArgs.skipLibCheck) .describe("skipLibCheck", "Use skipLibCheck when loading typescript modules.") + .boolean("experimentalDecorators").default("experimentalDecorators", defaultArgs.experimentalDecorators) + .describe("skipLibCheck", "Use experimentalDecorators when loading typescript modules.") .boolean("ignoreErrors").default("ignoreErrors", defaultArgs.ignoreErrors) .describe("ignoreErrors", "Generate even if the program has errors.") .alias("out", "o") @@ -70,6 +72,7 @@ export function run() { strictNullChecks: args.strictNullChecks, esModuleInterop: args.esModuleInterop, skipLibCheck: args.skipLibCheck, + experimentalDecorators: args.experimentalDecorators, ignoreErrors: args.ignoreErrors, out: args.out, validationKeywords: args.validationKeywords, diff --git a/typescript-json-schema.ts b/typescript-json-schema.ts index 86f38724..8471203f 100644 --- a/typescript-json-schema.ts +++ b/typescript-json-schema.ts @@ -49,6 +49,7 @@ export function getDefaultArgs(): Args { strictNullChecks: false, esModuleInterop: false, skipLibCheck: false, + experimentalDecorators: true, ignoreErrors: false, out: "", validationKeywords: [], @@ -81,6 +82,7 @@ export type Args = { esModuleInterop: boolean; skipLibCheck: boolean; ignoreErrors: boolean; + experimentalDecorators: boolean; out: string; validationKeywords: string[]; include: string[]; @@ -1833,6 +1835,8 @@ export async function exec(filePattern: string, fullTypeName: string, args = get strictNullChecks: args.strictNullChecks, esModuleInterop: args.esModuleInterop, skipLibCheck: args.skipLibCheck, + emitDecoratorMetadata: args.experimentalDecorators, + experimentalDecorators: args.experimentalDecorators, }); onlyIncludeFiles = onlyIncludeFiles.map(normalizeFileName); }