-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
Add compilerOptions option #173
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 |
---|---|---|
|
@@ -22,6 +22,7 @@ interface ConfigurationFile extends Configuration.IConfigurationFile { | |
|
||
export class IncrementalChecker { | ||
programConfigFile: string; | ||
compilerOptions: object; | ||
linterConfigFile: string | false; | ||
watchPaths: string[]; | ||
workNumber: number; | ||
|
@@ -41,6 +42,7 @@ export class IncrementalChecker { | |
|
||
constructor( | ||
programConfigFile: string, | ||
compilerOptions: object, | ||
linterConfigFile: string | false, | ||
watchPaths: string[], | ||
workNumber: number, | ||
|
@@ -49,6 +51,7 @@ export class IncrementalChecker { | |
vue: boolean | ||
) { | ||
this.programConfigFile = programConfigFile; | ||
this.compilerOptions = compilerOptions; | ||
this.linterConfigFile = linterConfigFile; | ||
this.watchPaths = watchPaths; | ||
this.workNumber = workNumber || 0; | ||
|
@@ -68,15 +71,19 @@ export class IncrementalChecker { | |
})); | ||
} | ||
|
||
static loadProgramConfig(configFile: string) { | ||
return ts.parseJsonConfigFileContent( | ||
static loadProgramConfig(configFile: string, compilerOptions: object) { | ||
const parsed = ts.parseJsonConfigFileContent( | ||
// Regardless of the setting in the tsconfig.json we want isolatedModules to be false | ||
Object.assign(ts.readConfigFile(configFile, ts.sys.readFile).config, { | ||
isolatedModules: false | ||
}), | ||
ts.sys, | ||
path.dirname(configFile) | ||
); | ||
|
||
parsed.options = { ...parsed.options, ...compilerOptions }; | ||
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. I'm not sure if we can use object spread as it won't work on node 6 (and fork-ts-checker supports node 6). https://node.green/#ES2018-features-object-rest-spread-properties-object-spread-properties Can we switch to 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. Typescript will compile it down to 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 you use assign elsewhere in code base I don't mind changing either way! 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 that's the case then that's fine with me! |
||
|
||
return parsed; | ||
} | ||
|
||
static loadLinterConfig(configFile: string): ConfigurationFile { | ||
|
@@ -189,7 +196,10 @@ export class IncrementalChecker { | |
loadVueProgram() { | ||
this.programConfig = | ||
this.programConfig || | ||
VueProgram.loadProgramConfig(this.programConfigFile); | ||
VueProgram.loadProgramConfig( | ||
this.programConfigFile, | ||
this.compilerOptions | ||
); | ||
|
||
return VueProgram.createProgram( | ||
this.programConfig, | ||
|
@@ -203,7 +213,10 @@ export class IncrementalChecker { | |
loadDefaultProgram() { | ||
this.programConfig = | ||
this.programConfig || | ||
IncrementalChecker.loadProgramConfig(this.programConfigFile); | ||
IncrementalChecker.loadProgramConfig( | ||
this.programConfigFile, | ||
this.compilerOptions | ||
); | ||
|
||
return IncrementalChecker.createProgram( | ||
this.programConfig, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ interface ResolvedScript { | |
} | ||
|
||
export class VueProgram { | ||
static loadProgramConfig(configFile: string) { | ||
static loadProgramConfig(configFile: string, compilerOptions: object) { | ||
const extraExtensions = ['vue']; | ||
|
||
const parseConfigHost: ts.ParseConfigHost = { | ||
|
@@ -40,6 +40,7 @@ export class VueProgram { | |
); | ||
|
||
parsed.options.allowNonTsExtensions = true; | ||
parsed.options = { ...parsed.options, ...compilerOptions }; | ||
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. I'm not sure if we can use object spread as it won't work on node 6 (and fork-ts-checker supports node 6). https://node.green/#ES2018-features-object-rest-spread-properties-object-spread-properties Can we switch to Object.assign please? 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. Again - fine with this staying as is if TypeScript transpiles us to glory! 😄 |
||
|
||
return parsed; | ||
} | ||
|
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 the documented type of
compilerOptions
beobject
instead?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.
You're absolutely right. Good catch! Was a late night for me yesterday 😛