typescript-json-schema icon indicating copy to clipboard operation
typescript-json-schema copied to clipboard

Programmatic compiler options are expected to be in Typescript's internal format, not the JSON format

Open peterjwest opened this issue 7 years ago • 2 comments

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' ] } }

peterjwest avatar Jan 19 '18 10:01 peterjwest

Could you send a PR for a)?

domoritz avatar Jan 19 '18 16:01 domoritz

Related to #97

jhult avatar Jun 24 '21 05:06 jhult