Skip to content
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

Merged
merged 28 commits into from
Aug 23, 2016

Conversation

zhengbli
Copy link
Contributor

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.

@zhengbli zhengbli changed the title Add two APIs for enabling CompileOnSave on tsserver WIP: Add two APIs for enabling CompileOnSave on tsserver Jul 27, 2016
@zhengbli zhengbli changed the title WIP: Add two APIs for enabling CompileOnSave on tsserver WIP: Add APIs for enabling CompileOnSave on tsserver Jul 27, 2016
@zhengbli zhengbli changed the title WIP: Add APIs for enabling CompileOnSave on tsserver Add APIs for enabling CompileOnSave on tsserver Jul 29, 2016
@@ -93,6 +93,17 @@ namespace ts {
return undefined;
}

export function findFirst<T>(array: T[], predicate: (item: T) => boolean): T {
Copy link
Contributor

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

Use Path type for internal file name matching and simplifying builder logic
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);
Copy link
Contributor

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")) {
Copy link
Contributor

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) {
Copy link
Contributor

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

@zhengbli zhengbli merged commit a082857 into microsoft:tsserverVS-WIP Aug 23, 2016
@zhengbli zhengbli deleted the compileOnSave0 branch August 23, 2016 23:20
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants