mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 00:55:32 -05:00
Add APIs for enabling CompileOnSave on tsserver (#9837)
* Add API to get only the emited declarations output * Add nonModuleBuilder * Add basic tests for CompileOnSaveAffectedFileList API * Add API for compile single file * Avoid invoking project.languageService directly * Add API to query if compileOnSave is enabled for a project * Seperate check and emit signatures * Use Path type for internal file name matching and simplifying builder logic * Always return cascaded affected list * Correct the tsconfig file in compileOnSave tests Also move the CompileOnSave option out of compilerOptions * Reduce string to path conversion
This commit is contained in:
@@ -5,12 +5,15 @@
|
||||
/// <reference path="scanner.ts"/>
|
||||
|
||||
namespace ts {
|
||||
/* @internal */
|
||||
export const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", type: "boolean" };
|
||||
/* @internal */
|
||||
export const optionDeclarations: CommandLineOption[] = [
|
||||
{
|
||||
name: "charset",
|
||||
type: "string",
|
||||
},
|
||||
compileOnSaveCommandLineOption,
|
||||
{
|
||||
name: "declaration",
|
||||
shortName: "d",
|
||||
@@ -808,6 +811,7 @@ namespace ts {
|
||||
options.configFilePath = configFileName;
|
||||
|
||||
const { fileNames, wildcardDirectories } = getFileNames(errors);
|
||||
const compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
|
||||
|
||||
return {
|
||||
options,
|
||||
@@ -815,7 +819,8 @@ namespace ts {
|
||||
typingOptions,
|
||||
raw: json,
|
||||
errors,
|
||||
wildcardDirectories
|
||||
wildcardDirectories,
|
||||
compileOnSave
|
||||
};
|
||||
|
||||
function getFileNames(errors: Diagnostic[]): ExpandResult {
|
||||
@@ -870,6 +875,17 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean {
|
||||
if (!hasProperty(jsonOption, compileOnSaveCommandLineOption.name)) {
|
||||
return false;
|
||||
}
|
||||
const result = convertJsonOption(compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors);
|
||||
if (typeof result === "boolean" && result) {
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions, errors: Diagnostic[] } {
|
||||
const errors: Diagnostic[] = [];
|
||||
const options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
|
||||
|
||||
Reference in New Issue
Block a user