-
-
Notifications
You must be signed in to change notification settings - Fork 737
feat(readers/tsconfig.ts): support "extends" #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,31 +51,45 @@ export class TSConfigReader extends OptionsComponent { | |
return; | ||
} | ||
|
||
let data = ts.readConfigFile(fileName, ts.sys.readFile).config; | ||
const data = ts.readConfigFile(fileName, ts.sys.readFile).config; | ||
|
||
if (data === undefined) { | ||
event.addError('The tsconfig file %s does not contain valid JSON.', fileName); | ||
return; | ||
} | ||
|
||
if (!_.isPlainObject(data)) { | ||
event.addError('The tsconfig file %s does not contain a JSON object.', fileName); | ||
return; | ||
} | ||
|
||
data = ts.parseJsonConfigFileContent( | ||
let {options, fileNames} = ts.parseJsonConfigFileContent( | ||
data, | ||
ts.sys, | ||
Path.resolve(Path.dirname(fileName)), | ||
{}, | ||
Path.resolve(fileName)); | ||
|
||
event.inputFiles = data.fileNames; | ||
event.inputFiles = fileNames; | ||
options = _.clone(options); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we care about cloning the options here? The config parse function should be generating a plain object that wouldn't be used anywhere else anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also point out where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
if (!data.typedocOptions) { | ||
data.typedocOptions = Object.create(null); | ||
} | ||
|
||
for (const key of TypeScriptSource.IGNORED) { | ||
delete options[key]; | ||
delete data.typedocOptions[key]; | ||
} | ||
|
||
_.defaults(event.data, data.typedocOptions); | ||
|
||
const ignored = TypeScriptSource.IGNORED; | ||
let compilerOptions = _.clone(data.raw.compilerOptions); | ||
for (const key of ignored) { | ||
delete compilerOptions[key]; | ||
for (const key in options) { | ||
if (!_.isUndefined(event.data[key])) { | ||
delete options[key]; | ||
} | ||
} | ||
|
||
_.defaults(event.data, data.raw.typedocOptions, compilerOptions); | ||
event.compilerOptions = options; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use
event.data
for everything instead of having two ways to pass this data?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be used, but currently
event.data
is more likeevent.rawOptions
so whatever additional data is added it should not be in conflict with any of the options and should be deleted before parsing them.If the following is OK I'll make the changes:
readers/tsconfig.ts
- addparsedCompilerOptions: CompilerOptions
to theevent.data
options/options.ts
- deleteparsedCompilerOptions
fromevent.data
before parsing