Merge branch 'release-1.4' into disableComputedProperty
This commit is contained in:
commit
e502a866df
4 changed files with 21 additions and 147 deletions
|
@ -1388,9 +1388,9 @@ module ts {
|
|||
}
|
||||
|
||||
export const enum ModuleKind {
|
||||
None,
|
||||
CommonJS,
|
||||
AMD,
|
||||
None = 0,
|
||||
CommonJS = 1,
|
||||
AMD = 2,
|
||||
}
|
||||
|
||||
export interface LineAndCharacter {
|
||||
|
@ -1403,9 +1403,9 @@ module ts {
|
|||
|
||||
|
||||
export const enum ScriptTarget {
|
||||
ES3,
|
||||
ES5,
|
||||
ES6,
|
||||
ES3 = 0,
|
||||
ES5 = 1,
|
||||
ES6 = 2,
|
||||
Latest = ES6,
|
||||
}
|
||||
|
||||
|
|
|
@ -145,14 +145,14 @@ module FourSlash {
|
|||
testOptMetadataNames.mapRoot, testOptMetadataNames.module, testOptMetadataNames.out,
|
||||
testOptMetadataNames.outDir, testOptMetadataNames.sourceMap, testOptMetadataNames.sourceRoot]
|
||||
|
||||
function convertGlobalOptionsToCompilationSettings(globalOptions: { [idx: string]: string }): ts.CompilationSettings {
|
||||
var settings: ts.CompilationSettings = {};
|
||||
function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions {
|
||||
var settings: ts.CompilerOptions = {};
|
||||
// Convert all property in globalOptions into ts.CompilationSettings
|
||||
for (var prop in globalOptions) {
|
||||
if (globalOptions.hasOwnProperty(prop)) {
|
||||
switch (prop) {
|
||||
case testOptMetadataNames.declaration:
|
||||
settings.generateDeclarationFiles = true;
|
||||
settings.declaration = true;
|
||||
break;
|
||||
case testOptMetadataNames.mapRoot:
|
||||
settings.mapRoot = globalOptions[prop];
|
||||
|
@ -161,24 +161,25 @@ module FourSlash {
|
|||
// create appropriate external module target for CompilationSettings
|
||||
switch (globalOptions[prop]) {
|
||||
case "AMD":
|
||||
settings.moduleGenTarget = ts.ModuleGenTarget.Asynchronous;
|
||||
settings.module = ts.ModuleKind.AMD;
|
||||
break;
|
||||
case "CommonJS":
|
||||
settings.moduleGenTarget = ts.ModuleGenTarget.Synchronous;
|
||||
settings.module = ts.ModuleKind.CommonJS;
|
||||
break;
|
||||
default:
|
||||
settings.moduleGenTarget = ts.ModuleGenTarget.Unspecified;
|
||||
ts.Debug.assert(globalOptions[prop] === undefined || globalOptions[prop] === "None");
|
||||
settings.module = ts.ModuleKind.None;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case testOptMetadataNames.out:
|
||||
settings.outFileOption = globalOptions[prop];
|
||||
settings.out = globalOptions[prop];
|
||||
break;
|
||||
case testOptMetadataNames.outDir:
|
||||
settings.outDirOption = globalOptions[prop];
|
||||
settings.outDir = globalOptions[prop];
|
||||
break;
|
||||
case testOptMetadataNames.sourceMap:
|
||||
settings.mapSourceFiles = true;
|
||||
settings.sourceMap = true;
|
||||
break;
|
||||
case testOptMetadataNames.sourceRoot:
|
||||
settings.sourceRoot = globalOptions[prop];
|
||||
|
@ -300,7 +301,7 @@ module FourSlash {
|
|||
this.cancellationToken = new TestCancellationToken();
|
||||
this.languageServiceShimHost = new Harness.LanguageService.TypeScriptLS(this.cancellationToken);
|
||||
|
||||
var compilationSettings = convertGlobalOptionsToCompilationSettings(this.testData.globalOptions);
|
||||
var compilationSettings = convertGlobalOptionsToCompilerOptions(this.testData.globalOptions);
|
||||
this.languageServiceShimHost.setCompilationSettings(compilationSettings);
|
||||
|
||||
var startResolveFileRef: FourSlashFile = undefined;
|
||||
|
|
|
@ -134,7 +134,7 @@ module Harness.LanguageService {
|
|||
private ls: ts.LanguageServiceShim = null;
|
||||
|
||||
private fileNameToScript: ts.Map<ScriptInfo> = {};
|
||||
private settings: ts.CompilationSettings = {};
|
||||
private settings: ts.CompilerOptions = {};
|
||||
|
||||
constructor(private cancellationToken: ts.CancellationToken = CancellationToken.None) {
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ module Harness.LanguageService {
|
|||
return this.ls;
|
||||
}
|
||||
|
||||
public setCompilationSettings(settings: ts.CompilationSettings) {
|
||||
public setCompilationSettings(settings: ts.CompilerOptions) {
|
||||
for (var key in settings) {
|
||||
if (settings.hasOwnProperty(key)) {
|
||||
this.settings[key] = settings[key];
|
||||
|
|
|
@ -169,131 +169,6 @@ module ts {
|
|||
getDefaultCompilationSettings(): string;
|
||||
}
|
||||
|
||||
/// TODO: delete this, it is only needed until the VS interface is updated
|
||||
export const enum LanguageVersion {
|
||||
EcmaScript3 = 0,
|
||||
EcmaScript5 = 1,
|
||||
EcmaScript6 = 2,
|
||||
}
|
||||
|
||||
export const enum ModuleGenTarget {
|
||||
Unspecified = 0,
|
||||
Synchronous = 1,
|
||||
Asynchronous = 2,
|
||||
}
|
||||
|
||||
export interface CompilationSettings {
|
||||
propagateEnumConstants?: boolean;
|
||||
removeComments?: boolean;
|
||||
watch?: boolean;
|
||||
noResolve?: boolean;
|
||||
allowAutomaticSemicolonInsertion?: boolean;
|
||||
noImplicitAny?: boolean;
|
||||
noLib?: boolean;
|
||||
codeGenTarget?: LanguageVersion;
|
||||
moduleGenTarget?: ModuleGenTarget;
|
||||
outFileOption?: string;
|
||||
outDirOption?: string;
|
||||
mapSourceFiles?: boolean;
|
||||
mapRoot?: string;
|
||||
sourceRoot?: string;
|
||||
generateDeclarationFiles?: boolean;
|
||||
useCaseSensitiveFileResolution?: boolean;
|
||||
gatherDiagnostics?: boolean;
|
||||
codepage?: number;
|
||||
emitBOM?: boolean;
|
||||
|
||||
// Declare indexer signature
|
||||
[index: string]: any;
|
||||
}
|
||||
|
||||
function languageVersionToScriptTarget(languageVersion: LanguageVersion): ScriptTarget {
|
||||
if (typeof languageVersion === "undefined") return undefined;
|
||||
|
||||
switch (languageVersion) {
|
||||
case LanguageVersion.EcmaScript3: return ScriptTarget.ES3
|
||||
case LanguageVersion.EcmaScript5: return ScriptTarget.ES5;
|
||||
case LanguageVersion.EcmaScript6: return ScriptTarget.ES6;
|
||||
default: throw Error("unsupported LanguageVersion value: " + languageVersion);
|
||||
}
|
||||
}
|
||||
|
||||
function moduleGenTargetToModuleKind(moduleGenTarget: ModuleGenTarget): ModuleKind {
|
||||
if (typeof moduleGenTarget === "undefined") return undefined;
|
||||
|
||||
switch (moduleGenTarget) {
|
||||
case ModuleGenTarget.Asynchronous: return ModuleKind.AMD;
|
||||
case ModuleGenTarget.Synchronous: return ModuleKind.CommonJS;
|
||||
case ModuleGenTarget.Unspecified: return ModuleKind.None;
|
||||
default: throw Error("unsupported ModuleGenTarget value: " + moduleGenTarget);
|
||||
}
|
||||
}
|
||||
|
||||
function scriptTargetTolanguageVersion(scriptTarget: ScriptTarget): LanguageVersion {
|
||||
if (typeof scriptTarget === "undefined") return undefined;
|
||||
|
||||
switch (scriptTarget) {
|
||||
case ScriptTarget.ES3: return LanguageVersion.EcmaScript3;
|
||||
case ScriptTarget.ES5: return LanguageVersion.EcmaScript5;
|
||||
case ScriptTarget.ES6: return LanguageVersion.EcmaScript6;
|
||||
default: throw Error("unsupported ScriptTarget value: " + scriptTarget);
|
||||
}
|
||||
}
|
||||
|
||||
function moduleKindToModuleGenTarget(moduleKind: ModuleKind): ModuleGenTarget {
|
||||
if (typeof moduleKind === "undefined") return undefined;
|
||||
|
||||
switch (moduleKind) {
|
||||
case ModuleKind.AMD: return ModuleGenTarget.Asynchronous;
|
||||
case ModuleKind.CommonJS: return ModuleGenTarget.Synchronous;
|
||||
case ModuleKind.None: return ModuleGenTarget.Unspecified;
|
||||
default: throw Error("unsupported ModuleKind value: " + moduleKind);
|
||||
}
|
||||
}
|
||||
|
||||
function compilationSettingsToCompilerOptions(settings: CompilationSettings): CompilerOptions {
|
||||
// TODO: we should not be converting, but use options all the way
|
||||
var options: CompilerOptions = {};
|
||||
//options.propagateEnumConstants = settings.propagateEnumConstants;
|
||||
options.removeComments = settings.removeComments;
|
||||
options.noResolve = settings.noResolve;
|
||||
options.noImplicitAny = settings.noImplicitAny;
|
||||
options.noLib = settings.noLib;
|
||||
options.target = languageVersionToScriptTarget(settings.codeGenTarget);
|
||||
options.module = moduleGenTargetToModuleKind(settings.moduleGenTarget);
|
||||
options.out = settings.outFileOption;
|
||||
options.outDir = settings.outDirOption;
|
||||
options.sourceMap = settings.mapSourceFiles;
|
||||
options.mapRoot = settings.mapRoot;
|
||||
options.sourceRoot = settings.sourceRoot;
|
||||
options.declaration = settings.generateDeclarationFiles;
|
||||
//options.useCaseSensitiveFileResolution = settings.useCaseSensitiveFileResolution;
|
||||
options.codepage = settings.codepage;
|
||||
options.emitBOM = settings.emitBOM;
|
||||
return options;
|
||||
}
|
||||
|
||||
function compilerOptionsToCompilationSettings(options: CompilerOptions): CompilationSettings {
|
||||
var settings: CompilationSettings = {};
|
||||
//options.propagateEnumConstants = settings.propagateEnumConstants;
|
||||
settings.removeComments = options.removeComments;
|
||||
settings.noResolve = options.noResolve;
|
||||
settings.noImplicitAny = options.noImplicitAny;
|
||||
settings.noLib = options.noLib;
|
||||
settings.codeGenTarget = scriptTargetTolanguageVersion(options.target);
|
||||
settings.moduleGenTarget = moduleKindToModuleGenTarget(options.module);
|
||||
settings.outFileOption = options.out;
|
||||
settings.outDirOption = options.outDir;
|
||||
settings.mapSourceFiles = options.sourceMap;
|
||||
settings.mapRoot = options.mapRoot;
|
||||
settings.sourceRoot = options.sourceRoot;
|
||||
settings.generateDeclarationFiles = options.declaration;
|
||||
// settings.useCaseSensitiveFileResolution = options.useCaseSensitiveFileResolution;
|
||||
settings.codepage = options.codepage;
|
||||
settings.emitBOM = options.emitBOM;
|
||||
return settings;
|
||||
}
|
||||
|
||||
function logInternalError(logger: Logger, err: Error) {
|
||||
logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message);
|
||||
}
|
||||
|
@ -347,9 +222,7 @@ module ts {
|
|||
throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings");
|
||||
return null;
|
||||
}
|
||||
var options = compilationSettingsToCompilerOptions(<CompilerOptions>JSON.parse(<any>settingsJson));
|
||||
|
||||
return options;
|
||||
return <CompilerOptions>JSON.parse(settingsJson);
|
||||
}
|
||||
|
||||
public getScriptFileNames(): string[] {
|
||||
|
@ -850,7 +723,7 @@ module ts {
|
|||
return this.forwardJSONCall(
|
||||
"getDefaultCompilationSettings()",
|
||||
() => {
|
||||
return compilerOptionsToCompilationSettings(getDefaultCompilerOptions());
|
||||
return getDefaultCompilerOptions();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue