diff --git a/src/lib/utils/options/declaration.ts b/src/lib/utils/options/declaration.ts index 982de9653d..1225752973 100644 --- a/src/lib/utils/options/declaration.ts +++ b/src/lib/utils/options/declaration.ts @@ -95,12 +95,13 @@ export class OptionDeclaration { const map = this.map; if (map !== 'object') { const key = value ? (value + '').toLowerCase() : ''; + const values = Object.keys(map).map(key => map[key]); if (map instanceof Map && map.has(key)) { value = map.get(key); } else if (key in map) { value = map[key]; - } else if (errorCallback) { + } else if (!~values.indexOf(value) && errorCallback) { if (this.mapError) { errorCallback(this.mapError); } else { diff --git a/src/lib/utils/options/options.ts b/src/lib/utils/options/options.ts index 94d8a70d65..bc4262a5d9 100644 --- a/src/lib/utils/options/options.ts +++ b/src/lib/utils/options/options.ts @@ -152,10 +152,10 @@ export class Options extends ChildableComponent { const value = obj[key]; const declaration = this.getDeclaration(key); const shouldValueBeAnObject = declaration && declaration['map'] === 'object'; - if (typeof value === 'object' && !shouldValueBeAnObject) { + if (!Array.isArray(value) && typeof value === 'object' && !shouldValueBeAnObject) { this.setValues(value, prefix + key + '.', errorCallback); } else { - this.setValue(prefix + key, value, errorCallback); + this.setValue(prefix + key, value); } } } diff --git a/src/lib/utils/options/readers/tsconfig.ts b/src/lib/utils/options/readers/tsconfig.ts index 35f3d3428a..1b4513e367 100644 --- a/src/lib/utils/options/readers/tsconfig.ts +++ b/src/lib/utils/options/readers/tsconfig.ts @@ -51,31 +51,30 @@ export class TSConfigReader extends OptionsComponent { return; } - let data = ts.readConfigFile(fileName, ts.sys.readFile).config; - if (data === undefined) { + let { config } = ts.readConfigFile(fileName, ts.sys.readFile); + if (config === undefined) { event.addError('The tsconfig file %s does not contain valid JSON.', fileName); return; } - if (!_.isPlainObject(data)) { + if (!_.isPlainObject(config)) { event.addError('The tsconfig file %s does not contain a JSON object.', fileName); return; } - data = ts.parseJsonConfigFileContent( - data, + const { fileNames, options, raw: { typedocOptions }} = ts.parseJsonConfigFileContent( + config, ts.sys, Path.resolve(Path.dirname(fileName)), {}, Path.resolve(fileName)); - event.inputFiles = data.fileNames; + event.inputFiles = fileNames; const ignored = TypeScriptSource.IGNORED; - let compilerOptions = _.clone(data.raw.compilerOptions); for (const key of ignored) { - delete compilerOptions[key]; + delete options[key]; } - _.defaults(event.data, data.raw.typedocOptions, compilerOptions); + _.defaults(event.data, typedocOptions, options); } } diff --git a/src/lib/utils/options/sources/typescript.ts b/src/lib/utils/options/sources/typescript.ts index c4504643f2..d6808e9598 100644 --- a/src/lib/utils/options/sources/typescript.ts +++ b/src/lib/utils/options/sources/typescript.ts @@ -15,11 +15,7 @@ export class TypeScriptSource extends OptionsComponent { static IGNORED: string[] = [ 'out', 'version', 'help', 'watch', 'declaration', 'mapRoot', - 'sourceMap', 'inlineSources', 'removeComments', - // Ignore new TypeScript 2.0 options until typedoc can't manage it. - 'lib', 'noImplicitThis', - 'traceResolution', 'noUnusedParameters', 'noUnusedLocals', - 'skipLibCheck', 'declarationDir', 'types', 'typeRoots' + 'sourceMap', 'inlineSources', 'removeComments' ]; initialize() { @@ -59,6 +55,9 @@ export class TypeScriptSource extends OptionsComponent { case 'string': param.type = ParameterType.String; break; + case 'list': + param.type = ParameterType.Array; + break; default: param.type = ParameterType.Map; param.map = option.type;