Add es6 target

This commit is contained in:
Mohamed Hegazy
2014-10-11 12:52:42 -07:00
parent bdac6ca895
commit 873c1df74b
27 changed files with 602 additions and 20 deletions

View File

@@ -184,7 +184,7 @@ module TypeScript {
export function preProcessFile(fileName: string, sourceText: IScriptSnapshot, readImportFiles = true): IPreProcessedFileInfo {
var text = SimpleText.fromScriptSnapshot(sourceText);
var scanner = Scanner.createScanner(ts.ScriptTarget.ES5, text, reportDiagnostic);
var scanner = Scanner.createScanner(ts.ScriptTarget.Latest, text, reportDiagnostic);
var firstToken = scanner.scan(/*allowRegularExpression:*/ false);

View File

@@ -77,7 +77,7 @@ module ts {
update(scriptSnapshot: TypeScript.IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TypeScript.TextChangeRange): SourceFile;
}
var scanner: Scanner = createScanner(ScriptTarget.ES5, /*skipTrivia*/ true);
var scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true);
var emptyArray: any[] = [];
@@ -1456,9 +1456,9 @@ module ts {
}
export function getDefaultCompilerOptions(): CompilerOptions {
// Set "ES5" target by default for language service
// Set "ScriptTarget.Latest" target by default for language service
return {
target: ScriptTarget.ES5,
target: ScriptTarget.Latest,
module: ModuleKind.None,
};
}
@@ -3794,8 +3794,8 @@ module ts {
// before and after it have to be a non-identifier char).
var endPosition = position + symbolNameLength;
if ((position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.ES5)) &&
(endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.ES5))) {
if ((position === 0 || !isIdentifierPart(text.charCodeAt(position - 1), ScriptTarget.Latest)) &&
(endPosition === sourceLength || !isIdentifierPart(text.charCodeAt(endPosition), ScriptTarget.Latest))) {
// Found a real match. Keep searching.
positions.push(position);
}
@@ -5217,7 +5217,7 @@ module ts {
/// Classifier
export function createClassifier(host: Logger): Classifier {
var scanner = createScanner(ScriptTarget.ES5, /*skipTrivia*/ false);
var scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false);
/// We do not have a full parser support to know when we should parse a regex or not
/// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where

View File

@@ -174,6 +174,7 @@ module ts {
export enum LanguageVersion {
EcmaScript3 = 0,
EcmaScript5 = 1,
EcmaScript6 = 2,
}
export enum ModuleGenTarget {
@@ -213,6 +214,7 @@ module ts {
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);
}
}
@@ -234,6 +236,7 @@ module ts {
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);
}
}

View File

@@ -186,7 +186,7 @@ module TypeScript.Scanner {
var lastTokenInfo = { leadingTriviaWidth: -1, width: -1 };
var lastTokenInfoTokenID: number = -1;
var triviaScanner = createScannerInternal(ts.ScriptTarget.ES5, SimpleText.fromString(""), () => { });
var triviaScanner = createScannerInternal(ts.ScriptTarget.Latest, SimpleText.fromString(""), () => { });
interface IScannerToken extends ISyntaxToken {
}

View File

@@ -84,7 +84,7 @@ module TypeScript {
if (languageVersion === ts.ScriptTarget.ES3) {
return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart);
}
else if (languageVersion === ts.ScriptTarget.ES5) {
else if (languageVersion >= ts.ScriptTarget.ES5) {
return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart);
}
else {
@@ -96,7 +96,7 @@ module TypeScript {
if (languageVersion === ts.ScriptTarget.ES3) {
return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart);
}
else if (languageVersion === ts.ScriptTarget.ES5) {
else if (languageVersion >= ts.ScriptTarget.ES5) {
return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart);
}
else {