typescript-json-schema
typescript-json-schema copied to clipboard
Programmatic compiler options are expected to be in Typescript's internal format, not the JSON format
For programmatic use, the compiler options are fed to Typescript without converting to Typescript's internal format. I don't know if this is intentional or not, but it is quite confusing.
Also the type TJS.CompilerOptions in your documentation assumes the unconverted format.
Would you consider? a) Converting this automatically b) Adding documentation to explain how to do this conversion.
I would be happy to make a PR.
Here's how I converted it:
const compilerOptions: TJS.CompilerOptions = ts.convertCompilerOptionsFromJson(require('./tsconfig.json').compilerOptions, './').options;
JSON compilerOptions:
{ lib: [ 'es6', 'dom' ],
sourceMap: true,
module: 'commonjs',
jsx: 'react',
jsxFactory: 'h',
target: 'es5',
experimentalDecorators: true,
moduleResolution: 'Node',
noImplicitAny: true,
noUnusedLocals: true,
strictNullChecks: true,
alwaysStrict: true,
allowJs: true,
typeRoots: [ './node_modules/@types/', './src/external/' ],
baseUrl: '.',
paths:
{ react: [ './node_modules/preact-compat' ],
'react-dom': [ './node_modules/preact-compat' ] } }
Typescript converted compilerOptions:
{ lib: [ 'lib.es2015.d.ts', 'lib.dom.d.ts' ],
sourceMap: true,
module: 1,
jsx: 2,
jsxFactory: 'h',
target: 1,
experimentalDecorators: true,
moduleResolution: 2,
noImplicitAny: true,
noUnusedLocals: true,
strictNullChecks: true,
alwaysStrict: true,
allowJs: true,
typeRoots: [ 'node_modules/@types/', 'src/external/' ],
baseUrl: '.',
paths:
{ react: [ './node_modules/preact-compat' ],
'react-dom': [ './node_modules/preact-compat' ] } }
Could you send a PR for a)?
Related to #97