diff --git a/bin/tsc.js b/bin/tsc.js
index 52ffd2b3b1b..83be107f8d1 100644
--- a/bin/tsc.js
+++ b/bin/tsc.js
@@ -600,10 +600,6 @@ var ts;
"\u2029": "\\u2029",
"\u0085": "\\u0085"
};
- function getDefaultLibFileName(options) {
- return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts";
- }
- ts.getDefaultLibFileName = getDefaultLibFileName;
function Symbol(flags, name) {
this.flags = flags;
this.name = name;
@@ -1076,6 +1072,12 @@ var ts;
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." },
+ Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" },
+ Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
+ Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." },
Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@@ -3383,7 +3385,7 @@ var ts;
scanner.setTextPos(pos);
scanner.scan();
var start = scanner.getTokenPos();
- return createTextSpanFromBounds(start, scanner.getTextPos());
+ return ts.createTextSpanFromBounds(start, scanner.getTextPos());
}
ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
function getErrorSpanForNode(sourceFile, node) {
@@ -3392,7 +3394,7 @@ var ts;
case 227:
var pos_1 = ts.skipTrivia(sourceFile.text, 0, false);
if (pos_1 === sourceFile.text.length) {
- return createTextSpan(0, 0);
+ return ts.createTextSpan(0, 0);
}
return getSpanOfTokenAtPosition(sourceFile, pos_1);
case 198:
@@ -3414,7 +3416,7 @@ var ts;
var pos = nodeIsMissing(errorNode)
? errorNode.pos
: ts.skipTrivia(sourceFile.text, errorNode.pos);
- return createTextSpanFromBounds(pos, errorNode.end);
+ return ts.createTextSpanFromBounds(pos, errorNode.end);
}
ts.getErrorSpanForNode = getErrorSpanForNode;
function isExternalModule(file) {
@@ -4136,115 +4138,6 @@ var ts;
return false;
}
ts.isModifier = isModifier;
- function textSpanEnd(span) {
- return span.start + span.length;
- }
- ts.textSpanEnd = textSpanEnd;
- function textSpanIsEmpty(span) {
- return span.length === 0;
- }
- ts.textSpanIsEmpty = textSpanIsEmpty;
- function textSpanContainsPosition(span, position) {
- return position >= span.start && position < textSpanEnd(span);
- }
- ts.textSpanContainsPosition = textSpanContainsPosition;
- function textSpanContainsTextSpan(span, other) {
- return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
- }
- ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
- function textSpanOverlapsWith(span, other) {
- var overlapStart = Math.max(span.start, other.start);
- var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
- return overlapStart < overlapEnd;
- }
- ts.textSpanOverlapsWith = textSpanOverlapsWith;
- function textSpanOverlap(span1, span2) {
- var overlapStart = Math.max(span1.start, span2.start);
- var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
- if (overlapStart < overlapEnd) {
- return createTextSpanFromBounds(overlapStart, overlapEnd);
- }
- return undefined;
- }
- ts.textSpanOverlap = textSpanOverlap;
- function textSpanIntersectsWithTextSpan(span, other) {
- return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start;
- }
- ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
- function textSpanIntersectsWith(span, start, length) {
- var end = start + length;
- return start <= textSpanEnd(span) && end >= span.start;
- }
- ts.textSpanIntersectsWith = textSpanIntersectsWith;
- function textSpanIntersectsWithPosition(span, position) {
- return position <= textSpanEnd(span) && position >= span.start;
- }
- ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
- function textSpanIntersection(span1, span2) {
- var intersectStart = Math.max(span1.start, span2.start);
- var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
- if (intersectStart <= intersectEnd) {
- return createTextSpanFromBounds(intersectStart, intersectEnd);
- }
- return undefined;
- }
- ts.textSpanIntersection = textSpanIntersection;
- function createTextSpan(start, length) {
- if (start < 0) {
- throw new Error("start < 0");
- }
- if (length < 0) {
- throw new Error("length < 0");
- }
- return { start: start, length: length };
- }
- ts.createTextSpan = createTextSpan;
- function createTextSpanFromBounds(start, end) {
- return createTextSpan(start, end - start);
- }
- ts.createTextSpanFromBounds = createTextSpanFromBounds;
- function textChangeRangeNewSpan(range) {
- return createTextSpan(range.span.start, range.newLength);
- }
- ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
- function textChangeRangeIsUnchanged(range) {
- return textSpanIsEmpty(range.span) && range.newLength === 0;
- }
- ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
- function createTextChangeRange(span, newLength) {
- if (newLength < 0) {
- throw new Error("newLength < 0");
- }
- return { span: span, newLength: newLength };
- }
- ts.createTextChangeRange = createTextChangeRange;
- ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
- function collapseTextChangeRangesAcrossMultipleVersions(changes) {
- if (changes.length === 0) {
- return ts.unchangedTextChangeRange;
- }
- if (changes.length === 1) {
- return changes[0];
- }
- var change0 = changes[0];
- var oldStartN = change0.span.start;
- var oldEndN = textSpanEnd(change0.span);
- var newEndN = oldStartN + change0.newLength;
- for (var i = 1; i < changes.length; i++) {
- var nextChange = changes[i];
- var oldStart1 = oldStartN;
- var oldEnd1 = oldEndN;
- var newEnd1 = newEndN;
- var oldStart2 = nextChange.span.start;
- var oldEnd2 = textSpanEnd(nextChange.span);
- var newEnd2 = oldStart2 + nextChange.newLength;
- oldStartN = Math.min(oldStart1, oldStart2);
- oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
- newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
- }
- return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
- }
- ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
function nodeStartsNewLexicalEnvironment(n) {
return isFunctionLike(n) || n.kind === 205 || n.kind === 227;
}
@@ -4641,6 +4534,118 @@ var ts;
}
ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
})(ts || (ts = {}));
+var ts;
+(function (ts) {
+ function textSpanEnd(span) {
+ return span.start + span.length;
+ }
+ ts.textSpanEnd = textSpanEnd;
+ function textSpanIsEmpty(span) {
+ return span.length === 0;
+ }
+ ts.textSpanIsEmpty = textSpanIsEmpty;
+ function textSpanContainsPosition(span, position) {
+ return position >= span.start && position < textSpanEnd(span);
+ }
+ ts.textSpanContainsPosition = textSpanContainsPosition;
+ function textSpanContainsTextSpan(span, other) {
+ return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
+ }
+ ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
+ function textSpanOverlapsWith(span, other) {
+ var overlapStart = Math.max(span.start, other.start);
+ var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
+ return overlapStart < overlapEnd;
+ }
+ ts.textSpanOverlapsWith = textSpanOverlapsWith;
+ function textSpanOverlap(span1, span2) {
+ var overlapStart = Math.max(span1.start, span2.start);
+ var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
+ if (overlapStart < overlapEnd) {
+ return createTextSpanFromBounds(overlapStart, overlapEnd);
+ }
+ return undefined;
+ }
+ ts.textSpanOverlap = textSpanOverlap;
+ function textSpanIntersectsWithTextSpan(span, other) {
+ return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start;
+ }
+ ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
+ function textSpanIntersectsWith(span, start, length) {
+ var end = start + length;
+ return start <= textSpanEnd(span) && end >= span.start;
+ }
+ ts.textSpanIntersectsWith = textSpanIntersectsWith;
+ function textSpanIntersectsWithPosition(span, position) {
+ return position <= textSpanEnd(span) && position >= span.start;
+ }
+ ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
+ function textSpanIntersection(span1, span2) {
+ var intersectStart = Math.max(span1.start, span2.start);
+ var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
+ if (intersectStart <= intersectEnd) {
+ return createTextSpanFromBounds(intersectStart, intersectEnd);
+ }
+ return undefined;
+ }
+ ts.textSpanIntersection = textSpanIntersection;
+ function createTextSpan(start, length) {
+ if (start < 0) {
+ throw new Error("start < 0");
+ }
+ if (length < 0) {
+ throw new Error("length < 0");
+ }
+ return { start: start, length: length };
+ }
+ ts.createTextSpan = createTextSpan;
+ function createTextSpanFromBounds(start, end) {
+ return createTextSpan(start, end - start);
+ }
+ ts.createTextSpanFromBounds = createTextSpanFromBounds;
+ function textChangeRangeNewSpan(range) {
+ return createTextSpan(range.span.start, range.newLength);
+ }
+ ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
+ function textChangeRangeIsUnchanged(range) {
+ return textSpanIsEmpty(range.span) && range.newLength === 0;
+ }
+ ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
+ function createTextChangeRange(span, newLength) {
+ if (newLength < 0) {
+ throw new Error("newLength < 0");
+ }
+ return { span: span, newLength: newLength };
+ }
+ ts.createTextChangeRange = createTextChangeRange;
+ ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
+ function collapseTextChangeRangesAcrossMultipleVersions(changes) {
+ if (changes.length === 0) {
+ return ts.unchangedTextChangeRange;
+ }
+ if (changes.length === 1) {
+ return changes[0];
+ }
+ var change0 = changes[0];
+ var oldStartN = change0.span.start;
+ var oldEndN = textSpanEnd(change0.span);
+ var newEndN = oldStartN + change0.newLength;
+ for (var i = 1; i < changes.length; i++) {
+ var nextChange = changes[i];
+ var oldStart1 = oldStartN;
+ var oldEnd1 = oldEndN;
+ var newEnd1 = newEndN;
+ var oldStart2 = nextChange.span.start;
+ var oldEnd2 = textSpanEnd(nextChange.span);
+ var newEnd2 = oldStart2 + nextChange.newLength;
+ oldStartN = Math.min(oldStart1, oldStart2);
+ oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
+ newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
+ }
+ return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
+ }
+ ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
+})(ts || (ts = {}));
///
///
var ts;
@@ -5492,7 +5497,7 @@ var ts;
if (token === 111 && inYieldContext()) {
return false;
}
- return inStrictModeContext() ? token > 111 : token > 101;
+ return token > 101;
}
function parseExpected(kind, diagnosticMessage) {
if (token === kind) {
@@ -5586,6 +5591,9 @@ var ts;
identifierCount++;
if (isIdentifier) {
var node = createNode(65);
+ if (token !== 65) {
+ node.originalKeywordKind = token;
+ }
node.text = internIdentifier(scanner.getTokenValue());
nextToken();
return finishNode(node);
@@ -7716,6 +7724,17 @@ var ts;
node.body = parseFunctionBlockOrSemicolon(false);
return finishNode(node);
}
+ function isClassMemberModifier(idToken) {
+ switch (idToken) {
+ case 109:
+ case 107:
+ case 108:
+ case 110:
+ return true;
+ default:
+ return false;
+ }
+ }
function isClassMemberStart() {
var idToken;
if (token === 52) {
@@ -7723,6 +7742,9 @@ var ts;
}
while (ts.isModifier(token)) {
idToken = token;
+ if (isClassMemberModifier(idToken)) {
+ return true;
+ }
nextToken();
}
if (token === 35) {
@@ -14170,7 +14192,7 @@ var ts;
}
function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) {
ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node));
- var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
+ var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node);
if (!hasGrammarError && node.kind === 162) {
checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node);
}
@@ -14207,7 +14229,7 @@ var ts;
}
function checkFunctionExpressionOrObjectLiteralMethodBody(node) {
ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node));
- if (node.type) {
+ if (node.type && !node.asteriskToken) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type));
}
if (node.body) {
@@ -14678,6 +14700,7 @@ var ts;
return type;
}
function checkExpression(node, contextualMapper) {
+ checkGrammarIdentifierInStrictMode(node);
return checkExpressionOrQualifiedName(node, contextualMapper);
}
function checkExpressionOrQualifiedName(node, contextualMapper) {
@@ -14772,6 +14795,7 @@ var ts;
return unknownType;
}
function checkTypeParameter(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
if (node.expression) {
grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
}
@@ -14974,9 +14998,11 @@ var ts;
checkDecorators(node);
}
function checkTypeReferenceNode(node) {
+ checkGrammarTypeReferenceInStrictMode(node.typeName);
return checkTypeReferenceOrHeritageClauseElement(node);
}
function checkHeritageClauseElement(node) {
+ checkGrammarHeritageClauseElementInStrictMode(node.expression);
return checkTypeReferenceOrHeritageClauseElement(node);
}
function checkTypeReferenceOrHeritageClauseElement(node) {
@@ -15379,6 +15405,7 @@ var ts;
}
}
function checkFunctionLikeDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSignatureDeclaration(node);
if (node.name && node.name.kind === 127) {
@@ -15398,7 +15425,7 @@ var ts;
}
}
checkSourceElement(node.body);
- if (node.type && !isAccessor(node.kind)) {
+ if (node.type && !isAccessor(node.kind) && !node.asteriskToken) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type));
}
if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !node.type && !isPrivateWithinAmbient(node)) {
@@ -15564,6 +15591,7 @@ var ts;
}
}
function checkVariableLikeDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSourceElement(node.type);
if (node.name.kind === 127) {
@@ -16087,6 +16115,7 @@ var ts;
return unknownType;
}
function checkClassDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
if (node.parent.kind !== 206 && node.parent.kind !== 227) {
grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration);
}
@@ -16275,7 +16304,7 @@ var ts;
return ok;
}
function checkInterfaceDeclaration(node) {
- checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
checkTypeParameters(node.typeParameters);
if (produceDiagnostics) {
checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
@@ -16461,7 +16490,7 @@ var ts;
if (!produceDiagnostics) {
return;
}
- checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
@@ -16514,7 +16543,7 @@ var ts;
}
function checkModuleDeclaration(node) {
if (produceDiagnostics) {
- if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
+ if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
if (!ts.isInAmbientContext(node) && node.name.kind === 8) {
grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
}
@@ -16603,7 +16632,7 @@ var ts;
checkAliasSymbol(node);
}
function checkImportDeclaration(node) {
- if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) {
+ if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) {
grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
}
if (checkExternalImportOrExportDeclaration(node)) {
@@ -16624,7 +16653,7 @@ var ts;
}
}
function checkImportEqualsDeclaration(node) {
- checkGrammarDecorators(node) || checkGrammarModifiers(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node);
if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
checkImportBinding(node);
if (node.flags & 1) {
@@ -16925,6 +16954,8 @@ var ts;
if (!(links.flags & 1)) {
checkGrammarSourceFile(node);
emitExtends = false;
+ emitDecorate = false;
+ emitParam = false;
potentialThisCollisions.length = 0;
ts.forEach(node.statements, checkSourceElement);
checkFunctionExpressionBodies(node);
@@ -17732,6 +17763,105 @@ var ts;
}
anyArrayType = createArrayType(anyType);
}
+ function isReservedwordInStrictMode(node) {
+ return (node.parserContextFlags & 1) &&
+ (node.originalKeywordKind >= 103 && node.originalKeywordKind <= 111);
+ }
+ function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) {
+ if (ts.getAncestor(identifier, 201) || ts.getAncestor(identifier, 174)) {
+ return grammarErrorOnNode(identifier, message, arg0);
+ }
+ return false;
+ }
+ function checkGrammarImportDeclarationNameInStrictMode(node) {
+ if (node.importClause) {
+ var impotClause = node.importClause;
+ if (impotClause.namedBindings) {
+ var nameBindings = impotClause.namedBindings;
+ if (nameBindings.kind === 211) {
+ var name_11 = nameBindings.name;
+ if (name_11.originalKeywordKind) {
+ var nameText = ts.declarationNameToString(name_11);
+ return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ else if (nameBindings.kind === 212) {
+ var reportError = false;
+ for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) {
+ var element = _a[_i];
+ var name_12 = element.name;
+ if (name_12.originalKeywordKind) {
+ var nameText = ts.declarationNameToString(name_12);
+ reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ return reportError;
+ }
+ }
+ }
+ return false;
+ }
+ function checkGrammarDeclarationNameInStrictMode(node) {
+ var name = node.name;
+ if (name && name.kind === 65 && isReservedwordInStrictMode(name)) {
+ var nameText = ts.declarationNameToString(name);
+ switch (node.kind) {
+ case 129:
+ case 198:
+ case 200:
+ case 128:
+ case 152:
+ case 202:
+ case 203:
+ case 204:
+ return checkGrammarIdentifierInStrictMode(name);
+ case 201:
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText);
+ case 205:
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ case 208:
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ return false;
+ }
+ function checkGrammarTypeReferenceInStrictMode(typeName) {
+ if (typeName.kind === 65) {
+ checkGrammarTypeNameInStrictMode(typeName);
+ }
+ else if (typeName.kind === 126) {
+ checkGrammarTypeNameInStrictMode(typeName.right);
+ checkGrammarTypeReferenceInStrictMode(typeName.left);
+ }
+ }
+ function checkGrammarHeritageClauseElementInStrictMode(expression) {
+ if (expression && expression.kind === 65) {
+ return checkGrammarIdentifierInStrictMode(expression);
+ }
+ else if (expression && expression.kind === 155) {
+ checkGrammarHeritageClauseElementInStrictMode(expression.expression);
+ }
+ }
+ function checkGrammarIdentifierInStrictMode(node, nameText) {
+ if (node && node.kind === 65 && isReservedwordInStrictMode(node)) {
+ if (!nameText) {
+ nameText = ts.declarationNameToString(node);
+ }
+ var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) ||
+ grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ return errorReport;
+ }
+ return false;
+ }
+ function checkGrammarTypeNameInStrictMode(node) {
+ if (node && node.kind === 65 && isReservedwordInStrictMode(node)) {
+ var nameText = ts.declarationNameToString(node);
+ var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) ||
+ grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ return errorReport;
+ }
+ return false;
+ }
function checkGrammarDecorators(node) {
if (!node.decorators) {
return false;
@@ -18101,17 +18231,17 @@ var ts;
var inStrictMode = (node.parserContextFlags & 1) !== 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var prop = _a[_i];
- var name_11 = prop.name;
+ var name_13 = prop.name;
if (prop.kind === 175 ||
- name_11.kind === 127) {
- checkGrammarComputedPropertyName(name_11);
+ name_13.kind === 127) {
+ checkGrammarComputedPropertyName(name_13);
continue;
}
var currentKind = void 0;
if (prop.kind === 224 || prop.kind === 225) {
checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
- if (name_11.kind === 7) {
- checkGrammarNumbericLiteral(name_11);
+ if (name_13.kind === 7) {
+ checkGrammarNumbericLiteral(name_13);
}
currentKind = Property;
}
@@ -18127,26 +18257,26 @@ var ts;
else {
ts.Debug.fail("Unexpected syntax kind:" + prop.kind);
}
- if (!ts.hasProperty(seen, name_11.text)) {
- seen[name_11.text] = currentKind;
+ if (!ts.hasProperty(seen, name_13.text)) {
+ seen[name_13.text] = currentKind;
}
else {
- var existingKind = seen[name_11.text];
+ var existingKind = seen[name_13.text];
if (currentKind === Property && existingKind === Property) {
if (inStrictMode) {
- grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
+ grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
}
}
else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) {
if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) {
- seen[name_11.text] = currentKind | existingKind;
+ seen[name_13.text] = currentKind | existingKind;
}
else {
- return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
+ return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
}
}
else {
- return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
+ return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
}
}
}
@@ -18465,12 +18595,11 @@ var ts;
var identifier = name;
if (contextNode && (contextNode.parserContextFlags & 1) && ts.isEvalOrArgumentsIdentifier(identifier)) {
var nameText = ts.declarationNameToString(identifier);
- if (ts.getAncestor(name, 201) || ts.getAncestor(name, 174)) {
- return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
- }
- else {
+ var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
+ if (!reportErrorInClassDeclaration) {
return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText);
}
+ return reportErrorInClassDeclaration;
}
}
}
@@ -18919,9 +19048,9 @@ var ts;
}
var count = 0;
while (true) {
- var name_12 = baseName + "_" + (++count);
- if (!ts.hasProperty(currentSourceFile.identifiers, name_12)) {
- return name_12;
+ var name_14 = baseName + "_" + (++count);
+ if (!ts.hasProperty(currentSourceFile.identifiers, name_14)) {
+ return name_14;
}
}
}
@@ -20003,9 +20132,9 @@ var ts;
var count = tempFlags & 268435455;
tempFlags++;
if (count !== 8 && count !== 13) {
- var name_13 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26);
- if (isUniqueName(name_13)) {
- return name_13;
+ var name_15 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26);
+ if (isUniqueName(name_15)) {
+ return name_15;
}
}
}
@@ -20033,8 +20162,8 @@ var ts;
}
function generateNameForModuleOrEnum(node) {
if (node.name.kind === 65) {
- var name_14 = node.name.text;
- assignGeneratedName(node, isUniqueLocalName(name_14, node) ? name_14 : makeUniqueName(name_14));
+ var name_16 = node.name.text;
+ assignGeneratedName(node, isUniqueLocalName(name_16, node) ? name_16 : makeUniqueName(name_16));
}
}
function generateNameForImportOrExportDeclaration(node) {
@@ -20214,8 +20343,8 @@ var ts;
if (scopeName) {
var parentIndex = getSourceMapNameIndex();
if (parentIndex !== -1) {
- var name_15 = node.name;
- if (!name_15 || name_15.kind !== 127) {
+ var name_17 = node.name;
+ if (!name_17 || name_17.kind !== 127) {
scopeName = "." + scopeName;
}
scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName;
@@ -20242,9 +20371,9 @@ var ts;
node.kind === 201 ||
node.kind === 204) {
if (node.name) {
- var name_16 = node.name;
- scopeName = name_16.kind === 127
- ? ts.getTextOfNode(name_16)
+ var name_18 = node.name;
+ scopeName = name_18.kind === 127
+ ? ts.getTextOfNode(name_18)
: node.name.text;
}
recordScopeNameStart(scopeName);
@@ -20657,6 +20786,7 @@ var ts;
default:
return -1;
}
+ case 172:
case 170:
return -1;
default:
@@ -20828,6 +20958,16 @@ var ts;
write("...");
emit(node.expression);
}
+ function emitYieldExpression(node) {
+ write(ts.tokenToString(111));
+ if (node.asteriskToken) {
+ write("*");
+ }
+ if (node.expression) {
+ write(" ");
+ emit(node.expression);
+ }
+ }
function needsParenthesisForPropertyAccessOrInvocation(node) {
switch (node.kind) {
case 65:
@@ -21069,6 +21209,9 @@ var ts;
write("]");
}
function emitMethod(node) {
+ if (languageVersion >= 2 && node.asteriskToken) {
+ write("*");
+ }
emit(node.name, false);
if (languageVersion < 2) {
write(": function ");
@@ -22054,12 +22197,12 @@ var ts;
function emitParameter(node) {
if (languageVersion < 2) {
if (ts.isBindingPattern(node.name)) {
- var name_17 = createTempVariable(0);
+ var name_19 = createTempVariable(0);
if (!tempParameters) {
tempParameters = [];
}
- tempParameters.push(name_17);
- emit(name_17);
+ tempParameters.push(name_19);
+ emit(name_19);
}
else {
emit(node.name);
@@ -22178,7 +22321,11 @@ var ts;
write("default ");
}
}
- write("function ");
+ write("function");
+ if (languageVersion >= 2 && node.asteriskToken) {
+ write("*");
+ }
+ write(" ");
}
if (shouldEmitFunctionName(node)) {
emitDeclarationName(node);
@@ -22510,6 +22657,9 @@ var ts;
else if (member.kind === 137) {
write("set ");
}
+ if (member.asteriskToken) {
+ write("*");
+ }
emit(member.name);
emitSignatureAndBody(member);
emitEnd(member);
@@ -23475,8 +23625,8 @@ var ts;
else {
for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) {
var specifier = _d[_c];
- var name_18 = (specifier.propertyName || specifier.name).text;
- (exportSpecifiers[name_18] || (exportSpecifiers[name_18] = [])).push(specifier);
+ var name_20 = (specifier.propertyName || specifier.name).text;
+ (exportSpecifiers[name_20] || (exportSpecifiers[name_20] = [])).push(specifier);
}
}
break;
@@ -23787,6 +23937,8 @@ var ts;
return emitConditionalExpression(node);
case 173:
return emitSpreadElementExpression(node);
+ case 172:
+ return emitYieldExpression(node);
case 175:
return;
case 179:
@@ -24060,7 +24212,7 @@ var ts;
}
return {
getSourceFile: getSourceFile,
- getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
+ getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), getDefaultLibFileName(options)); },
writeFile: writeFile,
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
@@ -24100,6 +24252,10 @@ var ts;
}
}
ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
+ function getDefaultLibFileName(options) {
+ return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts";
+ }
+ ts.getDefaultLibFileName = getDefaultLibFileName;
function createProgram(rootNames, options, host) {
var program;
var files = [];
diff --git a/bin/tsserver.js b/bin/tsserver.js
index ba3c349c046..e8f4bd1398a 100644
--- a/bin/tsserver.js
+++ b/bin/tsserver.js
@@ -600,10 +600,6 @@ var ts;
"\u2029": "\\u2029",
"\u0085": "\\u0085"
};
- function getDefaultLibFileName(options) {
- return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts";
- }
- ts.getDefaultLibFileName = getDefaultLibFileName;
function Symbol(flags, name) {
this.flags = flags;
this.name = name;
@@ -1076,6 +1072,12 @@ var ts;
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." },
+ Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" },
+ Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
+ Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." },
Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@@ -3217,7 +3219,7 @@ var ts;
scanner.setTextPos(pos);
scanner.scan();
var start = scanner.getTokenPos();
- return createTextSpanFromBounds(start, scanner.getTextPos());
+ return ts.createTextSpanFromBounds(start, scanner.getTextPos());
}
ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
function getErrorSpanForNode(sourceFile, node) {
@@ -3226,7 +3228,7 @@ var ts;
case 227:
var pos_1 = ts.skipTrivia(sourceFile.text, 0, false);
if (pos_1 === sourceFile.text.length) {
- return createTextSpan(0, 0);
+ return ts.createTextSpan(0, 0);
}
return getSpanOfTokenAtPosition(sourceFile, pos_1);
case 198:
@@ -3248,7 +3250,7 @@ var ts;
var pos = nodeIsMissing(errorNode)
? errorNode.pos
: ts.skipTrivia(sourceFile.text, errorNode.pos);
- return createTextSpanFromBounds(pos, errorNode.end);
+ return ts.createTextSpanFromBounds(pos, errorNode.end);
}
ts.getErrorSpanForNode = getErrorSpanForNode;
function isExternalModule(file) {
@@ -3970,115 +3972,6 @@ var ts;
return false;
}
ts.isModifier = isModifier;
- function textSpanEnd(span) {
- return span.start + span.length;
- }
- ts.textSpanEnd = textSpanEnd;
- function textSpanIsEmpty(span) {
- return span.length === 0;
- }
- ts.textSpanIsEmpty = textSpanIsEmpty;
- function textSpanContainsPosition(span, position) {
- return position >= span.start && position < textSpanEnd(span);
- }
- ts.textSpanContainsPosition = textSpanContainsPosition;
- function textSpanContainsTextSpan(span, other) {
- return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
- }
- ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
- function textSpanOverlapsWith(span, other) {
- var overlapStart = Math.max(span.start, other.start);
- var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
- return overlapStart < overlapEnd;
- }
- ts.textSpanOverlapsWith = textSpanOverlapsWith;
- function textSpanOverlap(span1, span2) {
- var overlapStart = Math.max(span1.start, span2.start);
- var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
- if (overlapStart < overlapEnd) {
- return createTextSpanFromBounds(overlapStart, overlapEnd);
- }
- return undefined;
- }
- ts.textSpanOverlap = textSpanOverlap;
- function textSpanIntersectsWithTextSpan(span, other) {
- return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start;
- }
- ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
- function textSpanIntersectsWith(span, start, length) {
- var end = start + length;
- return start <= textSpanEnd(span) && end >= span.start;
- }
- ts.textSpanIntersectsWith = textSpanIntersectsWith;
- function textSpanIntersectsWithPosition(span, position) {
- return position <= textSpanEnd(span) && position >= span.start;
- }
- ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
- function textSpanIntersection(span1, span2) {
- var intersectStart = Math.max(span1.start, span2.start);
- var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
- if (intersectStart <= intersectEnd) {
- return createTextSpanFromBounds(intersectStart, intersectEnd);
- }
- return undefined;
- }
- ts.textSpanIntersection = textSpanIntersection;
- function createTextSpan(start, length) {
- if (start < 0) {
- throw new Error("start < 0");
- }
- if (length < 0) {
- throw new Error("length < 0");
- }
- return { start: start, length: length };
- }
- ts.createTextSpan = createTextSpan;
- function createTextSpanFromBounds(start, end) {
- return createTextSpan(start, end - start);
- }
- ts.createTextSpanFromBounds = createTextSpanFromBounds;
- function textChangeRangeNewSpan(range) {
- return createTextSpan(range.span.start, range.newLength);
- }
- ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
- function textChangeRangeIsUnchanged(range) {
- return textSpanIsEmpty(range.span) && range.newLength === 0;
- }
- ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
- function createTextChangeRange(span, newLength) {
- if (newLength < 0) {
- throw new Error("newLength < 0");
- }
- return { span: span, newLength: newLength };
- }
- ts.createTextChangeRange = createTextChangeRange;
- ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
- function collapseTextChangeRangesAcrossMultipleVersions(changes) {
- if (changes.length === 0) {
- return ts.unchangedTextChangeRange;
- }
- if (changes.length === 1) {
- return changes[0];
- }
- var change0 = changes[0];
- var oldStartN = change0.span.start;
- var oldEndN = textSpanEnd(change0.span);
- var newEndN = oldStartN + change0.newLength;
- for (var i = 1; i < changes.length; i++) {
- var nextChange = changes[i];
- var oldStart1 = oldStartN;
- var oldEnd1 = oldEndN;
- var newEnd1 = newEndN;
- var oldStart2 = nextChange.span.start;
- var oldEnd2 = textSpanEnd(nextChange.span);
- var newEnd2 = oldStart2 + nextChange.newLength;
- oldStartN = Math.min(oldStart1, oldStart2);
- oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
- newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
- }
- return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
- }
- ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
function nodeStartsNewLexicalEnvironment(n) {
return isFunctionLike(n) || n.kind === 205 || n.kind === 227;
}
@@ -4475,6 +4368,118 @@ var ts;
}
ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
})(ts || (ts = {}));
+var ts;
+(function (ts) {
+ function textSpanEnd(span) {
+ return span.start + span.length;
+ }
+ ts.textSpanEnd = textSpanEnd;
+ function textSpanIsEmpty(span) {
+ return span.length === 0;
+ }
+ ts.textSpanIsEmpty = textSpanIsEmpty;
+ function textSpanContainsPosition(span, position) {
+ return position >= span.start && position < textSpanEnd(span);
+ }
+ ts.textSpanContainsPosition = textSpanContainsPosition;
+ function textSpanContainsTextSpan(span, other) {
+ return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
+ }
+ ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
+ function textSpanOverlapsWith(span, other) {
+ var overlapStart = Math.max(span.start, other.start);
+ var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
+ return overlapStart < overlapEnd;
+ }
+ ts.textSpanOverlapsWith = textSpanOverlapsWith;
+ function textSpanOverlap(span1, span2) {
+ var overlapStart = Math.max(span1.start, span2.start);
+ var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
+ if (overlapStart < overlapEnd) {
+ return createTextSpanFromBounds(overlapStart, overlapEnd);
+ }
+ return undefined;
+ }
+ ts.textSpanOverlap = textSpanOverlap;
+ function textSpanIntersectsWithTextSpan(span, other) {
+ return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start;
+ }
+ ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
+ function textSpanIntersectsWith(span, start, length) {
+ var end = start + length;
+ return start <= textSpanEnd(span) && end >= span.start;
+ }
+ ts.textSpanIntersectsWith = textSpanIntersectsWith;
+ function textSpanIntersectsWithPosition(span, position) {
+ return position <= textSpanEnd(span) && position >= span.start;
+ }
+ ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
+ function textSpanIntersection(span1, span2) {
+ var intersectStart = Math.max(span1.start, span2.start);
+ var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
+ if (intersectStart <= intersectEnd) {
+ return createTextSpanFromBounds(intersectStart, intersectEnd);
+ }
+ return undefined;
+ }
+ ts.textSpanIntersection = textSpanIntersection;
+ function createTextSpan(start, length) {
+ if (start < 0) {
+ throw new Error("start < 0");
+ }
+ if (length < 0) {
+ throw new Error("length < 0");
+ }
+ return { start: start, length: length };
+ }
+ ts.createTextSpan = createTextSpan;
+ function createTextSpanFromBounds(start, end) {
+ return createTextSpan(start, end - start);
+ }
+ ts.createTextSpanFromBounds = createTextSpanFromBounds;
+ function textChangeRangeNewSpan(range) {
+ return createTextSpan(range.span.start, range.newLength);
+ }
+ ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
+ function textChangeRangeIsUnchanged(range) {
+ return textSpanIsEmpty(range.span) && range.newLength === 0;
+ }
+ ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
+ function createTextChangeRange(span, newLength) {
+ if (newLength < 0) {
+ throw new Error("newLength < 0");
+ }
+ return { span: span, newLength: newLength };
+ }
+ ts.createTextChangeRange = createTextChangeRange;
+ ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
+ function collapseTextChangeRangesAcrossMultipleVersions(changes) {
+ if (changes.length === 0) {
+ return ts.unchangedTextChangeRange;
+ }
+ if (changes.length === 1) {
+ return changes[0];
+ }
+ var change0 = changes[0];
+ var oldStartN = change0.span.start;
+ var oldEndN = textSpanEnd(change0.span);
+ var newEndN = oldStartN + change0.newLength;
+ for (var i = 1; i < changes.length; i++) {
+ var nextChange = changes[i];
+ var oldStart1 = oldStartN;
+ var oldEnd1 = oldEndN;
+ var newEnd1 = newEndN;
+ var oldStart2 = nextChange.span.start;
+ var oldEnd2 = textSpanEnd(nextChange.span);
+ var newEnd2 = oldStart2 + nextChange.newLength;
+ oldStartN = Math.min(oldStart1, oldStart2);
+ oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
+ newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
+ }
+ return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
+ }
+ ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
+})(ts || (ts = {}));
///
///
var ts;
@@ -5326,7 +5331,7 @@ var ts;
if (token === 111 && inYieldContext()) {
return false;
}
- return inStrictModeContext() ? token > 111 : token > 101;
+ return token > 101;
}
function parseExpected(kind, diagnosticMessage) {
if (token === kind) {
@@ -5420,6 +5425,9 @@ var ts;
identifierCount++;
if (isIdentifier) {
var node = createNode(65);
+ if (token !== 65) {
+ node.originalKeywordKind = token;
+ }
node.text = internIdentifier(scanner.getTokenValue());
nextToken();
return finishNode(node);
@@ -7550,6 +7558,17 @@ var ts;
node.body = parseFunctionBlockOrSemicolon(false);
return finishNode(node);
}
+ function isClassMemberModifier(idToken) {
+ switch (idToken) {
+ case 109:
+ case 107:
+ case 108:
+ case 110:
+ return true;
+ default:
+ return false;
+ }
+ }
function isClassMemberStart() {
var idToken;
if (token === 52) {
@@ -7557,6 +7576,9 @@ var ts;
}
while (ts.isModifier(token)) {
idToken = token;
+ if (isClassMemberModifier(idToken)) {
+ return true;
+ }
nextToken();
}
if (token === 35) {
@@ -14513,7 +14535,7 @@ var ts;
}
function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) {
ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node));
- var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
+ var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node);
if (!hasGrammarError && node.kind === 162) {
checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node);
}
@@ -14550,7 +14572,7 @@ var ts;
}
function checkFunctionExpressionOrObjectLiteralMethodBody(node) {
ts.Debug.assert(node.kind !== 134 || ts.isObjectLiteralMethod(node));
- if (node.type) {
+ if (node.type && !node.asteriskToken) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type));
}
if (node.body) {
@@ -15021,6 +15043,7 @@ var ts;
return type;
}
function checkExpression(node, contextualMapper) {
+ checkGrammarIdentifierInStrictMode(node);
return checkExpressionOrQualifiedName(node, contextualMapper);
}
function checkExpressionOrQualifiedName(node, contextualMapper) {
@@ -15115,6 +15138,7 @@ var ts;
return unknownType;
}
function checkTypeParameter(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
if (node.expression) {
grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
}
@@ -15317,9 +15341,11 @@ var ts;
checkDecorators(node);
}
function checkTypeReferenceNode(node) {
+ checkGrammarTypeReferenceInStrictMode(node.typeName);
return checkTypeReferenceOrHeritageClauseElement(node);
}
function checkHeritageClauseElement(node) {
+ checkGrammarHeritageClauseElementInStrictMode(node.expression);
return checkTypeReferenceOrHeritageClauseElement(node);
}
function checkTypeReferenceOrHeritageClauseElement(node) {
@@ -15722,6 +15748,7 @@ var ts;
}
}
function checkFunctionLikeDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSignatureDeclaration(node);
if (node.name && node.name.kind === 127) {
@@ -15741,7 +15768,7 @@ var ts;
}
}
checkSourceElement(node.body);
- if (node.type && !isAccessor(node.kind)) {
+ if (node.type && !isAccessor(node.kind) && !node.asteriskToken) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type));
}
if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !node.type && !isPrivateWithinAmbient(node)) {
@@ -15907,6 +15934,7 @@ var ts;
}
}
function checkVariableLikeDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSourceElement(node.type);
if (node.name.kind === 127) {
@@ -16430,6 +16458,7 @@ var ts;
return unknownType;
}
function checkClassDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
if (node.parent.kind !== 206 && node.parent.kind !== 227) {
grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration);
}
@@ -16618,7 +16647,7 @@ var ts;
return ok;
}
function checkInterfaceDeclaration(node) {
- checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
checkTypeParameters(node.typeParameters);
if (produceDiagnostics) {
checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
@@ -16804,7 +16833,7 @@ var ts;
if (!produceDiagnostics) {
return;
}
- checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
@@ -16857,7 +16886,7 @@ var ts;
}
function checkModuleDeclaration(node) {
if (produceDiagnostics) {
- if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
+ if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
if (!ts.isInAmbientContext(node) && node.name.kind === 8) {
grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
}
@@ -16946,7 +16975,7 @@ var ts;
checkAliasSymbol(node);
}
function checkImportDeclaration(node) {
- if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) {
+ if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) {
grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
}
if (checkExternalImportOrExportDeclaration(node)) {
@@ -16967,7 +16996,7 @@ var ts;
}
}
function checkImportEqualsDeclaration(node) {
- checkGrammarDecorators(node) || checkGrammarModifiers(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node);
if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
checkImportBinding(node);
if (node.flags & 1) {
@@ -17268,6 +17297,8 @@ var ts;
if (!(links.flags & 1)) {
checkGrammarSourceFile(node);
emitExtends = false;
+ emitDecorate = false;
+ emitParam = false;
potentialThisCollisions.length = 0;
ts.forEach(node.statements, checkSourceElement);
checkFunctionExpressionBodies(node);
@@ -18075,6 +18106,105 @@ var ts;
}
anyArrayType = createArrayType(anyType);
}
+ function isReservedwordInStrictMode(node) {
+ return (node.parserContextFlags & 1) &&
+ (node.originalKeywordKind >= 103 && node.originalKeywordKind <= 111);
+ }
+ function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) {
+ if (ts.getAncestor(identifier, 201) || ts.getAncestor(identifier, 174)) {
+ return grammarErrorOnNode(identifier, message, arg0);
+ }
+ return false;
+ }
+ function checkGrammarImportDeclarationNameInStrictMode(node) {
+ if (node.importClause) {
+ var impotClause = node.importClause;
+ if (impotClause.namedBindings) {
+ var nameBindings = impotClause.namedBindings;
+ if (nameBindings.kind === 211) {
+ var name_11 = nameBindings.name;
+ if (name_11.originalKeywordKind) {
+ var nameText = ts.declarationNameToString(name_11);
+ return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ else if (nameBindings.kind === 212) {
+ var reportError = false;
+ for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) {
+ var element = _a[_i];
+ var name_12 = element.name;
+ if (name_12.originalKeywordKind) {
+ var nameText = ts.declarationNameToString(name_12);
+ reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ return reportError;
+ }
+ }
+ }
+ return false;
+ }
+ function checkGrammarDeclarationNameInStrictMode(node) {
+ var name = node.name;
+ if (name && name.kind === 65 && isReservedwordInStrictMode(name)) {
+ var nameText = ts.declarationNameToString(name);
+ switch (node.kind) {
+ case 129:
+ case 198:
+ case 200:
+ case 128:
+ case 152:
+ case 202:
+ case 203:
+ case 204:
+ return checkGrammarIdentifierInStrictMode(name);
+ case 201:
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText);
+ case 205:
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ case 208:
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ return false;
+ }
+ function checkGrammarTypeReferenceInStrictMode(typeName) {
+ if (typeName.kind === 65) {
+ checkGrammarTypeNameInStrictMode(typeName);
+ }
+ else if (typeName.kind === 126) {
+ checkGrammarTypeNameInStrictMode(typeName.right);
+ checkGrammarTypeReferenceInStrictMode(typeName.left);
+ }
+ }
+ function checkGrammarHeritageClauseElementInStrictMode(expression) {
+ if (expression && expression.kind === 65) {
+ return checkGrammarIdentifierInStrictMode(expression);
+ }
+ else if (expression && expression.kind === 155) {
+ checkGrammarHeritageClauseElementInStrictMode(expression.expression);
+ }
+ }
+ function checkGrammarIdentifierInStrictMode(node, nameText) {
+ if (node && node.kind === 65 && isReservedwordInStrictMode(node)) {
+ if (!nameText) {
+ nameText = ts.declarationNameToString(node);
+ }
+ var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) ||
+ grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ return errorReport;
+ }
+ return false;
+ }
+ function checkGrammarTypeNameInStrictMode(node) {
+ if (node && node.kind === 65 && isReservedwordInStrictMode(node)) {
+ var nameText = ts.declarationNameToString(node);
+ var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) ||
+ grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ return errorReport;
+ }
+ return false;
+ }
function checkGrammarDecorators(node) {
if (!node.decorators) {
return false;
@@ -18444,17 +18574,17 @@ var ts;
var inStrictMode = (node.parserContextFlags & 1) !== 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var prop = _a[_i];
- var name_11 = prop.name;
+ var name_13 = prop.name;
if (prop.kind === 175 ||
- name_11.kind === 127) {
- checkGrammarComputedPropertyName(name_11);
+ name_13.kind === 127) {
+ checkGrammarComputedPropertyName(name_13);
continue;
}
var currentKind = void 0;
if (prop.kind === 224 || prop.kind === 225) {
checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
- if (name_11.kind === 7) {
- checkGrammarNumbericLiteral(name_11);
+ if (name_13.kind === 7) {
+ checkGrammarNumbericLiteral(name_13);
}
currentKind = Property;
}
@@ -18470,26 +18600,26 @@ var ts;
else {
ts.Debug.fail("Unexpected syntax kind:" + prop.kind);
}
- if (!ts.hasProperty(seen, name_11.text)) {
- seen[name_11.text] = currentKind;
+ if (!ts.hasProperty(seen, name_13.text)) {
+ seen[name_13.text] = currentKind;
}
else {
- var existingKind = seen[name_11.text];
+ var existingKind = seen[name_13.text];
if (currentKind === Property && existingKind === Property) {
if (inStrictMode) {
- grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
+ grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
}
}
else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) {
if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) {
- seen[name_11.text] = currentKind | existingKind;
+ seen[name_13.text] = currentKind | existingKind;
}
else {
- return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
+ return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
}
}
else {
- return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
+ return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
}
}
}
@@ -18808,12 +18938,11 @@ var ts;
var identifier = name;
if (contextNode && (contextNode.parserContextFlags & 1) && ts.isEvalOrArgumentsIdentifier(identifier)) {
var nameText = ts.declarationNameToString(identifier);
- if (ts.getAncestor(name, 201) || ts.getAncestor(name, 174)) {
- return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
- }
- else {
+ var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
+ if (!reportErrorInClassDeclaration) {
return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText);
}
+ return reportErrorInClassDeclaration;
}
}
}
@@ -19262,9 +19391,9 @@ var ts;
}
var count = 0;
while (true) {
- var name_12 = baseName + "_" + (++count);
- if (!ts.hasProperty(currentSourceFile.identifiers, name_12)) {
- return name_12;
+ var name_14 = baseName + "_" + (++count);
+ if (!ts.hasProperty(currentSourceFile.identifiers, name_14)) {
+ return name_14;
}
}
}
@@ -20346,9 +20475,9 @@ var ts;
var count = tempFlags & 268435455;
tempFlags++;
if (count !== 8 && count !== 13) {
- var name_13 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26);
- if (isUniqueName(name_13)) {
- return name_13;
+ var name_15 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26);
+ if (isUniqueName(name_15)) {
+ return name_15;
}
}
}
@@ -20376,8 +20505,8 @@ var ts;
}
function generateNameForModuleOrEnum(node) {
if (node.name.kind === 65) {
- var name_14 = node.name.text;
- assignGeneratedName(node, isUniqueLocalName(name_14, node) ? name_14 : makeUniqueName(name_14));
+ var name_16 = node.name.text;
+ assignGeneratedName(node, isUniqueLocalName(name_16, node) ? name_16 : makeUniqueName(name_16));
}
}
function generateNameForImportOrExportDeclaration(node) {
@@ -20557,8 +20686,8 @@ var ts;
if (scopeName) {
var parentIndex = getSourceMapNameIndex();
if (parentIndex !== -1) {
- var name_15 = node.name;
- if (!name_15 || name_15.kind !== 127) {
+ var name_17 = node.name;
+ if (!name_17 || name_17.kind !== 127) {
scopeName = "." + scopeName;
}
scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName;
@@ -20585,9 +20714,9 @@ var ts;
node.kind === 201 ||
node.kind === 204) {
if (node.name) {
- var name_16 = node.name;
- scopeName = name_16.kind === 127
- ? ts.getTextOfNode(name_16)
+ var name_18 = node.name;
+ scopeName = name_18.kind === 127
+ ? ts.getTextOfNode(name_18)
: node.name.text;
}
recordScopeNameStart(scopeName);
@@ -21000,6 +21129,7 @@ var ts;
default:
return -1;
}
+ case 172:
case 170:
return -1;
default:
@@ -21171,6 +21301,16 @@ var ts;
write("...");
emit(node.expression);
}
+ function emitYieldExpression(node) {
+ write(ts.tokenToString(111));
+ if (node.asteriskToken) {
+ write("*");
+ }
+ if (node.expression) {
+ write(" ");
+ emit(node.expression);
+ }
+ }
function needsParenthesisForPropertyAccessOrInvocation(node) {
switch (node.kind) {
case 65:
@@ -21412,6 +21552,9 @@ var ts;
write("]");
}
function emitMethod(node) {
+ if (languageVersion >= 2 && node.asteriskToken) {
+ write("*");
+ }
emit(node.name, false);
if (languageVersion < 2) {
write(": function ");
@@ -22397,12 +22540,12 @@ var ts;
function emitParameter(node) {
if (languageVersion < 2) {
if (ts.isBindingPattern(node.name)) {
- var name_17 = createTempVariable(0);
+ var name_19 = createTempVariable(0);
if (!tempParameters) {
tempParameters = [];
}
- tempParameters.push(name_17);
- emit(name_17);
+ tempParameters.push(name_19);
+ emit(name_19);
}
else {
emit(node.name);
@@ -22521,7 +22664,11 @@ var ts;
write("default ");
}
}
- write("function ");
+ write("function");
+ if (languageVersion >= 2 && node.asteriskToken) {
+ write("*");
+ }
+ write(" ");
}
if (shouldEmitFunctionName(node)) {
emitDeclarationName(node);
@@ -22853,6 +23000,9 @@ var ts;
else if (member.kind === 137) {
write("set ");
}
+ if (member.asteriskToken) {
+ write("*");
+ }
emit(member.name);
emitSignatureAndBody(member);
emitEnd(member);
@@ -23818,8 +23968,8 @@ var ts;
else {
for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) {
var specifier = _d[_c];
- var name_18 = (specifier.propertyName || specifier.name).text;
- (exportSpecifiers[name_18] || (exportSpecifiers[name_18] = [])).push(specifier);
+ var name_20 = (specifier.propertyName || specifier.name).text;
+ (exportSpecifiers[name_20] || (exportSpecifiers[name_20] = [])).push(specifier);
}
}
break;
@@ -24130,6 +24280,8 @@ var ts;
return emitConditionalExpression(node);
case 173:
return emitSpreadElementExpression(node);
+ case 172:
+ return emitYieldExpression(node);
case 175:
return;
case 179:
@@ -24403,7 +24555,7 @@ var ts;
}
return {
getSourceFile: getSourceFile,
- getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
+ getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), getDefaultLibFileName(options)); },
writeFile: writeFile,
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
@@ -24443,6 +24595,10 @@ var ts;
}
}
ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
+ function getDefaultLibFileName(options) {
+ return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts";
+ }
+ ts.getDefaultLibFileName = getDefaultLibFileName;
function createProgram(rootNames, options, host) {
var program;
var files = [];
@@ -25670,9 +25826,9 @@ var ts;
case 198:
case 152:
var variableDeclarationNode;
- var name_19;
+ var name_21;
if (node.kind === 152) {
- name_19 = node.name;
+ name_21 = node.name;
variableDeclarationNode = node;
while (variableDeclarationNode && variableDeclarationNode.kind !== 198) {
variableDeclarationNode = variableDeclarationNode.parent;
@@ -25682,16 +25838,16 @@ var ts;
else {
ts.Debug.assert(!ts.isBindingPattern(node.name));
variableDeclarationNode = node;
- name_19 = node.name;
+ name_21 = node.name;
}
if (ts.isConst(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.constElement);
+ return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.constElement);
}
else if (ts.isLet(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.letElement);
+ return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.letElement);
}
else {
- return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.variableElement);
+ return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.variableElement);
}
case 135:
return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement);
@@ -27639,9 +27795,9 @@ var ts;
}
Rules.prototype.getRuleName = function (rule) {
var o = this;
- for (var name_20 in o) {
- if (o[name_20] === rule) {
- return name_20;
+ for (var name_22 in o) {
+ if (o[name_22] === rule) {
+ return name_22;
}
}
throw new Error("Unknown rule");
@@ -31293,10 +31449,10 @@ var ts;
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
var sourceFile = _a[_i];
var nameTable = getNameTable(sourceFile);
- for (var name_21 in nameTable) {
- if (!allNames[name_21]) {
- allNames[name_21] = name_21;
- var displayName = getCompletionEntryDisplayName(name_21, target, true);
+ for (var name_23 in nameTable) {
+ if (!allNames[name_23]) {
+ allNames[name_23] = name_23;
+ var displayName = getCompletionEntryDisplayName(name_23, target, true);
if (displayName) {
var entry = {
name: displayName,
@@ -32935,17 +33091,17 @@ var ts;
if (isNameOfPropertyAssignment(node)) {
var objectLiteral = node.parent.parent;
var contextualType = typeInfoResolver.getContextualType(objectLiteral);
- var name_22 = node.text;
+ var name_24 = node.text;
if (contextualType) {
if (contextualType.flags & 16384) {
- var unionProperty = contextualType.getProperty(name_22);
+ var unionProperty = contextualType.getProperty(name_24);
if (unionProperty) {
return [unionProperty];
}
else {
var result_3 = [];
ts.forEach(contextualType.types, function (t) {
- var symbol = t.getProperty(name_22);
+ var symbol = t.getProperty(name_24);
if (symbol) {
result_3.push(symbol);
}
@@ -32954,7 +33110,7 @@ var ts;
}
}
else {
- var symbol_1 = contextualType.getProperty(name_22);
+ var symbol_1 = contextualType.getProperty(name_24);
if (symbol_1) {
return [symbol_1];
}
diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts
index a16bff2a862..1439f0de597 100644
--- a/bin/typescript.d.ts
+++ b/bin/typescript.d.ts
@@ -310,6 +310,7 @@ declare module "typescript" {
}
interface Identifier extends PrimaryExpression {
text: string;
+ originalKeywordKind?: SyntaxKind;
}
interface QualifiedName extends Node {
left: EntityName;
@@ -1181,6 +1182,33 @@ declare module "typescript" {
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
}
+declare module "typescript" {
+ function textSpanEnd(span: TextSpan): number;
+ function textSpanIsEmpty(span: TextSpan): boolean;
+ function textSpanContainsPosition(span: TextSpan, position: number): boolean;
+ function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean;
+ function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean;
+ function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
+ function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
+ function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
+ function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
+ function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
+ function createTextSpan(start: number, length: number): TextSpan;
+ function createTextSpanFromBounds(start: number, end: number): TextSpan;
+ function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
+ function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
+ function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
+ let unchangedTextChangeRange: TextChangeRange;
+ /**
+ * Called to merge all the changes that occurred across several versions of a script snapshot
+ * into a single change. i.e. if a user keeps making successive edits to a script we will
+ * have a text change from V1 to V2, V2 to V3, ..., Vn.
+ *
+ * This function will then merge those changes into a single change range valid between V1 and
+ * Vn.
+ */
+ function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
+}
declare module "typescript" {
function getNodeConstructor(kind: SyntaxKind): new () => Node;
function createNode(kind: SyntaxKind): Node;
@@ -1199,6 +1227,7 @@ declare module "typescript" {
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
+ function getDefaultLibFileName(options: CompilerOptions): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module "typescript" {
diff --git a/bin/typescript.js b/bin/typescript.js
index 1c749f0d94a..4544cc24ec1 100644
--- a/bin/typescript.js
+++ b/bin/typescript.js
@@ -1308,10 +1308,6 @@ var ts;
"\u2029": "\\u2029",
"\u0085": "\\u0085" // nextLine
};
- function getDefaultLibFileName(options) {
- return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts";
- }
- ts.getDefaultLibFileName = getDefaultLibFileName;
function Symbol(flags, name) {
this.flags = flags;
this.name = name;
@@ -1809,6 +1805,12 @@ var ts;
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." },
+ Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" },
+ Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
+ Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." },
Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@@ -4331,13 +4333,12 @@ var ts;
};
}
ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain;
- /* @internal */
function getSpanOfTokenAtPosition(sourceFile, pos) {
var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.text);
scanner.setTextPos(pos);
scanner.scan();
var start = scanner.getTokenPos();
- return createTextSpanFromBounds(start, scanner.getTextPos());
+ return ts.createTextSpanFromBounds(start, scanner.getTextPos());
}
ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
function getErrorSpanForNode(sourceFile, node) {
@@ -4347,7 +4348,7 @@ var ts;
var pos_1 = ts.skipTrivia(sourceFile.text, 0, false);
if (pos_1 === sourceFile.text.length) {
// file is empty - return span for the beginning of the file
- return createTextSpan(0, 0);
+ return ts.createTextSpan(0, 0);
}
return getSpanOfTokenAtPosition(sourceFile, pos_1);
// This list is a work in progress. Add missing node kinds to improve their error
@@ -4373,7 +4374,7 @@ var ts;
var pos = nodeIsMissing(errorNode)
? errorNode.pos
: ts.skipTrivia(sourceFile.text, errorNode.pos);
- return createTextSpanFromBounds(pos, errorNode.end);
+ return ts.createTextSpanFromBounds(pos, errorNode.end);
}
ts.getErrorSpanForNode = getErrorSpanForNode;
function isExternalModule(file) {
@@ -4482,7 +4483,6 @@ var ts;
}
}
ts.forEachReturnStatement = forEachReturnStatement;
- /* @internal */
function isVariableLike(node) {
if (node) {
switch (node.kind) {
@@ -5170,205 +5170,6 @@ var ts;
return false;
}
ts.isModifier = isModifier;
- function textSpanEnd(span) {
- return span.start + span.length;
- }
- ts.textSpanEnd = textSpanEnd;
- function textSpanIsEmpty(span) {
- return span.length === 0;
- }
- ts.textSpanIsEmpty = textSpanIsEmpty;
- function textSpanContainsPosition(span, position) {
- return position >= span.start && position < textSpanEnd(span);
- }
- ts.textSpanContainsPosition = textSpanContainsPosition;
- // Returns true if 'span' contains 'other'.
- function textSpanContainsTextSpan(span, other) {
- return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
- }
- ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
- function textSpanOverlapsWith(span, other) {
- var overlapStart = Math.max(span.start, other.start);
- var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
- return overlapStart < overlapEnd;
- }
- ts.textSpanOverlapsWith = textSpanOverlapsWith;
- function textSpanOverlap(span1, span2) {
- var overlapStart = Math.max(span1.start, span2.start);
- var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
- if (overlapStart < overlapEnd) {
- return createTextSpanFromBounds(overlapStart, overlapEnd);
- }
- return undefined;
- }
- ts.textSpanOverlap = textSpanOverlap;
- function textSpanIntersectsWithTextSpan(span, other) {
- return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start;
- }
- ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
- function textSpanIntersectsWith(span, start, length) {
- var end = start + length;
- return start <= textSpanEnd(span) && end >= span.start;
- }
- ts.textSpanIntersectsWith = textSpanIntersectsWith;
- function textSpanIntersectsWithPosition(span, position) {
- return position <= textSpanEnd(span) && position >= span.start;
- }
- ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
- function textSpanIntersection(span1, span2) {
- var intersectStart = Math.max(span1.start, span2.start);
- var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
- if (intersectStart <= intersectEnd) {
- return createTextSpanFromBounds(intersectStart, intersectEnd);
- }
- return undefined;
- }
- ts.textSpanIntersection = textSpanIntersection;
- function createTextSpan(start, length) {
- if (start < 0) {
- throw new Error("start < 0");
- }
- if (length < 0) {
- throw new Error("length < 0");
- }
- return { start: start, length: length };
- }
- ts.createTextSpan = createTextSpan;
- function createTextSpanFromBounds(start, end) {
- return createTextSpan(start, end - start);
- }
- ts.createTextSpanFromBounds = createTextSpanFromBounds;
- function textChangeRangeNewSpan(range) {
- return createTextSpan(range.span.start, range.newLength);
- }
- ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
- function textChangeRangeIsUnchanged(range) {
- return textSpanIsEmpty(range.span) && range.newLength === 0;
- }
- ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
- function createTextChangeRange(span, newLength) {
- if (newLength < 0) {
- throw new Error("newLength < 0");
- }
- return { span: span, newLength: newLength };
- }
- ts.createTextChangeRange = createTextChangeRange;
- ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
- /**
- * Called to merge all the changes that occurred across several versions of a script snapshot
- * into a single change. i.e. if a user keeps making successive edits to a script we will
- * have a text change from V1 to V2, V2 to V3, ..., Vn.
- *
- * This function will then merge those changes into a single change range valid between V1 and
- * Vn.
- */
- function collapseTextChangeRangesAcrossMultipleVersions(changes) {
- if (changes.length === 0) {
- return ts.unchangedTextChangeRange;
- }
- if (changes.length === 1) {
- return changes[0];
- }
- // We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd }
- // as it makes things much easier to reason about.
- var change0 = changes[0];
- var oldStartN = change0.span.start;
- var oldEndN = textSpanEnd(change0.span);
- var newEndN = oldStartN + change0.newLength;
- for (var i = 1; i < changes.length; i++) {
- var nextChange = changes[i];
- // Consider the following case:
- // i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting
- // at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }.
- // i.e. the span starting at 30 with length 30 is increased to length 40.
- //
- // 0 10 20 30 40 50 60 70 80 90 100
- // -------------------------------------------------------------------------------------------------------
- // | /
- // | /----
- // T1 | /----
- // | /----
- // | /----
- // -------------------------------------------------------------------------------------------------------
- // | \
- // | \
- // T2 | \
- // | \
- // | \
- // -------------------------------------------------------------------------------------------------------
- //
- // Merging these turns out to not be too difficult. First, determining the new start of the change is trivial
- // it's just the min of the old and new starts. i.e.:
- //
- // 0 10 20 30 40 50 60 70 80 90 100
- // ------------------------------------------------------------*------------------------------------------
- // | /
- // | /----
- // T1 | /----
- // | /----
- // | /----
- // ----------------------------------------$-------------------$------------------------------------------
- // . | \
- // . | \
- // T2 . | \
- // . | \
- // . | \
- // ----------------------------------------------------------------------*--------------------------------
- //
- // (Note the dots represent the newly inferrred start.
- // Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the
- // absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see
- // which if the two $'s precedes the other, and we move that one forward until they line up. in this case that
- // means:
- //
- // 0 10 20 30 40 50 60 70 80 90 100
- // --------------------------------------------------------------------------------*----------------------
- // | /
- // | /----
- // T1 | /----
- // | /----
- // | /----
- // ------------------------------------------------------------$------------------------------------------
- // . | \
- // . | \
- // T2 . | \
- // . | \
- // . | \
- // ----------------------------------------------------------------------*--------------------------------
- //
- // In other words (in this case), we're recognizing that the second edit happened after where the first edit
- // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
- // that's the same as if we started at char 80 instead of 60.
- //
- // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter
- // than pusing the first edit forward to match the second, we'll push the second edit forward to match the
- // first.
- //
- // In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange
- // semantics: { { start: 10, length: 70 }, newLength: 60 }
- //
- // The math then works out as follows.
- // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
- // final result like so:
- //
- // {
- // oldStart3: Min(oldStart1, oldStart2),
- // oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)),
- // newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2))
- // }
- var oldStart1 = oldStartN;
- var oldEnd1 = oldEndN;
- var newEnd1 = newEndN;
- var oldStart2 = nextChange.span.start;
- var oldEnd2 = textSpanEnd(nextChange.span);
- var newEnd2 = oldStart2 + nextChange.newLength;
- oldStartN = Math.min(oldStart1, oldStart2);
- oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
- newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
- }
- return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
- }
- ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
function nodeStartsNewLexicalEnvironment(n) {
return isFunctionLike(n) || n.kind === 205 /* ModuleDeclaration */ || n.kind === 227 /* SourceFile */;
}
@@ -5385,7 +5186,6 @@ var ts;
return node;
}
ts.createSynthesizedNode = createSynthesizedNode;
- /* @internal */
function createDiagnosticCollection() {
var nonFileDiagnostics = [];
var fileDiagnostics = {};
@@ -5807,6 +5607,208 @@ var ts;
}
ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
})(ts || (ts = {}));
+var ts;
+(function (ts) {
+ function textSpanEnd(span) {
+ return span.start + span.length;
+ }
+ ts.textSpanEnd = textSpanEnd;
+ function textSpanIsEmpty(span) {
+ return span.length === 0;
+ }
+ ts.textSpanIsEmpty = textSpanIsEmpty;
+ function textSpanContainsPosition(span, position) {
+ return position >= span.start && position < textSpanEnd(span);
+ }
+ ts.textSpanContainsPosition = textSpanContainsPosition;
+ // Returns true if 'span' contains 'other'.
+ function textSpanContainsTextSpan(span, other) {
+ return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
+ }
+ ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
+ function textSpanOverlapsWith(span, other) {
+ var overlapStart = Math.max(span.start, other.start);
+ var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
+ return overlapStart < overlapEnd;
+ }
+ ts.textSpanOverlapsWith = textSpanOverlapsWith;
+ function textSpanOverlap(span1, span2) {
+ var overlapStart = Math.max(span1.start, span2.start);
+ var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
+ if (overlapStart < overlapEnd) {
+ return createTextSpanFromBounds(overlapStart, overlapEnd);
+ }
+ return undefined;
+ }
+ ts.textSpanOverlap = textSpanOverlap;
+ function textSpanIntersectsWithTextSpan(span, other) {
+ return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start;
+ }
+ ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
+ function textSpanIntersectsWith(span, start, length) {
+ var end = start + length;
+ return start <= textSpanEnd(span) && end >= span.start;
+ }
+ ts.textSpanIntersectsWith = textSpanIntersectsWith;
+ function textSpanIntersectsWithPosition(span, position) {
+ return position <= textSpanEnd(span) && position >= span.start;
+ }
+ ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
+ function textSpanIntersection(span1, span2) {
+ var intersectStart = Math.max(span1.start, span2.start);
+ var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
+ if (intersectStart <= intersectEnd) {
+ return createTextSpanFromBounds(intersectStart, intersectEnd);
+ }
+ return undefined;
+ }
+ ts.textSpanIntersection = textSpanIntersection;
+ function createTextSpan(start, length) {
+ if (start < 0) {
+ throw new Error("start < 0");
+ }
+ if (length < 0) {
+ throw new Error("length < 0");
+ }
+ return { start: start, length: length };
+ }
+ ts.createTextSpan = createTextSpan;
+ function createTextSpanFromBounds(start, end) {
+ return createTextSpan(start, end - start);
+ }
+ ts.createTextSpanFromBounds = createTextSpanFromBounds;
+ function textChangeRangeNewSpan(range) {
+ return createTextSpan(range.span.start, range.newLength);
+ }
+ ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
+ function textChangeRangeIsUnchanged(range) {
+ return textSpanIsEmpty(range.span) && range.newLength === 0;
+ }
+ ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
+ function createTextChangeRange(span, newLength) {
+ if (newLength < 0) {
+ throw new Error("newLength < 0");
+ }
+ return { span: span, newLength: newLength };
+ }
+ ts.createTextChangeRange = createTextChangeRange;
+ ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
+ /**
+ * Called to merge all the changes that occurred across several versions of a script snapshot
+ * into a single change. i.e. if a user keeps making successive edits to a script we will
+ * have a text change from V1 to V2, V2 to V3, ..., Vn.
+ *
+ * This function will then merge those changes into a single change range valid between V1 and
+ * Vn.
+ */
+ function collapseTextChangeRangesAcrossMultipleVersions(changes) {
+ if (changes.length === 0) {
+ return ts.unchangedTextChangeRange;
+ }
+ if (changes.length === 1) {
+ return changes[0];
+ }
+ // We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd }
+ // as it makes things much easier to reason about.
+ var change0 = changes[0];
+ var oldStartN = change0.span.start;
+ var oldEndN = textSpanEnd(change0.span);
+ var newEndN = oldStartN + change0.newLength;
+ for (var i = 1; i < changes.length; i++) {
+ var nextChange = changes[i];
+ // Consider the following case:
+ // i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting
+ // at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }.
+ // i.e. the span starting at 30 with length 30 is increased to length 40.
+ //
+ // 0 10 20 30 40 50 60 70 80 90 100
+ // -------------------------------------------------------------------------------------------------------
+ // | /
+ // | /----
+ // T1 | /----
+ // | /----
+ // | /----
+ // -------------------------------------------------------------------------------------------------------
+ // | \
+ // | \
+ // T2 | \
+ // | \
+ // | \
+ // -------------------------------------------------------------------------------------------------------
+ //
+ // Merging these turns out to not be too difficult. First, determining the new start of the change is trivial
+ // it's just the min of the old and new starts. i.e.:
+ //
+ // 0 10 20 30 40 50 60 70 80 90 100
+ // ------------------------------------------------------------*------------------------------------------
+ // | /
+ // | /----
+ // T1 | /----
+ // | /----
+ // | /----
+ // ----------------------------------------$-------------------$------------------------------------------
+ // . | \
+ // . | \
+ // T2 . | \
+ // . | \
+ // . | \
+ // ----------------------------------------------------------------------*--------------------------------
+ //
+ // (Note the dots represent the newly inferrred start.
+ // Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the
+ // absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see
+ // which if the two $'s precedes the other, and we move that one forward until they line up. in this case that
+ // means:
+ //
+ // 0 10 20 30 40 50 60 70 80 90 100
+ // --------------------------------------------------------------------------------*----------------------
+ // | /
+ // | /----
+ // T1 | /----
+ // | /----
+ // | /----
+ // ------------------------------------------------------------$------------------------------------------
+ // . | \
+ // . | \
+ // T2 . | \
+ // . | \
+ // . | \
+ // ----------------------------------------------------------------------*--------------------------------
+ //
+ // In other words (in this case), we're recognizing that the second edit happened after where the first edit
+ // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
+ // that's the same as if we started at char 80 instead of 60.
+ //
+ // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter
+ // than pusing the first edit forward to match the second, we'll push the second edit forward to match the
+ // first.
+ //
+ // In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange
+ // semantics: { { start: 10, length: 70 }, newLength: 60 }
+ //
+ // The math then works out as follows.
+ // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
+ // final result like so:
+ //
+ // {
+ // oldStart3: Min(oldStart1, oldStart2),
+ // oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)),
+ // newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2))
+ // }
+ var oldStart1 = oldStartN;
+ var oldEnd1 = oldEndN;
+ var newEnd1 = newEndN;
+ var oldStart2 = nextChange.span.start;
+ var oldEnd2 = textSpanEnd(nextChange.span);
+ var newEnd2 = oldStart2 + nextChange.newLength;
+ oldStartN = Math.min(oldStart1, oldStart2);
+ oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
+ newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
+ }
+ return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
+ }
+ ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
+})(ts || (ts = {}));
///
///
var ts;
@@ -6995,6 +6997,7 @@ var ts;
function tryParse(callback) {
return speculationHelper(callback, false);
}
+ // Ignore strict mode flag because we will report an error in type checker instead.
function isIdentifier() {
if (token === 65 /* Identifier */) {
return true;
@@ -7004,7 +7007,7 @@ var ts;
if (token === 111 /* YieldKeyword */ && inYieldContext()) {
return false;
}
- return inStrictModeContext() ? token > 111 /* LastFutureReservedWord */ : token > 101 /* LastReservedWord */;
+ return token > 101 /* LastReservedWord */;
}
function parseExpected(kind, diagnosticMessage) {
if (token === kind) {
@@ -7108,6 +7111,10 @@ var ts;
identifierCount++;
if (isIdentifier) {
var node = createNode(65 /* Identifier */);
+ // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
+ if (token !== 65 /* Identifier */) {
+ node.originalKeywordKind = token;
+ }
node.text = internIdentifier(scanner.getTokenValue());
nextToken();
return finishNode(node);
@@ -9823,6 +9830,17 @@ var ts;
node.body = parseFunctionBlockOrSemicolon(false);
return finishNode(node);
}
+ function isClassMemberModifier(idToken) {
+ switch (idToken) {
+ case 109 /* PublicKeyword */:
+ case 107 /* PrivateKeyword */:
+ case 108 /* ProtectedKeyword */:
+ case 110 /* StaticKeyword */:
+ return true;
+ default:
+ return false;
+ }
+ }
function isClassMemberStart() {
var idToken;
if (token === 52 /* AtToken */) {
@@ -9831,6 +9849,15 @@ var ts;
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier.
while (ts.isModifier(token)) {
idToken = token;
+ // If the idToken is a class modifier (protected, private, public, and static), it is
+ // certain that we are starting to parse class member. This allows better error recovery
+ // Example:
+ // public foo() ... // true
+ // public @dec blah ... // true; we will then report an error later
+ // export public ... // true; we will then report an error later
+ if (isClassMemberModifier(idToken)) {
+ return true;
+ }
nextToken();
}
if (token === 35 /* AsteriskToken */) {
@@ -17230,7 +17257,7 @@ var ts;
function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) {
ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
// Grammar checking
- var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
+ var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node);
if (!hasGrammarError && node.kind === 162 /* FunctionExpression */) {
checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node);
}
@@ -17272,7 +17299,7 @@ var ts;
}
function checkFunctionExpressionOrObjectLiteralMethodBody(node) {
ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
- if (node.type) {
+ if (node.type && !node.asteriskToken) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type));
}
if (node.body) {
@@ -17834,6 +17861,7 @@ var ts;
return type;
}
function checkExpression(node, contextualMapper) {
+ checkGrammarIdentifierInStrictMode(node);
return checkExpressionOrQualifiedName(node, contextualMapper);
}
// Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When
@@ -17941,6 +17969,7 @@ var ts;
}
// DECLARATION AND STATEMENT TYPE CHECKING
function checkTypeParameter(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
// Grammar Checking
if (node.expression) {
grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
@@ -18172,9 +18201,11 @@ var ts;
checkDecorators(node);
}
function checkTypeReferenceNode(node) {
+ checkGrammarTypeReferenceInStrictMode(node.typeName);
return checkTypeReferenceOrHeritageClauseElement(node);
}
function checkHeritageClauseElement(node) {
+ checkGrammarHeritageClauseElementInStrictMode(node.expression);
return checkTypeReferenceOrHeritageClauseElement(node);
}
function checkTypeReferenceOrHeritageClauseElement(node) {
@@ -18648,6 +18679,7 @@ var ts;
}
}
function checkFunctionLikeDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSignatureDeclaration(node);
// Do not use hasDynamicName here, because that returns false for well known symbols.
@@ -18678,7 +18710,7 @@ var ts;
}
}
checkSourceElement(node.body);
- if (node.type && !isAccessor(node.kind)) {
+ if (node.type && !isAccessor(node.kind) && !node.asteriskToken) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type));
}
// Report an implicit any error if there is no body, no explicit return type, and node is not a private method
@@ -18891,6 +18923,7 @@ var ts;
}
// Check variable, parameter, or property declaration
function checkVariableLikeDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSourceElement(node.type);
// For a computed property, just check the initializer and exit
@@ -19521,6 +19554,7 @@ var ts;
return unknownType;
}
function checkClassDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
// Grammar checking
if (node.parent.kind !== 206 /* ModuleBlock */ && node.parent.kind !== 227 /* SourceFile */) {
grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration);
@@ -19721,7 +19755,7 @@ var ts;
}
function checkInterfaceDeclaration(node) {
// Grammar checking
- checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
checkTypeParameters(node.typeParameters);
if (produceDiagnostics) {
checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
@@ -19921,7 +19955,7 @@ var ts;
return;
}
// Grammar checking
- checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
@@ -19983,7 +20017,7 @@ var ts;
function checkModuleDeclaration(node) {
if (produceDiagnostics) {
// Grammar checking
- if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
+ if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) {
grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
}
@@ -20078,7 +20112,7 @@ var ts;
checkAliasSymbol(node);
}
function checkImportDeclaration(node) {
- if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) {
+ if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) {
grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
}
if (checkExternalImportOrExportDeclaration(node)) {
@@ -20099,7 +20133,7 @@ var ts;
}
}
function checkImportEqualsDeclaration(node) {
- checkGrammarDecorators(node) || checkGrammarModifiers(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node);
if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
checkImportBinding(node);
if (node.flags & 1 /* Export */) {
@@ -20418,6 +20452,8 @@ var ts;
// Grammar checking
checkGrammarSourceFile(node);
emitExtends = false;
+ emitDecorate = false;
+ emitParam = false;
potentialThisCollisions.length = 0;
ts.forEach(node.statements, checkSourceElement);
checkFunctionExpressionBodies(node);
@@ -21346,6 +21382,137 @@ var ts;
anyArrayType = createArrayType(anyType);
}
// GRAMMAR CHECKING
+ function isReservedwordInStrictMode(node) {
+ // Check that originalKeywordKind is less than LastFurtureReservedWord to see if an Identifier is a strict-mode reserved word
+ return (node.parserContextFlags & 1 /* StrictMode */) &&
+ (node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 111 /* LastFutureReservedWord */);
+ }
+ function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) {
+ // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.)
+ // if so, we would like to give more explicit invalid usage error.
+ if (ts.getAncestor(identifier, 201 /* ClassDeclaration */) || ts.getAncestor(identifier, 174 /* ClassExpression */)) {
+ return grammarErrorOnNode(identifier, message, arg0);
+ }
+ return false;
+ }
+ function checkGrammarImportDeclarationNameInStrictMode(node) {
+ // Check if the import declaration used strict-mode reserved word in its names bindings
+ if (node.importClause) {
+ var impotClause = node.importClause;
+ if (impotClause.namedBindings) {
+ var nameBindings = impotClause.namedBindings;
+ if (nameBindings.kind === 211 /* NamespaceImport */) {
+ var name_11 = nameBindings.name;
+ if (name_11.originalKeywordKind) {
+ var nameText = ts.declarationNameToString(name_11);
+ return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ else if (nameBindings.kind === 212 /* NamedImports */) {
+ var reportError = false;
+ for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) {
+ var element = _a[_i];
+ var name_12 = element.name;
+ if (name_12.originalKeywordKind) {
+ var nameText = ts.declarationNameToString(name_12);
+ reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ return reportError;
+ }
+ }
+ }
+ return false;
+ }
+ function checkGrammarDeclarationNameInStrictMode(node) {
+ var name = node.name;
+ if (name && name.kind === 65 /* Identifier */ && isReservedwordInStrictMode(name)) {
+ var nameText = ts.declarationNameToString(name);
+ switch (node.kind) {
+ case 129 /* Parameter */:
+ case 198 /* VariableDeclaration */:
+ case 200 /* FunctionDeclaration */:
+ case 128 /* TypeParameter */:
+ case 152 /* BindingElement */:
+ case 202 /* InterfaceDeclaration */:
+ case 203 /* TypeAliasDeclaration */:
+ case 204 /* EnumDeclaration */:
+ return checkGrammarIdentifierInStrictMode(name);
+ case 201 /* ClassDeclaration */:
+ // Report an error if the class declaration uses strict-mode reserved word.
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText);
+ case 205 /* ModuleDeclaration */:
+ // Report an error if the module declaration uses strict-mode reserved word.
+ // TODO(yuisu): fix this when having external module in strict mode
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ case 208 /* ImportEqualsDeclaration */:
+ // TODO(yuisu): fix this when having external module in strict mode
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ return false;
+ }
+ function checkGrammarTypeReferenceInStrictMode(typeName) {
+ // Check if the type reference is using strict mode keyword
+ // Example:
+ // class C {
+ // foo(x: public){} // Error.
+ // }
+ if (typeName.kind === 65 /* Identifier */) {
+ checkGrammarTypeNameInStrictMode(typeName);
+ }
+ else if (typeName.kind === 126 /* QualifiedName */) {
+ // Walk from right to left and report a possible error at each Identifier in QualifiedName
+ // Example:
+ // x1: public.private.package // error at public and private
+ checkGrammarTypeNameInStrictMode(typeName.right);
+ checkGrammarTypeReferenceInStrictMode(typeName.left);
+ }
+ }
+ // This function will report an error for every identifier in property access expression
+ // whether it violates strict mode reserved words.
+ // Example:
+ // public // error at public
+ // public.private.package // error at public
+ // B.private.B // no error
+ function checkGrammarHeritageClauseElementInStrictMode(expression) {
+ // Example:
+ // class C extends public // error at public
+ if (expression && expression.kind === 65 /* Identifier */) {
+ return checkGrammarIdentifierInStrictMode(expression);
+ }
+ else if (expression && expression.kind === 155 /* PropertyAccessExpression */) {
+ // Walk from left to right in PropertyAccessExpression until we are at the left most expression
+ // in PropertyAccessExpression. According to grammar production of MemberExpression,
+ // the left component expression is a PrimaryExpression (i.e. Identifier) while the other
+ // component after dots can be IdentifierName.
+ checkGrammarHeritageClauseElementInStrictMode(expression.expression);
+ }
+ }
+ // The function takes an identifier itself or an expression which has SyntaxKind.Identifier.
+ function checkGrammarIdentifierInStrictMode(node, nameText) {
+ if (node && node.kind === 65 /* Identifier */ && isReservedwordInStrictMode(node)) {
+ if (!nameText) {
+ nameText = ts.declarationNameToString(node);
+ }
+ // TODO (yuisu): Fix when module is a strict mode
+ var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) ||
+ grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ return errorReport;
+ }
+ return false;
+ }
+ // The function takes an identifier when uses as a typeName in TypeReferenceNode
+ function checkGrammarTypeNameInStrictMode(node) {
+ if (node && node.kind === 65 /* Identifier */ && isReservedwordInStrictMode(node)) {
+ var nameText = ts.declarationNameToString(node);
+ // TODO (yuisu): Fix when module is a strict mode
+ var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) ||
+ grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ return errorReport;
+ }
+ return false;
+ }
function checkGrammarDecorators(node) {
if (!node.decorators) {
return false;
@@ -21721,11 +21888,11 @@ var ts;
var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var prop = _a[_i];
- var name_11 = prop.name;
+ var name_13 = prop.name;
if (prop.kind === 175 /* OmittedExpression */ ||
- name_11.kind === 127 /* ComputedPropertyName */) {
+ name_13.kind === 127 /* ComputedPropertyName */) {
// If the name is not a ComputedPropertyName, the grammar checking will skip it
- checkGrammarComputedPropertyName(name_11);
+ checkGrammarComputedPropertyName(name_13);
continue;
}
// ECMA-262 11.1.5 Object Initialiser
@@ -21740,8 +21907,8 @@ var ts;
if (prop.kind === 224 /* PropertyAssignment */ || prop.kind === 225 /* ShorthandPropertyAssignment */) {
// Grammar checking for computedPropertName and shorthandPropertyAssignment
checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
- if (name_11.kind === 7 /* NumericLiteral */) {
- checkGrammarNumbericLiteral(name_11);
+ if (name_13.kind === 7 /* NumericLiteral */) {
+ checkGrammarNumbericLiteral(name_13);
}
currentKind = Property;
}
@@ -21757,26 +21924,26 @@ var ts;
else {
ts.Debug.fail("Unexpected syntax kind:" + prop.kind);
}
- if (!ts.hasProperty(seen, name_11.text)) {
- seen[name_11.text] = currentKind;
+ if (!ts.hasProperty(seen, name_13.text)) {
+ seen[name_13.text] = currentKind;
}
else {
- var existingKind = seen[name_11.text];
+ var existingKind = seen[name_13.text];
if (currentKind === Property && existingKind === Property) {
if (inStrictMode) {
- grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
+ grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
}
}
else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) {
if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) {
- seen[name_11.text] = currentKind | existingKind;
+ seen[name_13.text] = currentKind | existingKind;
}
else {
- return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
+ return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
}
}
else {
- return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
+ return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
}
}
}
@@ -22124,15 +22291,14 @@ var ts;
var identifier = name;
if (contextNode && (contextNode.parserContextFlags & 1 /* StrictMode */) && ts.isEvalOrArgumentsIdentifier(identifier)) {
var nameText = ts.declarationNameToString(identifier);
- // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.)
- // if so, we would like to give more explicit invalid usage error.
- // This will be particularly helpful in the case of "arguments" as such case is very common mistake.
- if (ts.getAncestor(name, 201 /* ClassDeclaration */) || ts.getAncestor(name, 174 /* ClassExpression */)) {
- return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
- }
- else {
+ // We check first if the name is inside class declaration or class expression; if so give explicit message
+ // otherwise report generic error message.
+ // reportGrammarErrorInClassDeclaration only return true if grammar error is successfully reported and false otherwise
+ var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
+ if (!reportErrorInClassDeclaration) {
return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText);
}
+ return reportErrorInClassDeclaration;
}
}
}
@@ -22631,9 +22797,9 @@ var ts;
}
var count = 0;
while (true) {
- var name_12 = baseName + "_" + (++count);
- if (!ts.hasProperty(currentSourceFile.identifiers, name_12)) {
- return name_12;
+ var name_14 = baseName + "_" + (++count);
+ if (!ts.hasProperty(currentSourceFile.identifiers, name_14)) {
+ return name_14;
}
}
}
@@ -23835,9 +24001,9 @@ var ts;
tempFlags++;
// Skip over 'i' and 'n'
if (count !== 8 && count !== 13) {
- var name_13 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26);
- if (isUniqueName(name_13)) {
- return name_13;
+ var name_15 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26);
+ if (isUniqueName(name_15)) {
+ return name_15;
}
}
}
@@ -23870,9 +24036,9 @@ var ts;
}
function generateNameForModuleOrEnum(node) {
if (node.name.kind === 65 /* Identifier */) {
- var name_14 = node.name.text;
+ var name_16 = node.name.text;
// Use module/enum name itself if it is unique, otherwise make a unique variation
- assignGeneratedName(node, isUniqueLocalName(name_14, node) ? name_14 : makeUniqueName(name_14));
+ assignGeneratedName(node, isUniqueLocalName(name_16, node) ? name_16 : makeUniqueName(name_16));
}
}
function generateNameForImportOrExportDeclaration(node) {
@@ -24085,8 +24251,8 @@ var ts;
// Child scopes are always shown with a dot (even if they have no name),
// unless it is a computed property. Then it is shown with brackets,
// but the brackets are included in the name.
- var name_15 = node.name;
- if (!name_15 || name_15.kind !== 127 /* ComputedPropertyName */) {
+ var name_17 = node.name;
+ if (!name_17 || name_17.kind !== 127 /* ComputedPropertyName */) {
scopeName = "." + scopeName;
}
scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName;
@@ -24115,10 +24281,10 @@ var ts;
node.kind === 204 /* EnumDeclaration */) {
// Declaration and has associated name use it
if (node.name) {
- var name_16 = node.name;
+ var name_18 = node.name;
// For computed property names, the text will include the brackets
- scopeName = name_16.kind === 127 /* ComputedPropertyName */
- ? ts.getTextOfNode(name_16)
+ scopeName = name_18.kind === 127 /* ComputedPropertyName */
+ ? ts.getTextOfNode(name_18)
: node.name.text;
}
recordScopeNameStart(scopeName);
@@ -24592,6 +24758,7 @@ var ts;
default:
return -1 /* LessThan */;
}
+ case 172 /* YieldExpression */:
case 170 /* ConditionalExpression */:
return -1 /* LessThan */;
default:
@@ -24779,6 +24946,16 @@ var ts;
write("...");
emit(node.expression);
}
+ function emitYieldExpression(node) {
+ write(ts.tokenToString(111 /* YieldKeyword */));
+ if (node.asteriskToken) {
+ write("*");
+ }
+ if (node.expression) {
+ write(" ");
+ emit(node.expression);
+ }
+ }
function needsParenthesisForPropertyAccessOrInvocation(node) {
switch (node.kind) {
case 65 /* Identifier */:
@@ -25037,6 +25214,9 @@ var ts;
write("]");
}
function emitMethod(node) {
+ if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) {
+ write("*");
+ }
emit(node.name, false);
if (languageVersion < 2 /* ES6 */) {
write(": function ");
@@ -26140,12 +26320,12 @@ var ts;
function emitParameter(node) {
if (languageVersion < 2 /* ES6 */) {
if (ts.isBindingPattern(node.name)) {
- var name_17 = createTempVariable(0 /* Auto */);
+ var name_19 = createTempVariable(0 /* Auto */);
if (!tempParameters) {
tempParameters = [];
}
- tempParameters.push(name_17);
- emit(name_17);
+ tempParameters.push(name_19);
+ emit(name_19);
}
else {
emit(node.name);
@@ -26269,7 +26449,11 @@ var ts;
write("default ");
}
}
- write("function ");
+ write("function");
+ if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) {
+ write("*");
+ }
+ write(" ");
}
if (shouldEmitFunctionName(node)) {
emitDeclarationName(node);
@@ -26616,6 +26800,9 @@ var ts;
else if (member.kind === 137 /* SetAccessor */) {
write("set ");
}
+ if (member.asteriskToken) {
+ write("*");
+ }
emit(member.name);
emitSignatureAndBody(member);
emitEnd(member);
@@ -27761,8 +27948,8 @@ var ts;
// export { x, y }
for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) {
var specifier = _d[_c];
- var name_18 = (specifier.propertyName || specifier.name).text;
- (exportSpecifiers[name_18] || (exportSpecifiers[name_18] = [])).push(specifier);
+ var name_20 = (specifier.propertyName || specifier.name).text;
+ (exportSpecifiers[name_20] || (exportSpecifiers[name_20] = [])).push(specifier);
}
}
break;
@@ -28094,6 +28281,8 @@ var ts;
return emitConditionalExpression(node);
case 173 /* SpreadElementExpression */:
return emitSpreadElementExpression(node);
+ case 172 /* YieldExpression */:
+ return emitYieldExpression(node);
case 175 /* OmittedExpression */:
return;
case 179 /* Block */:
@@ -28393,7 +28582,7 @@ var ts;
}
return {
getSourceFile: getSourceFile,
- getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
+ getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), getDefaultLibFileName(options)); },
writeFile: writeFile,
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
@@ -28433,6 +28622,10 @@ var ts;
}
}
ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
+ function getDefaultLibFileName(options) {
+ return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts";
+ }
+ ts.getDefaultLibFileName = getDefaultLibFileName;
function createProgram(rootNames, options, host) {
var program;
var files = [];
@@ -29753,9 +29946,9 @@ var ts;
case 198 /* VariableDeclaration */:
case 152 /* BindingElement */:
var variableDeclarationNode;
- var name_19;
+ var name_21;
if (node.kind === 152 /* BindingElement */) {
- name_19 = node.name;
+ name_21 = node.name;
variableDeclarationNode = node;
// binding elements are added only for variable declarations
// bubble up to the containing variable declaration
@@ -29767,16 +29960,16 @@ var ts;
else {
ts.Debug.assert(!ts.isBindingPattern(node.name));
variableDeclarationNode = node;
- name_19 = node.name;
+ name_21 = node.name;
}
if (ts.isConst(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.constElement);
+ return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.constElement);
}
else if (ts.isLet(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.letElement);
+ return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.letElement);
}
else {
- return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.variableElement);
+ return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.variableElement);
}
case 135 /* Constructor */:
return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement);
@@ -32316,9 +32509,9 @@ var ts;
}
Rules.prototype.getRuleName = function (rule) {
var o = this;
- for (var name_20 in o) {
- if (o[name_20] === rule) {
- return name_20;
+ for (var name_22 in o) {
+ if (o[name_22] === rule) {
+ return name_22;
}
}
throw new Error("Unknown rule");
@@ -36528,10 +36721,10 @@ var ts;
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
var sourceFile = _a[_i];
var nameTable = getNameTable(sourceFile);
- for (var name_21 in nameTable) {
- if (!allNames[name_21]) {
- allNames[name_21] = name_21;
- var displayName = getCompletionEntryDisplayName(name_21, target, true);
+ for (var name_23 in nameTable) {
+ if (!allNames[name_23]) {
+ allNames[name_23] = name_23;
+ var displayName = getCompletionEntryDisplayName(name_23, target, true);
if (displayName) {
var entry = {
name: displayName,
@@ -38363,19 +38556,19 @@ var ts;
if (isNameOfPropertyAssignment(node)) {
var objectLiteral = node.parent.parent;
var contextualType = typeInfoResolver.getContextualType(objectLiteral);
- var name_22 = node.text;
+ var name_24 = node.text;
if (contextualType) {
if (contextualType.flags & 16384 /* Union */) {
// This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types)
// if not, search the constituent types for the property
- var unionProperty = contextualType.getProperty(name_22);
+ var unionProperty = contextualType.getProperty(name_24);
if (unionProperty) {
return [unionProperty];
}
else {
var result_3 = [];
ts.forEach(contextualType.types, function (t) {
- var symbol = t.getProperty(name_22);
+ var symbol = t.getProperty(name_24);
if (symbol) {
result_3.push(symbol);
}
@@ -38384,7 +38577,7 @@ var ts;
}
}
else {
- var symbol_1 = contextualType.getProperty(name_22);
+ var symbol_1 = contextualType.getProperty(name_24);
if (symbol_1) {
return [symbol_1];
}
diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts
index d988810fd3b..9e9df4fdc78 100644
--- a/bin/typescriptServices.d.ts
+++ b/bin/typescriptServices.d.ts
@@ -310,6 +310,7 @@ declare module ts {
}
interface Identifier extends PrimaryExpression {
text: string;
+ originalKeywordKind?: SyntaxKind;
}
interface QualifiedName extends Node {
left: EntityName;
@@ -1181,6 +1182,33 @@ declare module ts {
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
}
+declare module ts {
+ function textSpanEnd(span: TextSpan): number;
+ function textSpanIsEmpty(span: TextSpan): boolean;
+ function textSpanContainsPosition(span: TextSpan, position: number): boolean;
+ function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean;
+ function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean;
+ function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
+ function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
+ function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
+ function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
+ function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
+ function createTextSpan(start: number, length: number): TextSpan;
+ function createTextSpanFromBounds(start: number, end: number): TextSpan;
+ function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
+ function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
+ function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
+ let unchangedTextChangeRange: TextChangeRange;
+ /**
+ * Called to merge all the changes that occurred across several versions of a script snapshot
+ * into a single change. i.e. if a user keeps making successive edits to a script we will
+ * have a text change from V1 to V2, V2 to V3, ..., Vn.
+ *
+ * This function will then merge those changes into a single change range valid between V1 and
+ * Vn.
+ */
+ function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
+}
declare module ts {
function getNodeConstructor(kind: SyntaxKind): new () => Node;
function createNode(kind: SyntaxKind): Node;
@@ -1199,6 +1227,7 @@ declare module ts {
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
+ function getDefaultLibFileName(options: CompilerOptions): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module ts {
diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js
index 1c749f0d94a..4544cc24ec1 100644
--- a/bin/typescriptServices.js
+++ b/bin/typescriptServices.js
@@ -1308,10 +1308,6 @@ var ts;
"\u2029": "\\u2029",
"\u0085": "\\u0085" // nextLine
};
- function getDefaultLibFileName(options) {
- return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts";
- }
- ts.getDefaultLibFileName = getDefaultLibFileName;
function Symbol(flags, name) {
this.flags = flags;
this.name = name;
@@ -1809,6 +1805,12 @@ var ts;
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
+ Identifier_expected_0_is_a_reserved_word_in_strict_mode_External_Module_is_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. External Module is automatically in strict mode." },
+ Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" },
+ Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
+ Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: ts.DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." },
Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@@ -4331,13 +4333,12 @@ var ts;
};
}
ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain;
- /* @internal */
function getSpanOfTokenAtPosition(sourceFile, pos) {
var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.text);
scanner.setTextPos(pos);
scanner.scan();
var start = scanner.getTokenPos();
- return createTextSpanFromBounds(start, scanner.getTextPos());
+ return ts.createTextSpanFromBounds(start, scanner.getTextPos());
}
ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
function getErrorSpanForNode(sourceFile, node) {
@@ -4347,7 +4348,7 @@ var ts;
var pos_1 = ts.skipTrivia(sourceFile.text, 0, false);
if (pos_1 === sourceFile.text.length) {
// file is empty - return span for the beginning of the file
- return createTextSpan(0, 0);
+ return ts.createTextSpan(0, 0);
}
return getSpanOfTokenAtPosition(sourceFile, pos_1);
// This list is a work in progress. Add missing node kinds to improve their error
@@ -4373,7 +4374,7 @@ var ts;
var pos = nodeIsMissing(errorNode)
? errorNode.pos
: ts.skipTrivia(sourceFile.text, errorNode.pos);
- return createTextSpanFromBounds(pos, errorNode.end);
+ return ts.createTextSpanFromBounds(pos, errorNode.end);
}
ts.getErrorSpanForNode = getErrorSpanForNode;
function isExternalModule(file) {
@@ -4482,7 +4483,6 @@ var ts;
}
}
ts.forEachReturnStatement = forEachReturnStatement;
- /* @internal */
function isVariableLike(node) {
if (node) {
switch (node.kind) {
@@ -5170,205 +5170,6 @@ var ts;
return false;
}
ts.isModifier = isModifier;
- function textSpanEnd(span) {
- return span.start + span.length;
- }
- ts.textSpanEnd = textSpanEnd;
- function textSpanIsEmpty(span) {
- return span.length === 0;
- }
- ts.textSpanIsEmpty = textSpanIsEmpty;
- function textSpanContainsPosition(span, position) {
- return position >= span.start && position < textSpanEnd(span);
- }
- ts.textSpanContainsPosition = textSpanContainsPosition;
- // Returns true if 'span' contains 'other'.
- function textSpanContainsTextSpan(span, other) {
- return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
- }
- ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
- function textSpanOverlapsWith(span, other) {
- var overlapStart = Math.max(span.start, other.start);
- var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
- return overlapStart < overlapEnd;
- }
- ts.textSpanOverlapsWith = textSpanOverlapsWith;
- function textSpanOverlap(span1, span2) {
- var overlapStart = Math.max(span1.start, span2.start);
- var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
- if (overlapStart < overlapEnd) {
- return createTextSpanFromBounds(overlapStart, overlapEnd);
- }
- return undefined;
- }
- ts.textSpanOverlap = textSpanOverlap;
- function textSpanIntersectsWithTextSpan(span, other) {
- return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start;
- }
- ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
- function textSpanIntersectsWith(span, start, length) {
- var end = start + length;
- return start <= textSpanEnd(span) && end >= span.start;
- }
- ts.textSpanIntersectsWith = textSpanIntersectsWith;
- function textSpanIntersectsWithPosition(span, position) {
- return position <= textSpanEnd(span) && position >= span.start;
- }
- ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
- function textSpanIntersection(span1, span2) {
- var intersectStart = Math.max(span1.start, span2.start);
- var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
- if (intersectStart <= intersectEnd) {
- return createTextSpanFromBounds(intersectStart, intersectEnd);
- }
- return undefined;
- }
- ts.textSpanIntersection = textSpanIntersection;
- function createTextSpan(start, length) {
- if (start < 0) {
- throw new Error("start < 0");
- }
- if (length < 0) {
- throw new Error("length < 0");
- }
- return { start: start, length: length };
- }
- ts.createTextSpan = createTextSpan;
- function createTextSpanFromBounds(start, end) {
- return createTextSpan(start, end - start);
- }
- ts.createTextSpanFromBounds = createTextSpanFromBounds;
- function textChangeRangeNewSpan(range) {
- return createTextSpan(range.span.start, range.newLength);
- }
- ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
- function textChangeRangeIsUnchanged(range) {
- return textSpanIsEmpty(range.span) && range.newLength === 0;
- }
- ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
- function createTextChangeRange(span, newLength) {
- if (newLength < 0) {
- throw new Error("newLength < 0");
- }
- return { span: span, newLength: newLength };
- }
- ts.createTextChangeRange = createTextChangeRange;
- ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
- /**
- * Called to merge all the changes that occurred across several versions of a script snapshot
- * into a single change. i.e. if a user keeps making successive edits to a script we will
- * have a text change from V1 to V2, V2 to V3, ..., Vn.
- *
- * This function will then merge those changes into a single change range valid between V1 and
- * Vn.
- */
- function collapseTextChangeRangesAcrossMultipleVersions(changes) {
- if (changes.length === 0) {
- return ts.unchangedTextChangeRange;
- }
- if (changes.length === 1) {
- return changes[0];
- }
- // We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd }
- // as it makes things much easier to reason about.
- var change0 = changes[0];
- var oldStartN = change0.span.start;
- var oldEndN = textSpanEnd(change0.span);
- var newEndN = oldStartN + change0.newLength;
- for (var i = 1; i < changes.length; i++) {
- var nextChange = changes[i];
- // Consider the following case:
- // i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting
- // at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }.
- // i.e. the span starting at 30 with length 30 is increased to length 40.
- //
- // 0 10 20 30 40 50 60 70 80 90 100
- // -------------------------------------------------------------------------------------------------------
- // | /
- // | /----
- // T1 | /----
- // | /----
- // | /----
- // -------------------------------------------------------------------------------------------------------
- // | \
- // | \
- // T2 | \
- // | \
- // | \
- // -------------------------------------------------------------------------------------------------------
- //
- // Merging these turns out to not be too difficult. First, determining the new start of the change is trivial
- // it's just the min of the old and new starts. i.e.:
- //
- // 0 10 20 30 40 50 60 70 80 90 100
- // ------------------------------------------------------------*------------------------------------------
- // | /
- // | /----
- // T1 | /----
- // | /----
- // | /----
- // ----------------------------------------$-------------------$------------------------------------------
- // . | \
- // . | \
- // T2 . | \
- // . | \
- // . | \
- // ----------------------------------------------------------------------*--------------------------------
- //
- // (Note the dots represent the newly inferrred start.
- // Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the
- // absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see
- // which if the two $'s precedes the other, and we move that one forward until they line up. in this case that
- // means:
- //
- // 0 10 20 30 40 50 60 70 80 90 100
- // --------------------------------------------------------------------------------*----------------------
- // | /
- // | /----
- // T1 | /----
- // | /----
- // | /----
- // ------------------------------------------------------------$------------------------------------------
- // . | \
- // . | \
- // T2 . | \
- // . | \
- // . | \
- // ----------------------------------------------------------------------*--------------------------------
- //
- // In other words (in this case), we're recognizing that the second edit happened after where the first edit
- // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
- // that's the same as if we started at char 80 instead of 60.
- //
- // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter
- // than pusing the first edit forward to match the second, we'll push the second edit forward to match the
- // first.
- //
- // In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange
- // semantics: { { start: 10, length: 70 }, newLength: 60 }
- //
- // The math then works out as follows.
- // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
- // final result like so:
- //
- // {
- // oldStart3: Min(oldStart1, oldStart2),
- // oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)),
- // newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2))
- // }
- var oldStart1 = oldStartN;
- var oldEnd1 = oldEndN;
- var newEnd1 = newEndN;
- var oldStart2 = nextChange.span.start;
- var oldEnd2 = textSpanEnd(nextChange.span);
- var newEnd2 = oldStart2 + nextChange.newLength;
- oldStartN = Math.min(oldStart1, oldStart2);
- oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
- newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
- }
- return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
- }
- ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
function nodeStartsNewLexicalEnvironment(n) {
return isFunctionLike(n) || n.kind === 205 /* ModuleDeclaration */ || n.kind === 227 /* SourceFile */;
}
@@ -5385,7 +5186,6 @@ var ts;
return node;
}
ts.createSynthesizedNode = createSynthesizedNode;
- /* @internal */
function createDiagnosticCollection() {
var nonFileDiagnostics = [];
var fileDiagnostics = {};
@@ -5807,6 +5607,208 @@ var ts;
}
ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
})(ts || (ts = {}));
+var ts;
+(function (ts) {
+ function textSpanEnd(span) {
+ return span.start + span.length;
+ }
+ ts.textSpanEnd = textSpanEnd;
+ function textSpanIsEmpty(span) {
+ return span.length === 0;
+ }
+ ts.textSpanIsEmpty = textSpanIsEmpty;
+ function textSpanContainsPosition(span, position) {
+ return position >= span.start && position < textSpanEnd(span);
+ }
+ ts.textSpanContainsPosition = textSpanContainsPosition;
+ // Returns true if 'span' contains 'other'.
+ function textSpanContainsTextSpan(span, other) {
+ return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
+ }
+ ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
+ function textSpanOverlapsWith(span, other) {
+ var overlapStart = Math.max(span.start, other.start);
+ var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
+ return overlapStart < overlapEnd;
+ }
+ ts.textSpanOverlapsWith = textSpanOverlapsWith;
+ function textSpanOverlap(span1, span2) {
+ var overlapStart = Math.max(span1.start, span2.start);
+ var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
+ if (overlapStart < overlapEnd) {
+ return createTextSpanFromBounds(overlapStart, overlapEnd);
+ }
+ return undefined;
+ }
+ ts.textSpanOverlap = textSpanOverlap;
+ function textSpanIntersectsWithTextSpan(span, other) {
+ return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start;
+ }
+ ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
+ function textSpanIntersectsWith(span, start, length) {
+ var end = start + length;
+ return start <= textSpanEnd(span) && end >= span.start;
+ }
+ ts.textSpanIntersectsWith = textSpanIntersectsWith;
+ function textSpanIntersectsWithPosition(span, position) {
+ return position <= textSpanEnd(span) && position >= span.start;
+ }
+ ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
+ function textSpanIntersection(span1, span2) {
+ var intersectStart = Math.max(span1.start, span2.start);
+ var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
+ if (intersectStart <= intersectEnd) {
+ return createTextSpanFromBounds(intersectStart, intersectEnd);
+ }
+ return undefined;
+ }
+ ts.textSpanIntersection = textSpanIntersection;
+ function createTextSpan(start, length) {
+ if (start < 0) {
+ throw new Error("start < 0");
+ }
+ if (length < 0) {
+ throw new Error("length < 0");
+ }
+ return { start: start, length: length };
+ }
+ ts.createTextSpan = createTextSpan;
+ function createTextSpanFromBounds(start, end) {
+ return createTextSpan(start, end - start);
+ }
+ ts.createTextSpanFromBounds = createTextSpanFromBounds;
+ function textChangeRangeNewSpan(range) {
+ return createTextSpan(range.span.start, range.newLength);
+ }
+ ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
+ function textChangeRangeIsUnchanged(range) {
+ return textSpanIsEmpty(range.span) && range.newLength === 0;
+ }
+ ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
+ function createTextChangeRange(span, newLength) {
+ if (newLength < 0) {
+ throw new Error("newLength < 0");
+ }
+ return { span: span, newLength: newLength };
+ }
+ ts.createTextChangeRange = createTextChangeRange;
+ ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
+ /**
+ * Called to merge all the changes that occurred across several versions of a script snapshot
+ * into a single change. i.e. if a user keeps making successive edits to a script we will
+ * have a text change from V1 to V2, V2 to V3, ..., Vn.
+ *
+ * This function will then merge those changes into a single change range valid between V1 and
+ * Vn.
+ */
+ function collapseTextChangeRangesAcrossMultipleVersions(changes) {
+ if (changes.length === 0) {
+ return ts.unchangedTextChangeRange;
+ }
+ if (changes.length === 1) {
+ return changes[0];
+ }
+ // We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd }
+ // as it makes things much easier to reason about.
+ var change0 = changes[0];
+ var oldStartN = change0.span.start;
+ var oldEndN = textSpanEnd(change0.span);
+ var newEndN = oldStartN + change0.newLength;
+ for (var i = 1; i < changes.length; i++) {
+ var nextChange = changes[i];
+ // Consider the following case:
+ // i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting
+ // at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }.
+ // i.e. the span starting at 30 with length 30 is increased to length 40.
+ //
+ // 0 10 20 30 40 50 60 70 80 90 100
+ // -------------------------------------------------------------------------------------------------------
+ // | /
+ // | /----
+ // T1 | /----
+ // | /----
+ // | /----
+ // -------------------------------------------------------------------------------------------------------
+ // | \
+ // | \
+ // T2 | \
+ // | \
+ // | \
+ // -------------------------------------------------------------------------------------------------------
+ //
+ // Merging these turns out to not be too difficult. First, determining the new start of the change is trivial
+ // it's just the min of the old and new starts. i.e.:
+ //
+ // 0 10 20 30 40 50 60 70 80 90 100
+ // ------------------------------------------------------------*------------------------------------------
+ // | /
+ // | /----
+ // T1 | /----
+ // | /----
+ // | /----
+ // ----------------------------------------$-------------------$------------------------------------------
+ // . | \
+ // . | \
+ // T2 . | \
+ // . | \
+ // . | \
+ // ----------------------------------------------------------------------*--------------------------------
+ //
+ // (Note the dots represent the newly inferrred start.
+ // Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the
+ // absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see
+ // which if the two $'s precedes the other, and we move that one forward until they line up. in this case that
+ // means:
+ //
+ // 0 10 20 30 40 50 60 70 80 90 100
+ // --------------------------------------------------------------------------------*----------------------
+ // | /
+ // | /----
+ // T1 | /----
+ // | /----
+ // | /----
+ // ------------------------------------------------------------$------------------------------------------
+ // . | \
+ // . | \
+ // T2 . | \
+ // . | \
+ // . | \
+ // ----------------------------------------------------------------------*--------------------------------
+ //
+ // In other words (in this case), we're recognizing that the second edit happened after where the first edit
+ // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
+ // that's the same as if we started at char 80 instead of 60.
+ //
+ // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter
+ // than pusing the first edit forward to match the second, we'll push the second edit forward to match the
+ // first.
+ //
+ // In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange
+ // semantics: { { start: 10, length: 70 }, newLength: 60 }
+ //
+ // The math then works out as follows.
+ // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
+ // final result like so:
+ //
+ // {
+ // oldStart3: Min(oldStart1, oldStart2),
+ // oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)),
+ // newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2))
+ // }
+ var oldStart1 = oldStartN;
+ var oldEnd1 = oldEndN;
+ var newEnd1 = newEndN;
+ var oldStart2 = nextChange.span.start;
+ var oldEnd2 = textSpanEnd(nextChange.span);
+ var newEnd2 = oldStart2 + nextChange.newLength;
+ oldStartN = Math.min(oldStart1, oldStart2);
+ oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
+ newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
+ }
+ return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
+ }
+ ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
+})(ts || (ts = {}));
///
///
var ts;
@@ -6995,6 +6997,7 @@ var ts;
function tryParse(callback) {
return speculationHelper(callback, false);
}
+ // Ignore strict mode flag because we will report an error in type checker instead.
function isIdentifier() {
if (token === 65 /* Identifier */) {
return true;
@@ -7004,7 +7007,7 @@ var ts;
if (token === 111 /* YieldKeyword */ && inYieldContext()) {
return false;
}
- return inStrictModeContext() ? token > 111 /* LastFutureReservedWord */ : token > 101 /* LastReservedWord */;
+ return token > 101 /* LastReservedWord */;
}
function parseExpected(kind, diagnosticMessage) {
if (token === kind) {
@@ -7108,6 +7111,10 @@ var ts;
identifierCount++;
if (isIdentifier) {
var node = createNode(65 /* Identifier */);
+ // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
+ if (token !== 65 /* Identifier */) {
+ node.originalKeywordKind = token;
+ }
node.text = internIdentifier(scanner.getTokenValue());
nextToken();
return finishNode(node);
@@ -9823,6 +9830,17 @@ var ts;
node.body = parseFunctionBlockOrSemicolon(false);
return finishNode(node);
}
+ function isClassMemberModifier(idToken) {
+ switch (idToken) {
+ case 109 /* PublicKeyword */:
+ case 107 /* PrivateKeyword */:
+ case 108 /* ProtectedKeyword */:
+ case 110 /* StaticKeyword */:
+ return true;
+ default:
+ return false;
+ }
+ }
function isClassMemberStart() {
var idToken;
if (token === 52 /* AtToken */) {
@@ -9831,6 +9849,15 @@ var ts;
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier.
while (ts.isModifier(token)) {
idToken = token;
+ // If the idToken is a class modifier (protected, private, public, and static), it is
+ // certain that we are starting to parse class member. This allows better error recovery
+ // Example:
+ // public foo() ... // true
+ // public @dec blah ... // true; we will then report an error later
+ // export public ... // true; we will then report an error later
+ if (isClassMemberModifier(idToken)) {
+ return true;
+ }
nextToken();
}
if (token === 35 /* AsteriskToken */) {
@@ -17230,7 +17257,7 @@ var ts;
function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) {
ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
// Grammar checking
- var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
+ var hasGrammarError = checkGrammarDeclarationNameInStrictMode(node) || checkGrammarFunctionLikeDeclaration(node);
if (!hasGrammarError && node.kind === 162 /* FunctionExpression */) {
checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node);
}
@@ -17272,7 +17299,7 @@ var ts;
}
function checkFunctionExpressionOrObjectLiteralMethodBody(node) {
ts.Debug.assert(node.kind !== 134 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
- if (node.type) {
+ if (node.type && !node.asteriskToken) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type));
}
if (node.body) {
@@ -17834,6 +17861,7 @@ var ts;
return type;
}
function checkExpression(node, contextualMapper) {
+ checkGrammarIdentifierInStrictMode(node);
return checkExpressionOrQualifiedName(node, contextualMapper);
}
// Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When
@@ -17941,6 +17969,7 @@ var ts;
}
// DECLARATION AND STATEMENT TYPE CHECKING
function checkTypeParameter(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
// Grammar Checking
if (node.expression) {
grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
@@ -18172,9 +18201,11 @@ var ts;
checkDecorators(node);
}
function checkTypeReferenceNode(node) {
+ checkGrammarTypeReferenceInStrictMode(node.typeName);
return checkTypeReferenceOrHeritageClauseElement(node);
}
function checkHeritageClauseElement(node) {
+ checkGrammarHeritageClauseElementInStrictMode(node.expression);
return checkTypeReferenceOrHeritageClauseElement(node);
}
function checkTypeReferenceOrHeritageClauseElement(node) {
@@ -18648,6 +18679,7 @@ var ts;
}
}
function checkFunctionLikeDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSignatureDeclaration(node);
// Do not use hasDynamicName here, because that returns false for well known symbols.
@@ -18678,7 +18710,7 @@ var ts;
}
}
checkSourceElement(node.body);
- if (node.type && !isAccessor(node.kind)) {
+ if (node.type && !isAccessor(node.kind) && !node.asteriskToken) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNodeOrHeritageClauseElement(node.type));
}
// Report an implicit any error if there is no body, no explicit return type, and node is not a private method
@@ -18891,6 +18923,7 @@ var ts;
}
// Check variable, parameter, or property declaration
function checkVariableLikeDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
checkDecorators(node);
checkSourceElement(node.type);
// For a computed property, just check the initializer and exit
@@ -19521,6 +19554,7 @@ var ts;
return unknownType;
}
function checkClassDeclaration(node) {
+ checkGrammarDeclarationNameInStrictMode(node);
// Grammar checking
if (node.parent.kind !== 206 /* ModuleBlock */ && node.parent.kind !== 227 /* SourceFile */) {
grammarErrorOnNode(node, ts.Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration);
@@ -19721,7 +19755,7 @@ var ts;
}
function checkInterfaceDeclaration(node) {
// Grammar checking
- checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
checkTypeParameters(node.typeParameters);
if (produceDiagnostics) {
checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
@@ -19921,7 +19955,7 @@ var ts;
return;
}
// Grammar checking
- checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
@@ -19983,7 +20017,7 @@ var ts;
function checkModuleDeclaration(node) {
if (produceDiagnostics) {
// Grammar checking
- if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
+ if (!checkGrammarDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) {
grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
}
@@ -20078,7 +20112,7 @@ var ts;
checkAliasSymbol(node);
}
function checkImportDeclaration(node) {
- if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) {
+ if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) {
grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
}
if (checkExternalImportOrExportDeclaration(node)) {
@@ -20099,7 +20133,7 @@ var ts;
}
}
function checkImportEqualsDeclaration(node) {
- checkGrammarDecorators(node) || checkGrammarModifiers(node);
+ checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node);
if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
checkImportBinding(node);
if (node.flags & 1 /* Export */) {
@@ -20418,6 +20452,8 @@ var ts;
// Grammar checking
checkGrammarSourceFile(node);
emitExtends = false;
+ emitDecorate = false;
+ emitParam = false;
potentialThisCollisions.length = 0;
ts.forEach(node.statements, checkSourceElement);
checkFunctionExpressionBodies(node);
@@ -21346,6 +21382,137 @@ var ts;
anyArrayType = createArrayType(anyType);
}
// GRAMMAR CHECKING
+ function isReservedwordInStrictMode(node) {
+ // Check that originalKeywordKind is less than LastFurtureReservedWord to see if an Identifier is a strict-mode reserved word
+ return (node.parserContextFlags & 1 /* StrictMode */) &&
+ (node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 111 /* LastFutureReservedWord */);
+ }
+ function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) {
+ // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.)
+ // if so, we would like to give more explicit invalid usage error.
+ if (ts.getAncestor(identifier, 201 /* ClassDeclaration */) || ts.getAncestor(identifier, 174 /* ClassExpression */)) {
+ return grammarErrorOnNode(identifier, message, arg0);
+ }
+ return false;
+ }
+ function checkGrammarImportDeclarationNameInStrictMode(node) {
+ // Check if the import declaration used strict-mode reserved word in its names bindings
+ if (node.importClause) {
+ var impotClause = node.importClause;
+ if (impotClause.namedBindings) {
+ var nameBindings = impotClause.namedBindings;
+ if (nameBindings.kind === 211 /* NamespaceImport */) {
+ var name_11 = nameBindings.name;
+ if (name_11.originalKeywordKind) {
+ var nameText = ts.declarationNameToString(name_11);
+ return grammarErrorOnNode(name_11, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ else if (nameBindings.kind === 212 /* NamedImports */) {
+ var reportError = false;
+ for (var _i = 0, _a = nameBindings.elements; _i < _a.length; _i++) {
+ var element = _a[_i];
+ var name_12 = element.name;
+ if (name_12.originalKeywordKind) {
+ var nameText = ts.declarationNameToString(name_12);
+ reportError = reportError || grammarErrorOnNode(name_12, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ return reportError;
+ }
+ }
+ }
+ return false;
+ }
+ function checkGrammarDeclarationNameInStrictMode(node) {
+ var name = node.name;
+ if (name && name.kind === 65 /* Identifier */ && isReservedwordInStrictMode(name)) {
+ var nameText = ts.declarationNameToString(name);
+ switch (node.kind) {
+ case 129 /* Parameter */:
+ case 198 /* VariableDeclaration */:
+ case 200 /* FunctionDeclaration */:
+ case 128 /* TypeParameter */:
+ case 152 /* BindingElement */:
+ case 202 /* InterfaceDeclaration */:
+ case 203 /* TypeAliasDeclaration */:
+ case 204 /* EnumDeclaration */:
+ return checkGrammarIdentifierInStrictMode(name);
+ case 201 /* ClassDeclaration */:
+ // Report an error if the class declaration uses strict-mode reserved word.
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText);
+ case 205 /* ModuleDeclaration */:
+ // Report an error if the module declaration uses strict-mode reserved word.
+ // TODO(yuisu): fix this when having external module in strict mode
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ case 208 /* ImportEqualsDeclaration */:
+ // TODO(yuisu): fix this when having external module in strict mode
+ return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ }
+ }
+ return false;
+ }
+ function checkGrammarTypeReferenceInStrictMode(typeName) {
+ // Check if the type reference is using strict mode keyword
+ // Example:
+ // class C {
+ // foo(x: public){} // Error.
+ // }
+ if (typeName.kind === 65 /* Identifier */) {
+ checkGrammarTypeNameInStrictMode(typeName);
+ }
+ else if (typeName.kind === 126 /* QualifiedName */) {
+ // Walk from right to left and report a possible error at each Identifier in QualifiedName
+ // Example:
+ // x1: public.private.package // error at public and private
+ checkGrammarTypeNameInStrictMode(typeName.right);
+ checkGrammarTypeReferenceInStrictMode(typeName.left);
+ }
+ }
+ // This function will report an error for every identifier in property access expression
+ // whether it violates strict mode reserved words.
+ // Example:
+ // public // error at public
+ // public.private.package // error at public
+ // B.private.B // no error
+ function checkGrammarHeritageClauseElementInStrictMode(expression) {
+ // Example:
+ // class C extends public // error at public
+ if (expression && expression.kind === 65 /* Identifier */) {
+ return checkGrammarIdentifierInStrictMode(expression);
+ }
+ else if (expression && expression.kind === 155 /* PropertyAccessExpression */) {
+ // Walk from left to right in PropertyAccessExpression until we are at the left most expression
+ // in PropertyAccessExpression. According to grammar production of MemberExpression,
+ // the left component expression is a PrimaryExpression (i.e. Identifier) while the other
+ // component after dots can be IdentifierName.
+ checkGrammarHeritageClauseElementInStrictMode(expression.expression);
+ }
+ }
+ // The function takes an identifier itself or an expression which has SyntaxKind.Identifier.
+ function checkGrammarIdentifierInStrictMode(node, nameText) {
+ if (node && node.kind === 65 /* Identifier */ && isReservedwordInStrictMode(node)) {
+ if (!nameText) {
+ nameText = ts.declarationNameToString(node);
+ }
+ // TODO (yuisu): Fix when module is a strict mode
+ var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) ||
+ grammarErrorOnNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ return errorReport;
+ }
+ return false;
+ }
+ // The function takes an identifier when uses as a typeName in TypeReferenceNode
+ function checkGrammarTypeNameInStrictMode(node) {
+ if (node && node.kind === 65 /* Identifier */ && isReservedwordInStrictMode(node)) {
+ var nameText = ts.declarationNameToString(node);
+ // TODO (yuisu): Fix when module is a strict mode
+ var errorReport = reportStrictModeGrammarErrorInClassDeclaration(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode, nameText) ||
+ grammarErrorOnNode(node, ts.Diagnostics.Type_expected_0_is_a_reserved_word_in_strict_mode, nameText);
+ return errorReport;
+ }
+ return false;
+ }
function checkGrammarDecorators(node) {
if (!node.decorators) {
return false;
@@ -21721,11 +21888,11 @@ var ts;
var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var prop = _a[_i];
- var name_11 = prop.name;
+ var name_13 = prop.name;
if (prop.kind === 175 /* OmittedExpression */ ||
- name_11.kind === 127 /* ComputedPropertyName */) {
+ name_13.kind === 127 /* ComputedPropertyName */) {
// If the name is not a ComputedPropertyName, the grammar checking will skip it
- checkGrammarComputedPropertyName(name_11);
+ checkGrammarComputedPropertyName(name_13);
continue;
}
// ECMA-262 11.1.5 Object Initialiser
@@ -21740,8 +21907,8 @@ var ts;
if (prop.kind === 224 /* PropertyAssignment */ || prop.kind === 225 /* ShorthandPropertyAssignment */) {
// Grammar checking for computedPropertName and shorthandPropertyAssignment
checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
- if (name_11.kind === 7 /* NumericLiteral */) {
- checkGrammarNumbericLiteral(name_11);
+ if (name_13.kind === 7 /* NumericLiteral */) {
+ checkGrammarNumbericLiteral(name_13);
}
currentKind = Property;
}
@@ -21757,26 +21924,26 @@ var ts;
else {
ts.Debug.fail("Unexpected syntax kind:" + prop.kind);
}
- if (!ts.hasProperty(seen, name_11.text)) {
- seen[name_11.text] = currentKind;
+ if (!ts.hasProperty(seen, name_13.text)) {
+ seen[name_13.text] = currentKind;
}
else {
- var existingKind = seen[name_11.text];
+ var existingKind = seen[name_13.text];
if (currentKind === Property && existingKind === Property) {
if (inStrictMode) {
- grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
+ grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
}
}
else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) {
if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) {
- seen[name_11.text] = currentKind | existingKind;
+ seen[name_13.text] = currentKind | existingKind;
}
else {
- return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
+ return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
}
}
else {
- return grammarErrorOnNode(name_11, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
+ return grammarErrorOnNode(name_13, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
}
}
}
@@ -22124,15 +22291,14 @@ var ts;
var identifier = name;
if (contextNode && (contextNode.parserContextFlags & 1 /* StrictMode */) && ts.isEvalOrArgumentsIdentifier(identifier)) {
var nameText = ts.declarationNameToString(identifier);
- // We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.)
- // if so, we would like to give more explicit invalid usage error.
- // This will be particularly helpful in the case of "arguments" as such case is very common mistake.
- if (ts.getAncestor(name, 201 /* ClassDeclaration */) || ts.getAncestor(name, 174 /* ClassExpression */)) {
- return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
- }
- else {
+ // We check first if the name is inside class declaration or class expression; if so give explicit message
+ // otherwise report generic error message.
+ // reportGrammarErrorInClassDeclaration only return true if grammar error is successfully reported and false otherwise
+ var reportErrorInClassDeclaration = reportStrictModeGrammarErrorInClassDeclaration(identifier, ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
+ if (!reportErrorInClassDeclaration) {
return grammarErrorOnNode(identifier, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, nameText);
}
+ return reportErrorInClassDeclaration;
}
}
}
@@ -22631,9 +22797,9 @@ var ts;
}
var count = 0;
while (true) {
- var name_12 = baseName + "_" + (++count);
- if (!ts.hasProperty(currentSourceFile.identifiers, name_12)) {
- return name_12;
+ var name_14 = baseName + "_" + (++count);
+ if (!ts.hasProperty(currentSourceFile.identifiers, name_14)) {
+ return name_14;
}
}
}
@@ -23835,9 +24001,9 @@ var ts;
tempFlags++;
// Skip over 'i' and 'n'
if (count !== 8 && count !== 13) {
- var name_13 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26);
- if (isUniqueName(name_13)) {
- return name_13;
+ var name_15 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26);
+ if (isUniqueName(name_15)) {
+ return name_15;
}
}
}
@@ -23870,9 +24036,9 @@ var ts;
}
function generateNameForModuleOrEnum(node) {
if (node.name.kind === 65 /* Identifier */) {
- var name_14 = node.name.text;
+ var name_16 = node.name.text;
// Use module/enum name itself if it is unique, otherwise make a unique variation
- assignGeneratedName(node, isUniqueLocalName(name_14, node) ? name_14 : makeUniqueName(name_14));
+ assignGeneratedName(node, isUniqueLocalName(name_16, node) ? name_16 : makeUniqueName(name_16));
}
}
function generateNameForImportOrExportDeclaration(node) {
@@ -24085,8 +24251,8 @@ var ts;
// Child scopes are always shown with a dot (even if they have no name),
// unless it is a computed property. Then it is shown with brackets,
// but the brackets are included in the name.
- var name_15 = node.name;
- if (!name_15 || name_15.kind !== 127 /* ComputedPropertyName */) {
+ var name_17 = node.name;
+ if (!name_17 || name_17.kind !== 127 /* ComputedPropertyName */) {
scopeName = "." + scopeName;
}
scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName;
@@ -24115,10 +24281,10 @@ var ts;
node.kind === 204 /* EnumDeclaration */) {
// Declaration and has associated name use it
if (node.name) {
- var name_16 = node.name;
+ var name_18 = node.name;
// For computed property names, the text will include the brackets
- scopeName = name_16.kind === 127 /* ComputedPropertyName */
- ? ts.getTextOfNode(name_16)
+ scopeName = name_18.kind === 127 /* ComputedPropertyName */
+ ? ts.getTextOfNode(name_18)
: node.name.text;
}
recordScopeNameStart(scopeName);
@@ -24592,6 +24758,7 @@ var ts;
default:
return -1 /* LessThan */;
}
+ case 172 /* YieldExpression */:
case 170 /* ConditionalExpression */:
return -1 /* LessThan */;
default:
@@ -24779,6 +24946,16 @@ var ts;
write("...");
emit(node.expression);
}
+ function emitYieldExpression(node) {
+ write(ts.tokenToString(111 /* YieldKeyword */));
+ if (node.asteriskToken) {
+ write("*");
+ }
+ if (node.expression) {
+ write(" ");
+ emit(node.expression);
+ }
+ }
function needsParenthesisForPropertyAccessOrInvocation(node) {
switch (node.kind) {
case 65 /* Identifier */:
@@ -25037,6 +25214,9 @@ var ts;
write("]");
}
function emitMethod(node) {
+ if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) {
+ write("*");
+ }
emit(node.name, false);
if (languageVersion < 2 /* ES6 */) {
write(": function ");
@@ -26140,12 +26320,12 @@ var ts;
function emitParameter(node) {
if (languageVersion < 2 /* ES6 */) {
if (ts.isBindingPattern(node.name)) {
- var name_17 = createTempVariable(0 /* Auto */);
+ var name_19 = createTempVariable(0 /* Auto */);
if (!tempParameters) {
tempParameters = [];
}
- tempParameters.push(name_17);
- emit(name_17);
+ tempParameters.push(name_19);
+ emit(name_19);
}
else {
emit(node.name);
@@ -26269,7 +26449,11 @@ var ts;
write("default ");
}
}
- write("function ");
+ write("function");
+ if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) {
+ write("*");
+ }
+ write(" ");
}
if (shouldEmitFunctionName(node)) {
emitDeclarationName(node);
@@ -26616,6 +26800,9 @@ var ts;
else if (member.kind === 137 /* SetAccessor */) {
write("set ");
}
+ if (member.asteriskToken) {
+ write("*");
+ }
emit(member.name);
emitSignatureAndBody(member);
emitEnd(member);
@@ -27761,8 +27948,8 @@ var ts;
// export { x, y }
for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) {
var specifier = _d[_c];
- var name_18 = (specifier.propertyName || specifier.name).text;
- (exportSpecifiers[name_18] || (exportSpecifiers[name_18] = [])).push(specifier);
+ var name_20 = (specifier.propertyName || specifier.name).text;
+ (exportSpecifiers[name_20] || (exportSpecifiers[name_20] = [])).push(specifier);
}
}
break;
@@ -28094,6 +28281,8 @@ var ts;
return emitConditionalExpression(node);
case 173 /* SpreadElementExpression */:
return emitSpreadElementExpression(node);
+ case 172 /* YieldExpression */:
+ return emitYieldExpression(node);
case 175 /* OmittedExpression */:
return;
case 179 /* Block */:
@@ -28393,7 +28582,7 @@ var ts;
}
return {
getSourceFile: getSourceFile,
- getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
+ getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), getDefaultLibFileName(options)); },
writeFile: writeFile,
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
@@ -28433,6 +28622,10 @@ var ts;
}
}
ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
+ function getDefaultLibFileName(options) {
+ return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts";
+ }
+ ts.getDefaultLibFileName = getDefaultLibFileName;
function createProgram(rootNames, options, host) {
var program;
var files = [];
@@ -29753,9 +29946,9 @@ var ts;
case 198 /* VariableDeclaration */:
case 152 /* BindingElement */:
var variableDeclarationNode;
- var name_19;
+ var name_21;
if (node.kind === 152 /* BindingElement */) {
- name_19 = node.name;
+ name_21 = node.name;
variableDeclarationNode = node;
// binding elements are added only for variable declarations
// bubble up to the containing variable declaration
@@ -29767,16 +29960,16 @@ var ts;
else {
ts.Debug.assert(!ts.isBindingPattern(node.name));
variableDeclarationNode = node;
- name_19 = node.name;
+ name_21 = node.name;
}
if (ts.isConst(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.constElement);
+ return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.constElement);
}
else if (ts.isLet(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.letElement);
+ return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.letElement);
}
else {
- return createItem(node, getTextOfNode(name_19), ts.ScriptElementKind.variableElement);
+ return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.variableElement);
}
case 135 /* Constructor */:
return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement);
@@ -32316,9 +32509,9 @@ var ts;
}
Rules.prototype.getRuleName = function (rule) {
var o = this;
- for (var name_20 in o) {
- if (o[name_20] === rule) {
- return name_20;
+ for (var name_22 in o) {
+ if (o[name_22] === rule) {
+ return name_22;
}
}
throw new Error("Unknown rule");
@@ -36528,10 +36721,10 @@ var ts;
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
var sourceFile = _a[_i];
var nameTable = getNameTable(sourceFile);
- for (var name_21 in nameTable) {
- if (!allNames[name_21]) {
- allNames[name_21] = name_21;
- var displayName = getCompletionEntryDisplayName(name_21, target, true);
+ for (var name_23 in nameTable) {
+ if (!allNames[name_23]) {
+ allNames[name_23] = name_23;
+ var displayName = getCompletionEntryDisplayName(name_23, target, true);
if (displayName) {
var entry = {
name: displayName,
@@ -38363,19 +38556,19 @@ var ts;
if (isNameOfPropertyAssignment(node)) {
var objectLiteral = node.parent.parent;
var contextualType = typeInfoResolver.getContextualType(objectLiteral);
- var name_22 = node.text;
+ var name_24 = node.text;
if (contextualType) {
if (contextualType.flags & 16384 /* Union */) {
// This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types)
// if not, search the constituent types for the property
- var unionProperty = contextualType.getProperty(name_22);
+ var unionProperty = contextualType.getProperty(name_24);
if (unionProperty) {
return [unionProperty];
}
else {
var result_3 = [];
ts.forEach(contextualType.types, function (t) {
- var symbol = t.getProperty(name_22);
+ var symbol = t.getProperty(name_24);
if (symbol) {
result_3.push(symbol);
}
@@ -38384,7 +38577,7 @@ var ts;
}
}
else {
- var symbol_1 = contextualType.getProperty(name_22);
+ var symbol_1 = contextualType.getProperty(name_24);
if (symbol_1) {
return [symbol_1];
}