Skip to content

Commit

Permalink
Add support for experimentalDecorators ts option. To use with TS5 dec…
Browse files Browse the repository at this point in the history
…orators (#606)

Co-authored-by: kriz <kos@treenity.pro>
  • Loading branch information
krizka and kriz authored Jun 6, 2024
1 parent 1bbf4a9 commit acc0c45
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions typescript-json-schema-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions typescript-json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function getDefaultArgs(): Args {
strictNullChecks: false,
esModuleInterop: false,
skipLibCheck: false,
experimentalDecorators: true,
ignoreErrors: false,
out: "",
validationKeywords: [],
Expand Down Expand Up @@ -81,6 +82,7 @@ export type Args = {
esModuleInterop: boolean;
skipLibCheck: boolean;
ignoreErrors: boolean;
experimentalDecorators: boolean;
out: string;
validationKeywords: string[];
include: string[];
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit acc0c45

Please sign in to comment.