-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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 APIs for enabling CompileOnSave on tsserver #9837
Conversation
… into compileOnSave0
@@ -93,6 +93,17 @@ namespace ts { | |||
return undefined; | |||
} | |||
|
|||
export function findFirst<T>(array: T[], predicate: (item: T) => boolean): T { |
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.
forEach
has pretty much the same semantics
Also move the CompileOnSave option out of compilerOptions
if (!hasProperty(jsonOption, "compileOnSave")) { | ||
return false; | ||
} | ||
const result = convertJsonOption({ name: "compileOnSave", type: "boolean" }, jsonOption["compileOnSave"], basePath, errors); |
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.
extract { name: "compileOnSave", type: "boolean" }
into a variable so it can be used here and in commandLineParser.ts
@@ -771,6 +776,17 @@ namespace ts { | |||
} | |||
} | |||
|
|||
export function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean { | |||
if (!hasProperty(jsonOption, "compileOnSave")) { |
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.
hasProperty(jsonOption, compileOnSaveCommandLineOption.name)
return; | ||
} | ||
|
||
if (array.length === 1 && array[0] === fileInfo) { |
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 can do splice
only if array[0] === fileInfo
otherwise just exit
6802f9a
to
600b05d
Compare
Added two APIs to enable "Compile On Save" on tsserver:
CompileOnSaveAffectedFileList
: returns the list of files that need to be saved and recompiled due to the current changes. The editor can use this list to queue up files to compile and prompt the user with options of saving the files / checking out the files from source control etc.CompileFile
: writes the emit output of a single file to the file system.