diff --git a/bin/tsc.js b/bin/tsc.js
index 83be107f8d1..b6cb0edc12c 100644
--- a/bin/tsc.js
+++ b/bin/tsc.js
@@ -1445,7 +1445,7 @@ var ts;
(function (ts) {
var textToToken = {
"any": 112,
- "as": 102,
+ "as": 111,
"boolean": 113,
"break": 66,
"case": 67,
@@ -1470,24 +1470,24 @@ var ts;
"function": 83,
"get": 116,
"if": 84,
- "implements": 103,
+ "implements": 102,
"import": 85,
"in": 86,
"instanceof": 87,
- "interface": 104,
- "let": 105,
+ "interface": 103,
+ "let": 104,
"module": 117,
"new": 88,
"null": 89,
"number": 119,
- "package": 106,
- "private": 107,
- "protected": 108,
- "public": 109,
+ "package": 105,
+ "private": 106,
+ "protected": 107,
+ "public": 108,
"require": 118,
"return": 90,
"set": 120,
- "static": 110,
+ "static": 109,
"string": 121,
"super": 91,
"switch": 92,
@@ -1502,7 +1502,7 @@ var ts;
"void": 99,
"while": 100,
"with": 101,
- "yield": 111,
+ "yield": 110,
"of": 125,
"{": 14,
"}": 15,
@@ -4010,7 +4010,7 @@ var ts;
}
ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement;
function getClassImplementsHeritageClauseElements(node) {
- var heritageClause = getHeritageClause(node.heritageClauses, 103);
+ var heritageClause = getHeritageClause(node.heritageClauses, 102);
return heritageClause ? heritageClause.types : undefined;
}
ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements;
@@ -4125,10 +4125,10 @@ var ts;
ts.isESSymbolIdentifier = isESSymbolIdentifier;
function isModifier(token) {
switch (token) {
- case 109:
- case 107:
case 108:
- case 110:
+ case 106:
+ case 107:
+ case 109:
case 78:
case 115:
case 70:
@@ -4536,6 +4536,10 @@ var ts;
})(ts || (ts = {}));
var ts;
(function (ts) {
+ function getDefaultLibFileName(options) {
+ return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts";
+ }
+ ts.getDefaultLibFileName = getDefaultLibFileName;
function textSpanEnd(span) {
return span.start + span.length;
}
@@ -4984,10 +4988,10 @@ var ts;
;
function modifierToFlag(token) {
switch (token) {
- case 110: return 128;
- case 109: return 16;
- case 108: return 64;
- case 107: return 32;
+ case 109: return 128;
+ case 108: return 16;
+ case 107: return 64;
+ case 106: return 32;
case 78: return 1;
case 115: return 2;
case 70: return 8192;
@@ -5494,7 +5498,7 @@ var ts;
if (token === 65) {
return true;
}
- if (token === 111 && inYieldContext()) {
+ if (token === 110 && inYieldContext()) {
return false;
}
return token > 101;
@@ -5730,7 +5734,7 @@ var ts;
ts.Debug.assert(token === 14);
if (nextToken() === 15) {
var next = nextToken();
- return next === 23 || next === 14 || next === 79 || next === 103;
+ return next === 23 || next === 14 || next === 79 || next === 102;
}
return true;
}
@@ -5739,7 +5743,7 @@ var ts;
return isIdentifier();
}
function isHeritageClauseExtendsOrImplementsKeyword() {
- if (token === 103 ||
+ if (token === 102 ||
token === 79) {
return lookAhead(nextTokenIsStartOfExpression);
}
@@ -5767,11 +5771,11 @@ var ts;
case 4:
return token === 15 || token === 67 || token === 73;
case 8:
- return token === 14 || token === 79 || token === 103;
+ return token === 14 || token === 79 || token === 102;
case 9:
return isVariableDeclaratorListTerminator();
case 16:
- return token === 25 || token === 16 || token === 14 || token === 79 || token === 103;
+ return token === 25 || token === 16 || token === 14 || token === 79 || token === 102;
case 12:
return token === 17 || token === 22;
case 14:
@@ -6575,7 +6579,7 @@ var ts;
case 38:
case 39:
case 24:
- case 111:
+ case 110:
return true;
default:
if (isBinaryOperator()) {
@@ -6645,7 +6649,7 @@ var ts;
return parseConditionalExpressionRest(expr);
}
function isYieldExpression() {
- if (token === 111) {
+ if (token === 110) {
if (inYieldContext()) {
return true;
}
@@ -7270,7 +7274,7 @@ var ts;
parseExpected(16);
var initializer = undefined;
if (token !== 22) {
- if (token === 98 || token === 105 || token === 70) {
+ if (token === 98 || token === 104 || token === 70) {
initializer = parseVariableDeclarationList(true);
}
else {
@@ -7431,7 +7435,7 @@ var ts;
return !inErrorRecovery;
case 14:
case 98:
- case 105:
+ case 104:
case 83:
case 69:
case 84:
@@ -7452,17 +7456,17 @@ var ts;
case 70:
var isConstEnum = lookAhead(nextTokenIsEnumKeyword);
return !isConstEnum;
- case 104:
+ case 103:
case 117:
case 77:
case 123:
if (isDeclarationStart()) {
return false;
}
- case 109:
- case 107:
case 108:
- case 110:
+ case 106:
+ case 107:
+ case 109:
if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) {
return false;
}
@@ -7517,7 +7521,7 @@ var ts;
return parseTryStatement();
case 72:
return parseDebuggerStatement();
- case 105:
+ case 104:
if (isLetDeclaration()) {
return parseVariableStatement(scanner.getStartPos(), undefined, undefined);
}
@@ -7542,7 +7546,7 @@ var ts;
return undefined;
}
return parseVariableStatement(start, decorators, modifiers);
- case 105:
+ case 104:
if (!isLetDeclaration()) {
return undefined;
}
@@ -7627,7 +7631,7 @@ var ts;
switch (token) {
case 98:
break;
- case 105:
+ case 104:
node.flags |= 4096;
break;
case 70:
@@ -7726,10 +7730,10 @@ var ts;
}
function isClassMemberModifier(idToken) {
switch (idToken) {
- case 109:
- case 107:
case 108:
- case 110:
+ case 106:
+ case 107:
+ case 109:
return true;
default:
return false;
@@ -7892,7 +7896,7 @@ var ts;
return parseList(19, false, parseHeritageClause);
}
function parseHeritageClause() {
- if (token === 79 || token === 103) {
+ if (token === 79 || token === 102) {
var node = createNode(222);
node.token = token;
nextToken();
@@ -7910,7 +7914,7 @@ var ts;
return finishNode(node);
}
function isHeritageClause() {
- return token === 79 || token === 103;
+ return token === 79 || token === 102;
}
function parseClassMembers() {
return parseList(6, false, parseClassElement);
@@ -7919,7 +7923,7 @@ var ts;
var node = createNode(202, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
- parseExpected(104);
+ parseExpected(103);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
node.heritageClauses = parseHeritageClauses(false);
@@ -8076,7 +8080,7 @@ var ts;
function parseNamespaceImport() {
var namespaceImport = createNode(211);
parseExpected(35);
- parseExpected(102);
+ parseExpected(111);
namespaceImport.name = parseIdentifier();
return finishNode(namespaceImport);
}
@@ -8097,9 +8101,9 @@ var ts;
var checkIdentifierStart = scanner.getTokenPos();
var checkIdentifierEnd = scanner.getTextPos();
var identifierName = parseIdentifierName();
- if (token === 102) {
+ if (token === 111) {
node.propertyName = identifierName;
- parseExpected(102);
+ parseExpected(111);
checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier();
checkIdentifierStart = scanner.getTokenPos();
checkIdentifierEnd = scanner.getTextPos();
@@ -8153,10 +8157,10 @@ var ts;
case 70:
case 83:
return true;
- case 105:
+ case 104:
return isLetDeclaration();
case 69:
- case 104:
+ case 103:
case 77:
case 123:
return lookAhead(nextTokenIsIdentifierOrKeyword);
@@ -8167,10 +8171,10 @@ var ts;
case 78:
return lookAhead(nextTokenCanFollowExportKeyword);
case 115:
- case 109:
- case 107:
case 108:
- case 110:
+ case 106:
+ case 107:
+ case 109:
return lookAhead(nextTokenIsDeclarationStart);
case 52:
return !followsModifier;
@@ -8202,7 +8206,7 @@ var ts;
return isDeclarationStart(true);
}
function nextTokenIsAsKeyword() {
- return nextToken() === 102;
+ return nextToken() === 111;
}
function parseDeclaration() {
var fullStart = getNodePos();
@@ -8219,14 +8223,14 @@ var ts;
}
switch (token) {
case 98:
- case 105:
+ case 104:
case 70:
return parseVariableStatement(fullStart, decorators, modifiers);
case 83:
return parseFunctionDeclaration(fullStart, decorators, modifiers);
case 69:
return parseClassDeclaration(fullStart, decorators, modifiers);
- case 104:
+ case 103:
return parseInterfaceDeclaration(fullStart, decorators, modifiers);
case 123:
return parseTypeAliasDeclaration(fullStart, decorators, modifiers);
@@ -10732,12 +10736,13 @@ var ts;
return result;
}
function getPropertiesOfType(type) {
- if (type.flags & 16384) {
- return getPropertiesOfUnionType(type);
- }
- return getPropertiesOfObjectType(getApparentType(type));
+ type = getApparentType(type);
+ return type.flags & 16384 ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type);
}
function getApparentType(type) {
+ if (type.flags & 16384) {
+ type = getReducedTypeOfUnionType(type);
+ }
if (type.flags & 512) {
do {
type = getConstraintOfTypeParameter(type);
@@ -10806,28 +10811,27 @@ var ts;
return property;
}
function getPropertyOfType(type, name) {
+ type = getApparentType(type);
+ if (type.flags & 48128) {
+ var resolved = resolveObjectOrUnionTypeMembers(type);
+ if (ts.hasProperty(resolved.members, name)) {
+ var symbol = resolved.members[name];
+ if (symbolIsValue(symbol)) {
+ return symbol;
+ }
+ }
+ if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
+ var symbol = getPropertyOfObjectType(globalFunctionType, name);
+ if (symbol) {
+ return symbol;
+ }
+ }
+ return getPropertyOfObjectType(globalObjectType, name);
+ }
if (type.flags & 16384) {
return getPropertyOfUnionType(type, name);
}
- if (!(type.flags & 48128)) {
- type = getApparentType(type);
- if (!(type.flags & 48128)) {
- return undefined;
- }
- }
- var resolved = resolveObjectOrUnionTypeMembers(type);
- if (ts.hasProperty(resolved.members, name)) {
- var symbol = resolved.members[name];
- if (symbolIsValue(symbol)) {
- return symbol;
- }
- }
- if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
- var symbol = getPropertyOfObjectType(globalFunctionType, name);
- if (symbol)
- return symbol;
- }
- return getPropertyOfObjectType(globalObjectType, name);
+ return undefined;
}
function getSignaturesOfObjectOrUnionType(type, kind) {
if (type.flags & (48128 | 16384)) {
@@ -11333,9 +11337,16 @@ var ts;
if (!type) {
type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(sortedTypes));
type.types = sortedTypes;
+ type.reducedType = noSubtypeReduction ? undefined : type;
}
return type;
}
+ function getReducedTypeOfUnionType(type) {
+ if (!type.reducedType) {
+ type.reducedType = getUnionType(type.types, false);
+ }
+ return type.reducedType;
+ }
function getTypeFromUnionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
@@ -15776,7 +15787,10 @@ var ts;
return checkElementTypeOfArrayOrString(inputType, errorNode);
}
if (isArrayLikeType(inputType)) {
- return getIndexTypeOfType(inputType, 1);
+ var indexType = getIndexTypeOfType(inputType, 1);
+ if (indexType) {
+ return indexType;
+ }
}
error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType));
return unknownType;
@@ -17765,7 +17779,7 @@ var ts;
}
function isReservedwordInStrictMode(node) {
return (node.parserContextFlags & 1) &&
- (node.originalKeywordKind >= 103 && node.originalKeywordKind <= 111);
+ (node.originalKeywordKind >= 102 && node.originalKeywordKind <= 110);
}
function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) {
if (ts.getAncestor(identifier, 201) || ts.getAncestor(identifier, 174)) {
@@ -17914,14 +17928,14 @@ var ts;
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
var modifier = _a[_i];
switch (modifier.kind) {
- case 109:
case 108:
case 107:
+ case 106:
var text = void 0;
- if (modifier.kind === 109) {
+ if (modifier.kind === 108) {
text = "public";
}
- else if (modifier.kind === 108) {
+ else if (modifier.kind === 107) {
text = "protected";
lastProtected = modifier;
}
@@ -17940,7 +17954,7 @@ var ts;
}
flags |= ts.modifierToFlag(modifier.kind);
break;
- case 110:
+ case 109:
if (flags & 128) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
}
@@ -18170,7 +18184,7 @@ var ts;
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 103);
+ ts.Debug.assert(heritageClause.token === 102);
if (seenImplementsClause) {
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
}
@@ -18192,7 +18206,7 @@ var ts;
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 103);
+ ts.Debug.assert(heritageClause.token === 102);
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
}
checkGrammarHeritageClause(heritageClause);
@@ -20959,7 +20973,7 @@ var ts;
emit(node.expression);
}
function emitYieldExpression(node) {
- write(ts.tokenToString(111));
+ write(ts.tokenToString(110));
if (node.asteriskToken) {
write("*");
}
@@ -21583,7 +21597,7 @@ var ts;
var tokenKind = 98;
if (decl && languageVersion >= 2) {
if (ts.isLet(decl)) {
- tokenKind = 105;
+ tokenKind = 104;
}
else if (ts.isConst(decl)) {
tokenKind = 70;
@@ -21596,7 +21610,7 @@ var ts;
switch (tokenKind) {
case 98:
return write("var ");
- case 105:
+ case 104:
return write("let ");
case 70:
return write("const ");
@@ -24212,7 +24226,7 @@ var ts;
}
return {
getSourceFile: getSourceFile,
- getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), getDefaultLibFileName(options)); },
+ getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
writeFile: writeFile,
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
@@ -24252,10 +24266,6 @@ 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 e8f4bd1398a..1067c4f3150 100644
--- a/bin/tsserver.js
+++ b/bin/tsserver.js
@@ -1445,7 +1445,7 @@ var ts;
(function (ts) {
var textToToken = {
"any": 112,
- "as": 102,
+ "as": 111,
"boolean": 113,
"break": 66,
"case": 67,
@@ -1470,24 +1470,24 @@ var ts;
"function": 83,
"get": 116,
"if": 84,
- "implements": 103,
+ "implements": 102,
"import": 85,
"in": 86,
"instanceof": 87,
- "interface": 104,
- "let": 105,
+ "interface": 103,
+ "let": 104,
"module": 117,
"new": 88,
"null": 89,
"number": 119,
- "package": 106,
- "private": 107,
- "protected": 108,
- "public": 109,
+ "package": 105,
+ "private": 106,
+ "protected": 107,
+ "public": 108,
"require": 118,
"return": 90,
"set": 120,
- "static": 110,
+ "static": 109,
"string": 121,
"super": 91,
"switch": 92,
@@ -1502,7 +1502,7 @@ var ts;
"void": 99,
"while": 100,
"with": 101,
- "yield": 111,
+ "yield": 110,
"of": 125,
"{": 14,
"}": 15,
@@ -3844,7 +3844,7 @@ var ts;
}
ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement;
function getClassImplementsHeritageClauseElements(node) {
- var heritageClause = getHeritageClause(node.heritageClauses, 103);
+ var heritageClause = getHeritageClause(node.heritageClauses, 102);
return heritageClause ? heritageClause.types : undefined;
}
ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements;
@@ -3959,10 +3959,10 @@ var ts;
ts.isESSymbolIdentifier = isESSymbolIdentifier;
function isModifier(token) {
switch (token) {
- case 109:
- case 107:
case 108:
- case 110:
+ case 106:
+ case 107:
+ case 109:
case 78:
case 115:
case 70:
@@ -4370,6 +4370,10 @@ var ts;
})(ts || (ts = {}));
var ts;
(function (ts) {
+ function getDefaultLibFileName(options) {
+ return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts";
+ }
+ ts.getDefaultLibFileName = getDefaultLibFileName;
function textSpanEnd(span) {
return span.start + span.length;
}
@@ -4818,10 +4822,10 @@ var ts;
;
function modifierToFlag(token) {
switch (token) {
- case 110: return 128;
- case 109: return 16;
- case 108: return 64;
- case 107: return 32;
+ case 109: return 128;
+ case 108: return 16;
+ case 107: return 64;
+ case 106: return 32;
case 78: return 1;
case 115: return 2;
case 70: return 8192;
@@ -5328,7 +5332,7 @@ var ts;
if (token === 65) {
return true;
}
- if (token === 111 && inYieldContext()) {
+ if (token === 110 && inYieldContext()) {
return false;
}
return token > 101;
@@ -5564,7 +5568,7 @@ var ts;
ts.Debug.assert(token === 14);
if (nextToken() === 15) {
var next = nextToken();
- return next === 23 || next === 14 || next === 79 || next === 103;
+ return next === 23 || next === 14 || next === 79 || next === 102;
}
return true;
}
@@ -5573,7 +5577,7 @@ var ts;
return isIdentifier();
}
function isHeritageClauseExtendsOrImplementsKeyword() {
- if (token === 103 ||
+ if (token === 102 ||
token === 79) {
return lookAhead(nextTokenIsStartOfExpression);
}
@@ -5601,11 +5605,11 @@ var ts;
case 4:
return token === 15 || token === 67 || token === 73;
case 8:
- return token === 14 || token === 79 || token === 103;
+ return token === 14 || token === 79 || token === 102;
case 9:
return isVariableDeclaratorListTerminator();
case 16:
- return token === 25 || token === 16 || token === 14 || token === 79 || token === 103;
+ return token === 25 || token === 16 || token === 14 || token === 79 || token === 102;
case 12:
return token === 17 || token === 22;
case 14:
@@ -6409,7 +6413,7 @@ var ts;
case 38:
case 39:
case 24:
- case 111:
+ case 110:
return true;
default:
if (isBinaryOperator()) {
@@ -6479,7 +6483,7 @@ var ts;
return parseConditionalExpressionRest(expr);
}
function isYieldExpression() {
- if (token === 111) {
+ if (token === 110) {
if (inYieldContext()) {
return true;
}
@@ -7104,7 +7108,7 @@ var ts;
parseExpected(16);
var initializer = undefined;
if (token !== 22) {
- if (token === 98 || token === 105 || token === 70) {
+ if (token === 98 || token === 104 || token === 70) {
initializer = parseVariableDeclarationList(true);
}
else {
@@ -7265,7 +7269,7 @@ var ts;
return !inErrorRecovery;
case 14:
case 98:
- case 105:
+ case 104:
case 83:
case 69:
case 84:
@@ -7286,17 +7290,17 @@ var ts;
case 70:
var isConstEnum = lookAhead(nextTokenIsEnumKeyword);
return !isConstEnum;
- case 104:
+ case 103:
case 117:
case 77:
case 123:
if (isDeclarationStart()) {
return false;
}
- case 109:
- case 107:
case 108:
- case 110:
+ case 106:
+ case 107:
+ case 109:
if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) {
return false;
}
@@ -7351,7 +7355,7 @@ var ts;
return parseTryStatement();
case 72:
return parseDebuggerStatement();
- case 105:
+ case 104:
if (isLetDeclaration()) {
return parseVariableStatement(scanner.getStartPos(), undefined, undefined);
}
@@ -7376,7 +7380,7 @@ var ts;
return undefined;
}
return parseVariableStatement(start, decorators, modifiers);
- case 105:
+ case 104:
if (!isLetDeclaration()) {
return undefined;
}
@@ -7461,7 +7465,7 @@ var ts;
switch (token) {
case 98:
break;
- case 105:
+ case 104:
node.flags |= 4096;
break;
case 70:
@@ -7560,10 +7564,10 @@ var ts;
}
function isClassMemberModifier(idToken) {
switch (idToken) {
- case 109:
- case 107:
case 108:
- case 110:
+ case 106:
+ case 107:
+ case 109:
return true;
default:
return false;
@@ -7726,7 +7730,7 @@ var ts;
return parseList(19, false, parseHeritageClause);
}
function parseHeritageClause() {
- if (token === 79 || token === 103) {
+ if (token === 79 || token === 102) {
var node = createNode(222);
node.token = token;
nextToken();
@@ -7744,7 +7748,7 @@ var ts;
return finishNode(node);
}
function isHeritageClause() {
- return token === 79 || token === 103;
+ return token === 79 || token === 102;
}
function parseClassMembers() {
return parseList(6, false, parseClassElement);
@@ -7753,7 +7757,7 @@ var ts;
var node = createNode(202, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
- parseExpected(104);
+ parseExpected(103);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
node.heritageClauses = parseHeritageClauses(false);
@@ -7910,7 +7914,7 @@ var ts;
function parseNamespaceImport() {
var namespaceImport = createNode(211);
parseExpected(35);
- parseExpected(102);
+ parseExpected(111);
namespaceImport.name = parseIdentifier();
return finishNode(namespaceImport);
}
@@ -7931,9 +7935,9 @@ var ts;
var checkIdentifierStart = scanner.getTokenPos();
var checkIdentifierEnd = scanner.getTextPos();
var identifierName = parseIdentifierName();
- if (token === 102) {
+ if (token === 111) {
node.propertyName = identifierName;
- parseExpected(102);
+ parseExpected(111);
checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier();
checkIdentifierStart = scanner.getTokenPos();
checkIdentifierEnd = scanner.getTextPos();
@@ -7987,10 +7991,10 @@ var ts;
case 70:
case 83:
return true;
- case 105:
+ case 104:
return isLetDeclaration();
case 69:
- case 104:
+ case 103:
case 77:
case 123:
return lookAhead(nextTokenIsIdentifierOrKeyword);
@@ -8001,10 +8005,10 @@ var ts;
case 78:
return lookAhead(nextTokenCanFollowExportKeyword);
case 115:
- case 109:
- case 107:
case 108:
- case 110:
+ case 106:
+ case 107:
+ case 109:
return lookAhead(nextTokenIsDeclarationStart);
case 52:
return !followsModifier;
@@ -8036,7 +8040,7 @@ var ts;
return isDeclarationStart(true);
}
function nextTokenIsAsKeyword() {
- return nextToken() === 102;
+ return nextToken() === 111;
}
function parseDeclaration() {
var fullStart = getNodePos();
@@ -8053,14 +8057,14 @@ var ts;
}
switch (token) {
case 98:
- case 105:
+ case 104:
case 70:
return parseVariableStatement(fullStart, decorators, modifiers);
case 83:
return parseFunctionDeclaration(fullStart, decorators, modifiers);
case 69:
return parseClassDeclaration(fullStart, decorators, modifiers);
- case 104:
+ case 103:
return parseInterfaceDeclaration(fullStart, decorators, modifiers);
case 123:
return parseTypeAliasDeclaration(fullStart, decorators, modifiers);
@@ -11075,12 +11079,13 @@ var ts;
return result;
}
function getPropertiesOfType(type) {
- if (type.flags & 16384) {
- return getPropertiesOfUnionType(type);
- }
- return getPropertiesOfObjectType(getApparentType(type));
+ type = getApparentType(type);
+ return type.flags & 16384 ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type);
}
function getApparentType(type) {
+ if (type.flags & 16384) {
+ type = getReducedTypeOfUnionType(type);
+ }
if (type.flags & 512) {
do {
type = getConstraintOfTypeParameter(type);
@@ -11149,28 +11154,27 @@ var ts;
return property;
}
function getPropertyOfType(type, name) {
+ type = getApparentType(type);
+ if (type.flags & 48128) {
+ var resolved = resolveObjectOrUnionTypeMembers(type);
+ if (ts.hasProperty(resolved.members, name)) {
+ var symbol = resolved.members[name];
+ if (symbolIsValue(symbol)) {
+ return symbol;
+ }
+ }
+ if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
+ var symbol = getPropertyOfObjectType(globalFunctionType, name);
+ if (symbol) {
+ return symbol;
+ }
+ }
+ return getPropertyOfObjectType(globalObjectType, name);
+ }
if (type.flags & 16384) {
return getPropertyOfUnionType(type, name);
}
- if (!(type.flags & 48128)) {
- type = getApparentType(type);
- if (!(type.flags & 48128)) {
- return undefined;
- }
- }
- var resolved = resolveObjectOrUnionTypeMembers(type);
- if (ts.hasProperty(resolved.members, name)) {
- var symbol = resolved.members[name];
- if (symbolIsValue(symbol)) {
- return symbol;
- }
- }
- if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
- var symbol = getPropertyOfObjectType(globalFunctionType, name);
- if (symbol)
- return symbol;
- }
- return getPropertyOfObjectType(globalObjectType, name);
+ return undefined;
}
function getSignaturesOfObjectOrUnionType(type, kind) {
if (type.flags & (48128 | 16384)) {
@@ -11676,9 +11680,16 @@ var ts;
if (!type) {
type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(sortedTypes));
type.types = sortedTypes;
+ type.reducedType = noSubtypeReduction ? undefined : type;
}
return type;
}
+ function getReducedTypeOfUnionType(type) {
+ if (!type.reducedType) {
+ type.reducedType = getUnionType(type.types, false);
+ }
+ return type.reducedType;
+ }
function getTypeFromUnionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
@@ -16119,7 +16130,10 @@ var ts;
return checkElementTypeOfArrayOrString(inputType, errorNode);
}
if (isArrayLikeType(inputType)) {
- return getIndexTypeOfType(inputType, 1);
+ var indexType = getIndexTypeOfType(inputType, 1);
+ if (indexType) {
+ return indexType;
+ }
}
error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType));
return unknownType;
@@ -18108,7 +18122,7 @@ var ts;
}
function isReservedwordInStrictMode(node) {
return (node.parserContextFlags & 1) &&
- (node.originalKeywordKind >= 103 && node.originalKeywordKind <= 111);
+ (node.originalKeywordKind >= 102 && node.originalKeywordKind <= 110);
}
function reportStrictModeGrammarErrorInClassDeclaration(identifier, message, arg0, arg1, arg2) {
if (ts.getAncestor(identifier, 201) || ts.getAncestor(identifier, 174)) {
@@ -18257,14 +18271,14 @@ var ts;
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
var modifier = _a[_i];
switch (modifier.kind) {
- case 109:
case 108:
case 107:
+ case 106:
var text = void 0;
- if (modifier.kind === 109) {
+ if (modifier.kind === 108) {
text = "public";
}
- else if (modifier.kind === 108) {
+ else if (modifier.kind === 107) {
text = "protected";
lastProtected = modifier;
}
@@ -18283,7 +18297,7 @@ var ts;
}
flags |= ts.modifierToFlag(modifier.kind);
break;
- case 110:
+ case 109:
if (flags & 128) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
}
@@ -18513,7 +18527,7 @@ var ts;
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 103);
+ ts.Debug.assert(heritageClause.token === 102);
if (seenImplementsClause) {
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
}
@@ -18535,7 +18549,7 @@ var ts;
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 103);
+ ts.Debug.assert(heritageClause.token === 102);
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
}
checkGrammarHeritageClause(heritageClause);
@@ -21302,7 +21316,7 @@ var ts;
emit(node.expression);
}
function emitYieldExpression(node) {
- write(ts.tokenToString(111));
+ write(ts.tokenToString(110));
if (node.asteriskToken) {
write("*");
}
@@ -21926,7 +21940,7 @@ var ts;
var tokenKind = 98;
if (decl && languageVersion >= 2) {
if (ts.isLet(decl)) {
- tokenKind = 105;
+ tokenKind = 104;
}
else if (ts.isConst(decl)) {
tokenKind = 70;
@@ -21939,7 +21953,7 @@ var ts;
switch (tokenKind) {
case 98:
return write("var ");
- case 105:
+ case 104:
return write("let ");
case 70:
return write("const ");
@@ -24555,7 +24569,7 @@ var ts;
}
return {
getSourceFile: getSourceFile,
- getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), getDefaultLibFileName(options)); },
+ getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
writeFile: writeFile,
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
@@ -24595,10 +24609,6 @@ 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 = [];
@@ -25464,28 +25474,30 @@ var ts;
var rawItems = [];
ts.forEach(program.getSourceFiles(), function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
- var declarations = sourceFile.getNamedDeclarations();
- for (var _i = 0; _i < declarations.length; _i++) {
- var declaration = declarations[_i];
- var name = getDeclarationName(declaration);
- if (name !== undefined) {
- var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name);
+ var nameToDeclarations = sourceFile.getNamedDeclarations();
+ for (var name_21 in nameToDeclarations) {
+ var declarations = ts.getProperty(nameToDeclarations, name_21);
+ if (declarations) {
+ var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_21);
if (!matches) {
continue;
}
- if (patternMatcher.patternContainsDots) {
- var containers = getContainers(declaration);
- if (!containers) {
- return undefined;
- }
- matches = patternMatcher.getMatches(containers, name);
- if (!matches) {
- continue;
+ for (var _i = 0; _i < declarations.length; _i++) {
+ var declaration = declarations[_i];
+ if (patternMatcher.patternContainsDots) {
+ var containers = getContainers(declaration);
+ if (!containers) {
+ return undefined;
+ }
+ matches = patternMatcher.getMatches(containers, name_21);
+ if (!matches) {
+ continue;
+ }
}
+ var fileName = sourceFile.fileName;
+ var matchKind = bestMatchKind(matches);
+ rawItems.push({ name: name_21, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration });
}
- var fileName = sourceFile.fileName;
- var matchKind = bestMatchKind(matches);
- rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration });
}
}
});
@@ -25505,25 +25517,13 @@ var ts;
}
return true;
}
- function getDeclarationName(declaration) {
- var result = getTextOfIdentifierOrLiteral(declaration.name);
- if (result !== undefined) {
- return result;
- }
- if (declaration.name.kind === 127) {
- var expr = declaration.name.expression;
- if (expr.kind === 155) {
- return expr.name.text;
- }
- return getTextOfIdentifierOrLiteral(expr);
- }
- return undefined;
- }
function getTextOfIdentifierOrLiteral(node) {
- if (node.kind === 65 ||
- node.kind === 8 ||
- node.kind === 7) {
- return node.text;
+ if (node) {
+ if (node.kind === 65 ||
+ node.kind === 8 ||
+ node.kind === 7) {
+ return node.text;
+ }
}
return undefined;
}
@@ -25826,9 +25826,9 @@ var ts;
case 198:
case 152:
var variableDeclarationNode;
- var name_21;
+ var name_22;
if (node.kind === 152) {
- name_21 = node.name;
+ name_22 = node.name;
variableDeclarationNode = node;
while (variableDeclarationNode && variableDeclarationNode.kind !== 198) {
variableDeclarationNode = variableDeclarationNode.parent;
@@ -25838,16 +25838,16 @@ var ts;
else {
ts.Debug.assert(!ts.isBindingPattern(node.name));
variableDeclarationNode = node;
- name_21 = node.name;
+ name_22 = node.name;
}
if (ts.isConst(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.constElement);
+ return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.constElement);
}
else if (ts.isLet(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.letElement);
+ return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.letElement);
}
else {
- return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.variableElement);
+ return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.variableElement);
}
case 135:
return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement);
@@ -26439,7 +26439,8 @@ var ts;
var SignatureHelp;
(function (SignatureHelp) {
var emptyArray = [];
- function getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken) {
+ function getSignatureHelpItems(program, sourceFile, position, cancellationToken) {
+ var typeChecker = program.getTypeChecker();
var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position);
if (!startingToken) {
return undefined;
@@ -26451,12 +26452,51 @@ var ts;
}
var call = argumentInfo.invocation;
var candidates = [];
- var resolvedSignature = typeInfoResolver.getResolvedSignature(call, candidates);
+ var resolvedSignature = typeChecker.getResolvedSignature(call, candidates);
cancellationToken.throwIfCancellationRequested();
if (!candidates.length) {
+ if (ts.isJavaScript(sourceFile.fileName)) {
+ return createJavaScriptSignatureHelpItems(argumentInfo);
+ }
return undefined;
}
return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo);
+ function createJavaScriptSignatureHelpItems(argumentInfo) {
+ if (argumentInfo.invocation.kind !== 157) {
+ return undefined;
+ }
+ var callExpression = argumentInfo.invocation;
+ var expression = callExpression.expression;
+ var name = expression.kind === 65
+ ? expression
+ : expression.kind === 155
+ ? expression.name
+ : undefined;
+ if (!name || !name.text) {
+ return undefined;
+ }
+ var typeChecker = program.getTypeChecker();
+ for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
+ var sourceFile_1 = _a[_i];
+ var nameToDeclarations = sourceFile_1.getNamedDeclarations();
+ var declarations = ts.getProperty(nameToDeclarations, name.text);
+ if (declarations) {
+ for (var _b = 0; _b < declarations.length; _b++) {
+ var declaration = declarations[_b];
+ var symbol = declaration.symbol;
+ if (symbol) {
+ var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
+ if (type) {
+ var callSignatures = type.getCallSignatures();
+ if (callSignatures && callSignatures.length) {
+ return createSignatureHelpItems(callSignatures, callSignatures[0], argumentInfo);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
function getImmediatelyContainingArgumentInfo(node) {
if (node.parent.kind === 157 || node.parent.kind === 158) {
var callExpression = node.parent;
@@ -26618,8 +26658,8 @@ var ts;
var isTypeParameterList = argumentListInfo.kind === 0;
var invocation = argumentListInfo.invocation;
var callTarget = ts.getInvokedExpression(invocation);
- var callTargetSymbol = typeInfoResolver.getSymbolAtLocation(callTarget);
- var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeInfoResolver, callTargetSymbol, undefined, undefined);
+ var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget);
+ var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined);
var items = ts.map(candidates, function (candidateSignature) {
var signatureHelpParameters;
var prefixDisplayParts = [];
@@ -26633,13 +26673,13 @@ var ts;
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
suffixDisplayParts.push(ts.punctuationPart(25));
var parameterParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation);
});
suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts);
}
else {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation);
});
prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts);
prefixDisplayParts.push(ts.punctuationPart(16));
@@ -26648,7 +26688,7 @@ var ts;
suffixDisplayParts.push(ts.punctuationPart(17));
}
var returnTypeParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation);
});
suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts);
return {
@@ -26676,7 +26716,7 @@ var ts;
};
function createSignatureHelpParameterForParameter(parameter) {
var displayParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation);
});
var isOptional = ts.hasQuestionToken(parameter.valueDeclaration);
return {
@@ -26688,7 +26728,7 @@ var ts;
}
function createSignatureHelpParameterForTypeParameter(typeParameter) {
var displayParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation);
});
return {
name: typeParameter.symbol.name,
@@ -27074,9 +27114,9 @@ var ts;
ts.isInsideTemplateLiteral = isInsideTemplateLiteral;
function isAccessibilityModifier(kind) {
switch (kind) {
- case 109:
- case 107:
case 108:
+ case 106:
+ case 107:
return true;
}
return false;
@@ -27266,6 +27306,10 @@ var ts;
});
}
ts.signatureToDisplayParts = signatureToDisplayParts;
+ function isJavaScript(fileName) {
+ return ts.fileExtensionIs(fileName, ".js");
+ }
+ ts.isJavaScript = isJavaScript;
})(ts || (ts = {}));
///
///
@@ -27694,7 +27738,7 @@ var ts;
this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(34, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2));
this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([98, 94, 88, 74, 90, 97]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105, 70]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2));
+ this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104, 70]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2));
this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8));
this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(83, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2));
this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8));
@@ -27707,8 +27751,8 @@ var ts;
this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2));
this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117, 118]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 103, 85, 104, 117, 107, 109, 120, 110]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79, 103])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
+ this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 102, 85, 103, 117, 106, 108, 120, 109]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
+ this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79, 102])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2));
this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(32, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
@@ -27721,7 +27765,7 @@ var ts;
this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8));
this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65, 78, 73, 69, 110, 109, 107, 108, 116, 120, 18, 35])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2));
+ this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65, 78, 73, 69, 109, 108, 106, 107, 116, 120, 18, 35])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2));
this.HighPriorityCommonRules =
[
this.IgnoreBeforeComment, this.IgnoreAfterLineComment,
@@ -27795,9 +27839,9 @@ var ts;
}
Rules.prototype.getRuleName = function (rule) {
var o = this;
- for (var name_22 in o) {
- if (o[name_22] === rule) {
- return name_22;
+ for (var name_23 in o) {
+ if (o[name_23] === rule) {
+ return name_23;
}
}
throw new Error("Unknown rule");
@@ -28609,7 +28653,7 @@ var ts;
}
switch (node.kind) {
case 201: return 69;
- case 202: return 104;
+ case 202: return 103;
case 200: return 83;
case 204: return 204;
case 136: return 116;
@@ -29928,26 +29972,62 @@ var ts;
return this.namedDeclarations;
};
SourceFileObject.prototype.computeNamedDeclarations = function () {
- var namedDeclarations = [];
+ var result = {};
ts.forEachChild(this, visit);
- return namedDeclarations;
+ return result;
+ function addDeclaration(declaration) {
+ var name = getDeclarationName(declaration);
+ if (name) {
+ var declarations = getDeclarations(name);
+ declarations.push(declaration);
+ }
+ }
+ function getDeclarations(name) {
+ return ts.getProperty(result, name) || (result[name] = []);
+ }
+ function getDeclarationName(declaration) {
+ if (declaration.name) {
+ var result_2 = getTextOfIdentifierOrLiteral(declaration.name);
+ if (result_2 !== undefined) {
+ return result_2;
+ }
+ if (declaration.name.kind === 127) {
+ var expr = declaration.name.expression;
+ if (expr.kind === 155) {
+ return expr.name.text;
+ }
+ return getTextOfIdentifierOrLiteral(expr);
+ }
+ }
+ return undefined;
+ }
+ function getTextOfIdentifierOrLiteral(node) {
+ if (node) {
+ if (node.kind === 65 ||
+ node.kind === 8 ||
+ node.kind === 7) {
+ return node.text;
+ }
+ }
+ return undefined;
+ }
function visit(node) {
switch (node.kind) {
case 200:
case 134:
case 133:
var functionDeclaration = node;
- if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) {
- var lastDeclaration = namedDeclarations.length > 0 ?
- namedDeclarations[namedDeclarations.length - 1] :
- undefined;
- if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) {
+ var declarationName = getDeclarationName(functionDeclaration);
+ if (declarationName) {
+ var declarations = getDeclarations(declarationName);
+ var lastDeclaration = ts.lastOrUndefined(declarations);
+ if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) {
if (functionDeclaration.body && !lastDeclaration.body) {
- namedDeclarations[namedDeclarations.length - 1] = functionDeclaration;
+ declarations[declarations.length - 1] = functionDeclaration;
}
}
else {
- namedDeclarations.push(functionDeclaration);
+ declarations.push(functionDeclaration);
}
ts.forEachChild(node, visit);
}
@@ -29966,9 +30046,7 @@ var ts;
case 136:
case 137:
case 145:
- if (node.name) {
- namedDeclarations.push(node);
- }
+ addDeclaration(node);
case 135:
case 180:
case 199:
@@ -29995,7 +30073,7 @@ var ts;
case 226:
case 132:
case 131:
- namedDeclarations.push(node);
+ addDeclaration(node);
break;
case 215:
if (node.exportClause) {
@@ -30006,11 +30084,11 @@ var ts;
var importClause = node.importClause;
if (importClause) {
if (importClause.name) {
- namedDeclarations.push(importClause);
+ addDeclaration(importClause);
}
if (importClause.namedBindings) {
if (importClause.namedBindings.kind === 211) {
- namedDeclarations.push(importClause.namedBindings);
+ addDeclaration(importClause.namedBindings);
}
else {
ts.forEach(importClause.namedBindings.elements, visit);
@@ -30496,7 +30574,7 @@ var ts;
}
else if (token === 35) {
token = scanner.scan();
- if (token === 102) {
+ if (token === 111) {
token = scanner.scan();
if (token === 65) {
token = scanner.scan();
@@ -30734,7 +30812,6 @@ var ts;
var syntaxTreeCache = new SyntaxTreeCache(host);
var ruleProvider;
var program;
- var typeInfoResolver;
var useCaseSensitivefileNames = false;
var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) {
@@ -30792,7 +30869,7 @@ var ts;
}
}
program = newProgram;
- typeInfoResolver = program.getTypeChecker();
+ program.getTypeChecker();
return;
function getOrCreateSourceFile(fileName) {
var hostFileInformation = hostCache.getOrCreateEntry(fileName);
@@ -30832,9 +30909,6 @@ var ts;
return program;
}
function cleanupSemanticCache() {
- if (program) {
- typeInfoResolver = program.getTypeChecker();
- }
}
function dispose() {
if (program) {
@@ -30847,13 +30921,10 @@ var ts;
synchronizeHostData();
return program.getSyntacticDiagnostics(getValidSourceFile(fileName));
}
- function isJavaScript(fileName) {
- return ts.fileExtensionIs(fileName, ".js");
- }
function getSemanticDiagnostics(fileName) {
synchronizeHostData();
var targetSourceFile = getValidSourceFile(fileName);
- if (isJavaScript(fileName)) {
+ if (ts.isJavaScript(fileName)) {
return getJavaScriptSemanticDiagnostics(targetSourceFile);
}
var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile);
@@ -30887,7 +30958,7 @@ var ts;
break;
case 222:
var heritageClause = node;
- if (heritageClause.token === 103) {
+ if (heritageClause.token === 102) {
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file));
return true;
}
@@ -30990,13 +31061,13 @@ var ts;
for (var _i = 0; _i < modifiers.length; _i++) {
var modifier = modifiers[_i];
switch (modifier.kind) {
- case 109:
- case 107:
case 108:
+ case 106:
+ case 107:
case 115:
diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind)));
return true;
- case 110:
+ case 109:
case 78:
case 70:
case 73:
@@ -31051,19 +31122,8 @@ var ts;
}
return ts.unescapeIdentifier(displayName);
}
- function createCompletionEntry(symbol, typeChecker, location) {
- var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true);
- if (!displayName) {
- return undefined;
- }
- return {
- name: displayName,
- kind: getSymbolKind(symbol, typeChecker, location),
- kindModifiers: getSymbolModifiers(symbol),
- sortText: "0"
- };
- }
function getCompletionData(fileName, position) {
+ var typeChecker = program.getTypeChecker();
var syntacticStart = new Date().getTime();
var sourceFile = getValidSourceFile(fileName);
var start = new Date().getTime();
@@ -31119,23 +31179,23 @@ var ts;
isMemberCompletion = true;
isNewIdentifierLocation = false;
if (node.kind === 65 || node.kind === 126 || node.kind === 155) {
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
if (symbol && symbol.flags & 8388608) {
- symbol = typeInfoResolver.getAliasedSymbol(symbol);
+ symbol = typeChecker.getAliasedSymbol(symbol);
}
if (symbol && symbol.flags & 1952) {
- var exportedSymbols = typeInfoResolver.getExportsOfModule(symbol);
+ var exportedSymbols = typeChecker.getExportsOfModule(symbol);
ts.forEach(exportedSymbols, function (symbol) {
- if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) {
+ if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) {
symbols.push(symbol);
}
});
}
}
- var type = typeInfoResolver.getTypeAtLocation(node);
+ var type = typeChecker.getTypeAtLocation(node);
if (type) {
ts.forEach(type.getApparentProperties(), function (symbol) {
- if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) {
+ if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) {
symbols.push(symbol);
}
});
@@ -31146,11 +31206,11 @@ var ts;
if (containingObjectLiteral) {
isMemberCompletion = true;
isNewIdentifierLocation = true;
- var contextualType = typeInfoResolver.getContextualType(containingObjectLiteral);
+ var contextualType = typeChecker.getContextualType(containingObjectLiteral);
if (!contextualType) {
return false;
}
- var contextualTypeMembers = typeInfoResolver.getPropertiesOfType(contextualType);
+ var contextualTypeMembers = typeChecker.getPropertiesOfType(contextualType);
if (contextualTypeMembers && contextualTypeMembers.length > 0) {
symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties);
}
@@ -31163,9 +31223,9 @@ var ts;
ts.Debug.assert(importDeclaration !== undefined);
var exports_2;
if (importDeclaration.moduleSpecifier) {
- var moduleSpecifierSymbol = typeInfoResolver.getSymbolAtLocation(importDeclaration.moduleSpecifier);
+ var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier);
if (moduleSpecifierSymbol) {
- exports_2 = typeInfoResolver.getExportsOfModule(moduleSpecifierSymbol);
+ exports_2 = typeChecker.getExportsOfModule(moduleSpecifierSymbol);
}
}
symbols = exports_2 ? filterModuleExports(exports_2, importDeclaration) : emptyArray;
@@ -31182,7 +31242,7 @@ var ts;
position;
var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
var symbolMeanings = 793056 | 107455 | 1536 | 8388608;
- symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings);
+ symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings);
}
return true;
}
@@ -31239,9 +31299,9 @@ var ts;
return containingNodeKind === 171;
case 12:
return containingNodeKind === 176;
- case 109:
- case 107:
case 108:
+ case 106:
+ case 107:
return containingNodeKind === 132;
}
switch (previousToken.getText()) {
@@ -31328,6 +31388,7 @@ var ts;
containingNodeKind === 150;
case 22:
return containingNodeKind === 131 &&
+ previousToken.parent && previousToken.parent.parent &&
(previousToken.parent.parent.kind === 202 ||
previousToken.parent.parent.kind === 145);
case 24:
@@ -31335,27 +31396,28 @@ var ts;
containingNodeKind === 200 ||
containingNodeKind === 202 ||
isFunction(containingNodeKind);
- case 110:
+ case 109:
return containingNodeKind === 132;
case 21:
return containingNodeKind === 129 ||
containingNodeKind === 135 ||
- (previousToken.parent.parent.kind === 151);
- case 109:
- case 107:
+ (previousToken.parent && previousToken.parent.parent &&
+ previousToken.parent.parent.kind === 151);
case 108:
+ case 106:
+ case 107:
return containingNodeKind === 129;
case 69:
case 77:
- case 104:
+ case 103:
case 83:
case 98:
case 116:
case 120:
case 85:
- case 105:
+ case 104:
case 70:
- case 111:
+ case 110:
return true;
}
switch (previousToken.getText()) {
@@ -31428,7 +31490,7 @@ var ts;
}
var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot;
var entries;
- if (isRightOfDot && isJavaScript(fileName)) {
+ if (isRightOfDot && ts.isJavaScript(fileName)) {
entries = getCompletionEntriesFromSymbols(symbols);
ts.addRange(entries, getJavaScriptCompletionEntries());
}
@@ -31449,10 +31511,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_23 in nameTable) {
- if (!allNames[name_23]) {
- allNames[name_23] = name_23;
- var displayName = getCompletionEntryDisplayName(name_23, target, true);
+ for (var name_24 in nameTable) {
+ if (!allNames[name_24]) {
+ allNames[name_24] = name_24;
+ var displayName = getCompletionEntryDisplayName(name_24, target, true);
if (displayName) {
var entry = {
name: displayName,
@@ -31467,6 +31529,18 @@ var ts;
}
return entries;
}
+ function createCompletionEntry(symbol, location) {
+ var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true);
+ if (!displayName) {
+ return undefined;
+ }
+ return {
+ name: displayName,
+ kind: getSymbolKind(symbol, location),
+ kindModifiers: getSymbolModifiers(symbol),
+ sortText: "0"
+ };
+ }
function getCompletionEntriesFromSymbols(symbols) {
var start = new Date().getTime();
var entries = [];
@@ -31474,7 +31548,7 @@ var ts;
var nameToSymbol = {};
for (var _i = 0; _i < symbols.length; _i++) {
var symbol = symbols[_i];
- var entry = createCompletionEntry(symbol, typeInfoResolver, location);
+ var entry = createCompletionEntry(symbol, location);
if (entry) {
var id = ts.escapeIdentifier(entry.name);
if (!ts.lookUp(nameToSymbol, id)) {
@@ -31496,7 +31570,7 @@ var ts;
var target = program.getCompilerOptions().target;
var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false) === entryName ? s : undefined; });
if (symbol) {
- var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, typeInfoResolver, location_2, 7);
+ var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7);
return {
name: entryName,
kind: displayPartsDocumentationsAndSymbolKind.symbolKind,
@@ -31518,7 +31592,7 @@ var ts;
}
return undefined;
}
- function getSymbolKind(symbol, typeResolver, location) {
+ function getSymbolKind(symbol, location) {
var flags = symbol.getFlags();
if (flags & 32)
return ScriptElementKind.classElement;
@@ -31530,7 +31604,7 @@ var ts;
return ScriptElementKind.interfaceElement;
if (flags & 262144)
return ScriptElementKind.typeParameterElement;
- var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver, location);
+ var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location);
if (result === ScriptElementKind.unknown) {
if (flags & 262144)
return ScriptElementKind.typeParameterElement;
@@ -31543,11 +31617,12 @@ var ts;
}
return result;
}
- function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver, location) {
- if (typeResolver.isUndefinedSymbol(symbol)) {
+ function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location) {
+ var typeChecker = program.getTypeChecker();
+ if (typeChecker.isUndefinedSymbol(symbol)) {
return ScriptElementKind.variableElement;
}
- if (typeResolver.isArgumentsSymbol(symbol)) {
+ if (typeChecker.isArgumentsSymbol(symbol)) {
return ScriptElementKind.localVariableElement;
}
if (flags & 3) {
@@ -31574,7 +31649,7 @@ var ts;
return ScriptElementKind.constructorImplementationElement;
if (flags & 4) {
if (flags & 268435456) {
- var unionPropertyKind = ts.forEach(typeInfoResolver.getRootSymbols(symbol), function (rootSymbol) {
+ var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) {
var rootSymbolFlags = rootSymbol.getFlags();
if (rootSymbolFlags & (98308 | 3)) {
return ScriptElementKind.memberVariableElement;
@@ -31582,7 +31657,7 @@ var ts;
ts.Debug.assert(!!(rootSymbolFlags & 8192));
});
if (!unionPropertyKind) {
- var typeOfUnionProperty = typeInfoResolver.getTypeOfSymbolAtLocation(symbol, location);
+ var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (typeOfUnionProperty.getCallSignatures().length) {
return ScriptElementKind.memberFunctionElement;
}
@@ -31615,12 +31690,13 @@ var ts;
? ts.getNodeModifiers(symbol.declarations[0])
: ScriptElementKindModifier.none;
}
- function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, typeResolver, location, semanticMeaning) {
+ function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) {
if (semanticMeaning === void 0) { semanticMeaning = getMeaningFromLocation(location); }
+ var typeChecker = program.getTypeChecker();
var displayParts = [];
var documentation;
var symbolFlags = symbol.flags;
- var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver, location);
+ var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location);
var hasAddedSymbolInfo;
var type;
if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) {
@@ -31628,7 +31704,7 @@ var ts;
symbolKind = ScriptElementKind.memberVariableElement;
}
var signature;
- type = typeResolver.getTypeOfSymbolAtLocation(symbol, location);
+ type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (type) {
if (location.parent && location.parent.kind === 155) {
var right = location.parent.name;
@@ -31645,7 +31721,7 @@ var ts;
}
if (callExpression) {
var candidateSignatures = [];
- signature = typeResolver.getResolvedSignature(callExpression, candidateSignatures);
+ signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures);
if (!signature && candidateSignatures.length) {
signature = candidateSignatures[0];
}
@@ -31686,7 +31762,7 @@ var ts;
displayParts.push(ts.spacePart());
}
if (!(type.flags & 32768)) {
- displayParts.push.apply(displayParts, ts.symbolToDisplayParts(typeResolver, type.symbol, enclosingDeclaration, undefined, 1));
+ displayParts.push.apply(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1));
}
addSignatureDisplayParts(signature, allSignatures, 8);
break;
@@ -31700,8 +31776,8 @@ var ts;
(location.kind === 114 && location.parent.kind === 135)) {
var functionDeclaration = location.parent;
var allSignatures = functionDeclaration.kind === 135 ? type.getConstructSignatures() : type.getCallSignatures();
- if (!typeResolver.isImplementationOfOverload(functionDeclaration)) {
- signature = typeResolver.getSignatureFromDeclaration(functionDeclaration);
+ if (!typeChecker.isImplementationOfOverload(functionDeclaration)) {
+ signature = typeChecker.getSignatureFromDeclaration(functionDeclaration);
}
else {
signature = allSignatures[0];
@@ -31727,7 +31803,7 @@ var ts;
}
if ((symbolFlags & 64) && (semanticMeaning & 2)) {
addNewLineIfDisplayPartsExist();
- displayParts.push(ts.keywordPart(104));
+ displayParts.push(ts.keywordPart(103));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
@@ -31740,7 +31816,7 @@ var ts;
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(53));
displayParts.push(ts.spacePart());
- displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
+ displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
}
if (symbolFlags & 384) {
addNewLineIfDisplayPartsExist();
@@ -31774,7 +31850,7 @@ var ts;
}
else {
var signatureDeclaration = ts.getDeclarationOfKind(symbol, 128).parent;
- var signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration);
+ var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
if (signatureDeclaration.kind === 139) {
displayParts.push(ts.keywordPart(88));
displayParts.push(ts.spacePart());
@@ -31782,14 +31858,14 @@ var ts;
else if (signatureDeclaration.kind !== 138 && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
- displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, sourceFile, 32));
+ displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32));
}
}
if (symbolFlags & 8) {
addPrefixForAnyFunctionOrVar(symbol, "enum member");
var declaration = symbol.declarations[0];
if (declaration.kind === 226) {
- var constantValue = typeResolver.getConstantValue(declaration);
+ var constantValue = typeChecker.getConstantValue(declaration);
if (constantValue !== undefined) {
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(53));
@@ -31816,7 +31892,7 @@ var ts;
displayParts.push(ts.punctuationPart(17));
}
else {
- var internalAliasSymbol = typeResolver.getSymbolAtLocation(importEqualsDeclaration.moduleReference);
+ var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference);
if (internalAliasSymbol) {
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(53));
@@ -31839,12 +31915,12 @@ var ts;
displayParts.push(ts.spacePart());
if (type.symbol && type.symbol.flags & 262144) {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
- typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration);
+ typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration);
});
displayParts.push.apply(displayParts, typeParameterParts);
}
else {
- displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, type, enclosingDeclaration));
+ displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration));
}
}
else if (symbolFlags & 16 ||
@@ -31859,7 +31935,7 @@ var ts;
}
}
else {
- symbolKind = getSymbolKind(symbol, typeResolver, location);
+ symbolKind = getSymbolKind(symbol, location);
}
}
if (!documentation) {
@@ -31872,7 +31948,7 @@ var ts;
}
}
function addFullSymbolName(symbol, enclosingDeclaration) {
- var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeResolver, symbol, enclosingDeclaration || sourceFile, undefined, 1 | 2);
+ var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 | 2);
displayParts.push.apply(displayParts, fullSymbolDisplayParts);
}
function addPrefixForAnyFunctionOrVar(symbol, symbolKind) {
@@ -31900,7 +31976,7 @@ var ts;
}
}
function addSignatureDisplayParts(signature, allSignatures, flags) {
- displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32));
+ displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32));
if (allSignatures.length > 1) {
displayParts.push(ts.spacePart());
displayParts.push(ts.punctuationPart(16));
@@ -31914,7 +31990,7 @@ var ts;
}
function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
- typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration);
+ typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration);
});
displayParts.push.apply(displayParts, typeParameterParts);
}
@@ -31926,7 +32002,11 @@ var ts;
if (!node) {
return undefined;
}
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ if (isLabelName(node)) {
+ return undefined;
+ }
+ var typeChecker = program.getTypeChecker();
+ var symbol = typeChecker.getSymbolAtLocation(node);
if (!symbol) {
switch (node.kind) {
case 65:
@@ -31934,20 +32014,20 @@ var ts;
case 126:
case 93:
case 91:
- var type = typeInfoResolver.getTypeAtLocation(node);
+ var type = typeChecker.getTypeAtLocation(node);
if (type) {
return {
kind: ScriptElementKind.unknown,
kindModifiers: ScriptElementKindModifier.none,
textSpan: ts.createTextSpan(node.getStart(), node.getWidth()),
- displayParts: ts.typeToDisplayParts(typeInfoResolver, type, getContainerNode(node)),
+ displayParts: ts.typeToDisplayParts(typeChecker, type, getContainerNode(node)),
documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined
};
}
}
return undefined;
}
- var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), typeInfoResolver, node);
+ var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), node);
return {
kind: displayPartsDocumentationsAndKind.symbolKind,
kindModifiers: getSymbolModifiers(symbol),
@@ -31993,33 +32073,34 @@ var ts;
}
return undefined;
}
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var typeChecker = program.getTypeChecker();
+ var symbol = typeChecker.getSymbolAtLocation(node);
if (!symbol) {
return undefined;
}
if (symbol.flags & 8388608) {
var declaration = symbol.declarations[0];
if (node.kind === 65 && node.parent === declaration) {
- symbol = typeInfoResolver.getAliasedSymbol(symbol);
+ symbol = typeChecker.getAliasedSymbol(symbol);
}
}
if (node.parent.kind === 225) {
- var shorthandSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
+ var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
if (!shorthandSymbol) {
return [];
}
var shorthandDeclarations = shorthandSymbol.getDeclarations();
- var shorthandSymbolKind = getSymbolKind(shorthandSymbol, typeInfoResolver, node);
- var shorthandSymbolName = typeInfoResolver.symbolToString(shorthandSymbol);
- var shorthandContainerName = typeInfoResolver.symbolToString(symbol.parent, node);
+ var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node);
+ var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol);
+ var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node);
return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); });
}
var result = [];
var declarations = symbol.getDeclarations();
- var symbolName = typeInfoResolver.symbolToString(symbol);
- var symbolKind = getSymbolKind(symbol, typeInfoResolver, node);
+ var symbolName = typeChecker.symbolToString(symbol);
+ var symbolKind = getSymbolKind(symbol, node);
var containerSymbol = symbol.parent;
- var containerName = containerSymbol ? typeInfoResolver.symbolToString(containerSymbol, node) : "";
+ var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
ts.forEach(declarations, function (declaration) {
@@ -32069,7 +32150,7 @@ var ts;
var results = getOccurrencesAtPositionCore(fileName, position);
if (results) {
var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName));
- results = ts.filter(results, function (r) { return r.fileName === fileName; });
+ results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; });
}
return results;
}
@@ -32314,7 +32395,7 @@ var ts;
return undefined;
}
}
- else if (modifier === 110) {
+ else if (modifier === 109) {
if (container.kind !== 201) {
return undefined;
}
@@ -32360,13 +32441,13 @@ var ts;
return ts.map(keywords, getHighlightSpanForNode);
function getFlagFromModifier(modifier) {
switch (modifier) {
- case 109:
- return 16;
- case 107:
- return 32;
case 108:
+ return 16;
+ case 106:
+ return 32;
+ case 107:
return 64;
- case 110:
+ case 109:
return 128;
case 78:
return 1;
@@ -32609,6 +32690,7 @@ var ts;
return getReferencedSymbolsForNodes(node, program.getSourceFiles(), findInStrings, findInComments);
}
function getReferencedSymbolsForNodes(node, sourceFiles, findInStrings, findInComments) {
+ var typeChecker = program.getTypeChecker();
if (isLabelName(node)) {
if (isJumpStatementTarget(node)) {
var labelDefinition = getTargetLabel(node.parent, node.text);
@@ -32624,7 +32706,7 @@ var ts;
if (node.kind === 91) {
return getReferencesForSuperKeyword(node);
}
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
if (!symbol) {
return undefined;
}
@@ -32655,7 +32737,7 @@ var ts;
}
return result;
function getDefinition(symbol) {
- var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), typeInfoResolver, node);
+ var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node);
var name = ts.map(info.displayParts, function (p) { return p.text; }).join("");
var declarations = symbol.declarations;
if (!declarations || declarations.length === 0) {
@@ -32689,7 +32771,7 @@ var ts;
if (isImportOrExportSpecifierName(location)) {
return location.getText();
}
- name = typeInfoResolver.symbolToString(symbol);
+ name = typeChecker.symbolToString(symbol);
return stripQuotes(name);
}
function getInternedName(symbol, location, declarations) {
@@ -32837,10 +32919,10 @@ var ts;
if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) {
return;
}
- var referenceSymbol = typeInfoResolver.getSymbolAtLocation(referenceLocation);
+ var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation);
if (referenceSymbol) {
var referenceSymbolDeclaration = referenceSymbol.valueDeclaration;
- var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
+ var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation);
if (relatedSymbol) {
var referencedSymbol = getReferencedSymbol(relatedSymbol);
@@ -33013,18 +33095,18 @@ var ts;
function populateSearchSymbolSet(symbol, location) {
var result = [symbol];
if (isImportOrExportSpecifierImportSymbol(symbol)) {
- result.push(typeInfoResolver.getAliasedSymbol(symbol));
+ result.push(typeChecker.getAliasedSymbol(symbol));
}
if (isNameOfPropertyAssignment(location)) {
ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) {
- result.push.apply(result, typeInfoResolver.getRootSymbols(contextualSymbol));
+ result.push.apply(result, typeChecker.getRootSymbols(contextualSymbol));
});
- var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(location.parent);
+ var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent);
if (shorthandValueSymbol) {
result.push(shorthandValueSymbol);
}
}
- ts.forEach(typeInfoResolver.getRootSymbols(symbol), function (rootSymbol) {
+ ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) {
if (rootSymbol !== symbol) {
result.push(rootSymbol);
}
@@ -33049,9 +33131,9 @@ var ts;
return;
function getPropertySymbolFromTypeReference(typeReference) {
if (typeReference) {
- var type = typeInfoResolver.getTypeAtLocation(typeReference);
+ var type = typeChecker.getTypeAtLocation(typeReference);
if (type) {
- var propertySymbol = typeInfoResolver.getPropertyOfType(type, propertyName);
+ var propertySymbol = typeChecker.getPropertyOfType(type, propertyName);
if (propertySymbol) {
result.push(propertySymbol);
}
@@ -33065,24 +33147,24 @@ var ts;
return referenceSymbol;
}
if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) {
- var aliasedSymbol = typeInfoResolver.getAliasedSymbol(referenceSymbol);
+ var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol);
if (searchSymbols.indexOf(aliasedSymbol) >= 0) {
return aliasedSymbol;
}
}
if (isNameOfPropertyAssignment(referenceLocation)) {
return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) {
- return ts.forEach(typeInfoResolver.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
+ return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
});
}
- return ts.forEach(typeInfoResolver.getRootSymbols(referenceSymbol), function (rootSymbol) {
+ return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) {
if (searchSymbols.indexOf(rootSymbol) >= 0) {
return rootSymbol;
}
if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) {
- var result_2 = [];
- getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_2);
- return ts.forEach(result_2, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
+ var result_3 = [];
+ getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3);
+ return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
}
return undefined;
});
@@ -33090,27 +33172,27 @@ var ts;
function getPropertySymbolsFromContextualType(node) {
if (isNameOfPropertyAssignment(node)) {
var objectLiteral = node.parent.parent;
- var contextualType = typeInfoResolver.getContextualType(objectLiteral);
- var name_24 = node.text;
+ var contextualType = typeChecker.getContextualType(objectLiteral);
+ var name_25 = node.text;
if (contextualType) {
if (contextualType.flags & 16384) {
- var unionProperty = contextualType.getProperty(name_24);
+ var unionProperty = contextualType.getProperty(name_25);
if (unionProperty) {
return [unionProperty];
}
else {
- var result_3 = [];
+ var result_4 = [];
ts.forEach(contextualType.types, function (t) {
- var symbol = t.getProperty(name_24);
+ var symbol = t.getProperty(name_25);
if (symbol) {
- result_3.push(symbol);
+ result_4.push(symbol);
}
});
- return result_3;
+ return result_4;
}
}
else {
- var symbol_1 = contextualType.getProperty(name_24);
+ var symbol_1 = contextualType.getProperty(name_25);
if (symbol_1) {
return [symbol_1];
}
@@ -33260,7 +33342,7 @@ var ts;
}
if (!isLastClause && root.parent.kind === 177 && root.parent.parent.kind === 222) {
var decl = root.parent.parent.parent;
- return (decl.kind === 201 && root.parent.parent.token === 103) ||
+ return (decl.kind === 201 && root.parent.parent.token === 102) ||
(decl.kind === 202 && root.parent.parent.token === 79);
}
return false;
@@ -33314,7 +33396,7 @@ var ts;
function getSignatureHelpItems(fileName, position) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
- return ts.SignatureHelp.getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken);
+ return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken);
}
function getSourceFile(fileName) {
return syntaxTreeCache.getCurrentSourceFile(fileName);
@@ -33370,6 +33452,7 @@ var ts;
function getSemanticClassifications(fileName, span) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
+ var typeChecker = program.getTypeChecker();
var result = [];
processNode(sourceFile);
return result;
@@ -33408,7 +33491,7 @@ var ts;
function processNode(node) {
if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) {
if (node.kind === 65 && node.getWidth() > 0) {
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
if (symbol) {
var type = classifySymbol(symbol, getMeaningFromLocation(node));
if (type) {
@@ -33732,9 +33815,10 @@ var ts;
function getRenameInfo(fileName, position) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
+ var typeChecker = program.getTypeChecker();
var node = ts.getTouchingWord(sourceFile, position);
if (node && node.kind === 65) {
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
if (symbol) {
var declarations = symbol.getDeclarations();
if (declarations && declarations.length > 0) {
@@ -33742,19 +33826,19 @@ var ts;
if (defaultLibFileName) {
for (var _i = 0; _i < declarations.length; _i++) {
var current = declarations[_i];
- var sourceFile_1 = current.getSourceFile();
- if (sourceFile_1 && getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) {
+ var sourceFile_2 = current.getSourceFile();
+ if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) {
return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key));
}
}
}
- var kind = getSymbolKind(symbol, typeInfoResolver, node);
+ var kind = getSymbolKind(symbol, node);
if (kind) {
return {
canRename: true,
localizedErrorMessage: undefined,
displayName: symbol.name,
- fullDisplayName: typeInfoResolver.getFullyQualifiedName(symbol),
+ fullDisplayName: typeChecker.getFullyQualifiedName(symbol),
kind: kind,
kindModifiers: getSymbolModifiers(symbol),
triggerSpan: ts.createTextSpan(node.getStart(), node.getWidth())
@@ -33868,7 +33952,7 @@ var ts;
if (keyword2 === 116 ||
keyword2 === 120 ||
keyword2 === 114 ||
- keyword2 === 110) {
+ keyword2 === 109) {
return true;
}
return false;
@@ -34386,8 +34470,7 @@ var ts;
this.errorTimer = setTimeout(checkOne, ms);
}
};
- Session.prototype.getDefinition = function (_a) {
- var line = _a.line, offset = _a.offset, fileName = _a.file;
+ Session.prototype.getDefinition = function (line, offset, fileName) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -34405,8 +34488,7 @@ var ts;
end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan))
}); });
};
- Session.prototype.getOccurrences = function (_a) {
- var line = _a.line, offset = _a.offset, fileName = _a.file;
+ Session.prototype.getOccurrences = function (line, offset, fileName) {
fileName = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(fileName);
if (!project) {
@@ -34430,8 +34512,7 @@ var ts;
};
});
};
- Session.prototype.getRenameLocations = function (_a) {
- var line = _a.line, offset = _a.offset, fileName = _a.file, findInComments = _a.findInComments, findInStrings = _a.findInStrings;
+ Session.prototype.getRenameLocations = function (line, offset, fileName, findInComments, findInStrings) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -34492,8 +34573,7 @@ var ts;
}, []);
return { info: renameInfo, locs: bakedRenameLocs };
};
- Session.prototype.getReferences = function (_a) {
- var line = _a.line, offset = _a.offset, fileName = _a.file;
+ Session.prototype.getReferences = function (line, offset, fileName) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -34533,13 +34613,11 @@ var ts;
symbolDisplayString: displayString
};
};
- Session.prototype.openClientFile = function (_a) {
- var fileName = _a.file;
+ Session.prototype.openClientFile = function (fileName) {
var file = ts.normalizePath(fileName);
this.projectService.openClientFile(file);
};
- Session.prototype.getQuickInfo = function (_a) {
- var line = _a.line, offset = _a.offset, fileName = _a.file;
+ Session.prototype.getQuickInfo = function (line, offset, fileName) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -34562,8 +34640,7 @@ var ts;
documentation: docString
};
};
- Session.prototype.getFormattingEditsForRange = function (_a) {
- var line = _a.line, offset = _a.offset, endLine = _a.endLine, endOffset = _a.endOffset, fileName = _a.file;
+ Session.prototype.getFormattingEditsForRange = function (line, offset, endLine, endOffset, fileName) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -34584,8 +34661,7 @@ var ts;
};
});
};
- Session.prototype.getFormattingEditsAfterKeystroke = function (_a) {
- var line = _a.line, offset = _a.offset, key = _a.key, fileName = _a.file;
+ Session.prototype.getFormattingEditsAfterKeystroke = function (line, offset, key, fileName) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -34642,8 +34718,7 @@ var ts;
};
});
};
- Session.prototype.getCompletions = function (_a) {
- var line = _a.line, offset = _a.offset, prefix = _a.prefix, fileName = _a.file;
+ Session.prototype.getCompletions = function (line, offset, prefix, fileName) {
if (!prefix) {
prefix = "";
}
@@ -34665,8 +34740,7 @@ var ts;
return result;
}, []).sort(function (a, b) { return a.name.localeCompare(b.name); });
};
- Session.prototype.getCompletionEntryDetails = function (_a) {
- var line = _a.line, offset = _a.offset, entryNames = _a.entryNames, fileName = _a.file;
+ Session.prototype.getCompletionEntryDetails = function (line, offset, entryNames, fileName) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -34682,8 +34756,7 @@ var ts;
return accum;
}, []);
};
- Session.prototype.getSignatureHelpItems = function (_a) {
- var line = _a.line, offset = _a.offset, fileName = _a.file;
+ Session.prototype.getSignatureHelpItems = function (line, offset, fileName) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -34708,9 +34781,8 @@ var ts;
};
return result;
};
- Session.prototype.getDiagnostics = function (_a) {
+ Session.prototype.getDiagnostics = function (delay, fileNames) {
var _this = this;
- var delay = _a.delay, fileNames = _a.files;
var checkList = fileNames.reduce(function (accum, fileName) {
fileName = ts.normalizePath(fileName);
var project = _this.projectService.getProjectForFile(fileName);
@@ -34723,9 +34795,8 @@ var ts;
this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay);
}
};
- Session.prototype.change = function (_a) {
+ Session.prototype.change = function (line, offset, endLine, endOffset, insertString, fileName) {
var _this = this;
- var line = _a.line, offset = _a.offset, endLine = _a.endLine, endOffset = _a.endOffset, insertString = _a.insertString, fileName = _a.file;
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (project) {
@@ -34739,9 +34810,8 @@ var ts;
this.updateProjectStructure(this.changeSeq, function (n) { return n == _this.changeSeq; });
}
};
- Session.prototype.reload = function (_a, reqSeq) {
+ Session.prototype.reload = function (fileName, tempFileName, reqSeq) {
var _this = this;
- var fileName = _a.file, tempFileName = _a.tmpfile;
if (reqSeq === void 0) { reqSeq = 0; }
var file = ts.normalizePath(fileName);
var tmpfile = ts.normalizePath(tempFileName);
@@ -34753,8 +34823,7 @@ var ts;
});
}
};
- Session.prototype.saveToTmp = function (_a) {
- var fileName = _a.file, tempFileName = _a.tmpfile;
+ Session.prototype.saveToTmp = function (fileName, tempFileName) {
var file = ts.normalizePath(fileName);
var tmpfile = ts.normalizePath(tempFileName);
var project = this.projectService.getProjectForFile(file);
@@ -34762,8 +34831,7 @@ var ts;
project.compilerService.host.saveTo(file, tmpfile);
}
};
- Session.prototype.closeClientFile = function (_a) {
- var fileName = _a.file;
+ Session.prototype.closeClientFile = function (fileName) {
var file = ts.normalizePath(fileName);
this.projectService.closeClientFile(file);
};
@@ -34784,8 +34852,7 @@ var ts;
childItems: _this.decorateNavigationBarItem(project, fileName, item.childItems)
}); });
};
- Session.prototype.getNavigationBarItems = function (_a) {
- var fileName = _a.file;
+ Session.prototype.getNavigationBarItems = function (fileName) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -34798,8 +34865,7 @@ var ts;
}
return this.decorateNavigationBarItem(project, fileName, items);
};
- Session.prototype.getNavigateToItems = function (_a) {
- var searchValue = _a.searchValue, fileName = _a.file, maxResultCount = _a.maxResultCount;
+ Session.prototype.getNavigateToItems = function (searchValue, fileName, maxResultCount) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -34835,8 +34901,7 @@ var ts;
return bakedItem;
});
};
- Session.prototype.getBraceMatching = function (_a) {
- var line = _a.line, offset = _a.offset, fileName = _a.file;
+ Session.prototype.getBraceMatching = function (line, offset, fileName) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -34872,91 +34937,112 @@ var ts;
break;
}
case CommandNames.Definition: {
- response = this.getDefinition(request.arguments);
+ var defArgs = request.arguments;
+ response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file);
break;
}
case CommandNames.References: {
- response = this.getReferences(request.arguments);
+ var refArgs = request.arguments;
+ response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file);
break;
}
case CommandNames.Rename: {
- response = this.getRenameLocations(request.arguments);
+ var renameArgs = request.arguments;
+ response = this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings);
break;
}
case CommandNames.Open: {
- this.openClientFile(request.arguments);
+ var openArgs = request.arguments;
+ this.openClientFile(openArgs.file);
responseRequired = false;
break;
}
case CommandNames.Quickinfo: {
- response = this.getQuickInfo(request.arguments);
+ var quickinfoArgs = request.arguments;
+ response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file);
break;
}
case CommandNames.Format: {
- response = this.getFormattingEditsForRange(request.arguments);
+ var formatArgs = request.arguments;
+ response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file);
break;
}
case CommandNames.Formatonkey: {
- response = this.getFormattingEditsAfterKeystroke(request.arguments);
+ var formatOnKeyArgs = request.arguments;
+ response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file);
break;
}
case CommandNames.Completions: {
- response = this.getCompletions(request.arguments);
+ var completionsArgs = request.arguments;
+ response = this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file);
break;
}
case CommandNames.CompletionDetails: {
- response = this.getCompletionEntryDetails(request.arguments);
+ var completionDetailsArgs = request.arguments;
+ response =
+ this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file);
break;
}
case CommandNames.SignatureHelp: {
- response = this.getSignatureHelpItems(request.arguments);
+ var signatureHelpArgs = request.arguments;
+ response = this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file);
break;
}
case CommandNames.Geterr: {
- this.getDiagnostics(request.arguments);
+ var geterrArgs = request.arguments;
+ response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files);
responseRequired = false;
break;
}
case CommandNames.Change: {
- this.change(request.arguments);
+ var changeArgs = request.arguments;
+ this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file);
responseRequired = false;
break;
}
case CommandNames.Configure: {
- this.projectService.setHostConfiguration(request.arguments);
+ var configureArgs = request.arguments;
+ this.projectService.setHostConfiguration(configureArgs);
this.output(undefined, CommandNames.Configure, request.seq);
responseRequired = false;
break;
}
case CommandNames.Reload: {
- this.reload(request.arguments);
+ var reloadArgs = request.arguments;
+ this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq);
responseRequired = false;
break;
}
case CommandNames.Saveto: {
- this.saveToTmp(request.arguments);
+ var savetoArgs = request.arguments;
+ this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile);
responseRequired = false;
break;
}
case CommandNames.Close: {
- this.closeClientFile(request.arguments);
+ var closeArgs = request.arguments;
+ this.closeClientFile(closeArgs.file);
responseRequired = false;
break;
}
case CommandNames.Navto: {
- response = this.getNavigateToItems(request.arguments);
+ var navtoArgs = request.arguments;
+ response = this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount);
break;
}
case CommandNames.Brace: {
- response = this.getBraceMatching(request.arguments);
+ var braceArguments = request.arguments;
+ response = this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file);
break;
}
case CommandNames.NavBar: {
- response = this.getNavigationBarItems(request.arguments);
+ var navBarArgs = request.arguments;
+ response = this.getNavigationBarItems(navBarArgs.file);
break;
}
case CommandNames.Occurrences: {
- response = this.getOccurrences(request.arguments);
+ var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file;
+ response = this.getOccurrences(line, offset, fileName);
break;
}
default: {
diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts
index 1439f0de597..19f7ff11b4f 100644
--- a/bin/typescript.d.ts
+++ b/bin/typescript.d.ts
@@ -124,16 +124,16 @@ declare module "typescript" {
VoidKeyword = 99,
WhileKeyword = 100,
WithKeyword = 101,
- AsKeyword = 102,
- ImplementsKeyword = 103,
- InterfaceKeyword = 104,
- LetKeyword = 105,
- PackageKeyword = 106,
- PrivateKeyword = 107,
- ProtectedKeyword = 108,
- PublicKeyword = 109,
- StaticKeyword = 110,
- YieldKeyword = 111,
+ ImplementsKeyword = 102,
+ InterfaceKeyword = 103,
+ LetKeyword = 104,
+ PackageKeyword = 105,
+ PrivateKeyword = 106,
+ ProtectedKeyword = 107,
+ PublicKeyword = 108,
+ StaticKeyword = 109,
+ YieldKeyword = 110,
+ AsKeyword = 111,
AnyKeyword = 112,
BooleanKeyword = 113,
ConstructorKeyword = 114,
@@ -258,8 +258,8 @@ declare module "typescript" {
LastReservedWord = 101,
FirstKeyword = 66,
LastKeyword = 125,
- FirstFutureReservedWord = 103,
- LastFutureReservedWord = 111,
+ FirstFutureReservedWord = 102,
+ LastFutureReservedWord = 110,
FirstTypeNode = 141,
LastTypeNode = 149,
FirstPunctuation = 14,
@@ -1183,6 +1183,7 @@ declare module "typescript" {
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
}
declare module "typescript" {
+ function getDefaultLibFileName(options: CompilerOptions): string;
function textSpanEnd(span: TextSpan): number;
function textSpanIsEmpty(span: TextSpan): boolean;
function textSpanContainsPosition(span: TextSpan, position: number): boolean;
@@ -1227,7 +1228,6 @@ 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" {
@@ -1289,7 +1289,6 @@ declare module "typescript" {
getDocumentationComment(): SymbolDisplayPart[];
}
interface SourceFile {
- getNamedDeclarations(): Declaration[];
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionOfLineAndCharacter(line: number, character: number): number;
diff --git a/bin/typescript.js b/bin/typescript.js
index 4544cc24ec1..57271ad41ac 100644
--- a/bin/typescript.js
+++ b/bin/typescript.js
@@ -128,17 +128,17 @@ var ts;
SyntaxKind[SyntaxKind["WhileKeyword"] = 100] = "WhileKeyword";
SyntaxKind[SyntaxKind["WithKeyword"] = 101] = "WithKeyword";
// Strict mode reserved words
- SyntaxKind[SyntaxKind["AsKeyword"] = 102] = "AsKeyword";
- SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword";
- SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword";
- SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword";
- SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword";
- SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword";
- SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword";
- SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword";
- SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword";
- SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword";
+ SyntaxKind[SyntaxKind["ImplementsKeyword"] = 102] = "ImplementsKeyword";
+ SyntaxKind[SyntaxKind["InterfaceKeyword"] = 103] = "InterfaceKeyword";
+ SyntaxKind[SyntaxKind["LetKeyword"] = 104] = "LetKeyword";
+ SyntaxKind[SyntaxKind["PackageKeyword"] = 105] = "PackageKeyword";
+ SyntaxKind[SyntaxKind["PrivateKeyword"] = 106] = "PrivateKeyword";
+ SyntaxKind[SyntaxKind["ProtectedKeyword"] = 107] = "ProtectedKeyword";
+ SyntaxKind[SyntaxKind["PublicKeyword"] = 108] = "PublicKeyword";
+ SyntaxKind[SyntaxKind["StaticKeyword"] = 109] = "StaticKeyword";
+ SyntaxKind[SyntaxKind["YieldKeyword"] = 110] = "YieldKeyword";
// Contextual keywords
+ SyntaxKind[SyntaxKind["AsKeyword"] = 111] = "AsKeyword";
SyntaxKind[SyntaxKind["AnyKeyword"] = 112] = "AnyKeyword";
SyntaxKind[SyntaxKind["BooleanKeyword"] = 113] = "BooleanKeyword";
SyntaxKind[SyntaxKind["ConstructorKeyword"] = 114] = "ConstructorKeyword";
@@ -280,8 +280,8 @@ var ts;
SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord";
SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword";
SyntaxKind[SyntaxKind["LastKeyword"] = 125] = "LastKeyword";
- SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord";
- SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord";
+ SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord";
+ SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord";
SyntaxKind[SyntaxKind["FirstTypeNode"] = 141] = "FirstTypeNode";
SyntaxKind[SyntaxKind["LastTypeNode"] = 149] = "LastTypeNode";
SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation";
@@ -2178,7 +2178,7 @@ var ts;
(function (ts) {
var textToToken = {
"any": 112 /* AnyKeyword */,
- "as": 102 /* AsKeyword */,
+ "as": 111 /* AsKeyword */,
"boolean": 113 /* BooleanKeyword */,
"break": 66 /* BreakKeyword */,
"case": 67 /* CaseKeyword */,
@@ -2203,24 +2203,24 @@ var ts;
"function": 83 /* FunctionKeyword */,
"get": 116 /* GetKeyword */,
"if": 84 /* IfKeyword */,
- "implements": 103 /* ImplementsKeyword */,
+ "implements": 102 /* ImplementsKeyword */,
"import": 85 /* ImportKeyword */,
"in": 86 /* InKeyword */,
"instanceof": 87 /* InstanceOfKeyword */,
- "interface": 104 /* InterfaceKeyword */,
- "let": 105 /* LetKeyword */,
+ "interface": 103 /* InterfaceKeyword */,
+ "let": 104 /* LetKeyword */,
"module": 117 /* ModuleKeyword */,
"new": 88 /* NewKeyword */,
"null": 89 /* NullKeyword */,
"number": 119 /* NumberKeyword */,
- "package": 106 /* PackageKeyword */,
- "private": 107 /* PrivateKeyword */,
- "protected": 108 /* ProtectedKeyword */,
- "public": 109 /* PublicKeyword */,
+ "package": 105 /* PackageKeyword */,
+ "private": 106 /* PrivateKeyword */,
+ "protected": 107 /* ProtectedKeyword */,
+ "public": 108 /* PublicKeyword */,
"require": 118 /* RequireKeyword */,
"return": 90 /* ReturnKeyword */,
"set": 120 /* SetKeyword */,
- "static": 110 /* StaticKeyword */,
+ "static": 109 /* StaticKeyword */,
"string": 121 /* StringKeyword */,
"super": 91 /* SuperKeyword */,
"switch": 92 /* SwitchKeyword */,
@@ -2235,7 +2235,7 @@ var ts;
"void": 99 /* VoidKeyword */,
"while": 100 /* WhileKeyword */,
"with": 101 /* WithKeyword */,
- "yield": 111 /* YieldKeyword */,
+ "yield": 110 /* YieldKeyword */,
"of": 125 /* OfKeyword */,
"{": 14 /* OpenBraceToken */,
"}": 15 /* CloseBraceToken */,
@@ -5027,7 +5027,7 @@ var ts;
}
ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement;
function getClassImplementsHeritageClauseElements(node) {
- var heritageClause = getHeritageClause(node.heritageClauses, 103 /* ImplementsKeyword */);
+ var heritageClause = getHeritageClause(node.heritageClauses, 102 /* ImplementsKeyword */);
return heritageClause ? heritageClause.types : undefined;
}
ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements;
@@ -5157,10 +5157,10 @@ var ts;
ts.isESSymbolIdentifier = isESSymbolIdentifier;
function isModifier(token) {
switch (token) {
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
- case 110 /* StaticKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
+ case 109 /* StaticKeyword */:
case 78 /* ExportKeyword */:
case 115 /* DeclareKeyword */:
case 70 /* ConstKeyword */:
@@ -5609,6 +5609,10 @@ var ts;
})(ts || (ts = {}));
var ts;
(function (ts) {
+ function getDefaultLibFileName(options) {
+ return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts";
+ }
+ ts.getDefaultLibFileName = getDefaultLibFileName;
function textSpanEnd(span) {
return span.start + span.length;
}
@@ -6185,10 +6189,10 @@ var ts;
;
function modifierToFlag(token) {
switch (token) {
- case 110 /* StaticKeyword */: return 128 /* Static */;
- case 109 /* PublicKeyword */: return 16 /* Public */;
- case 108 /* ProtectedKeyword */: return 64 /* Protected */;
- case 107 /* PrivateKeyword */: return 32 /* Private */;
+ case 109 /* StaticKeyword */: return 128 /* Static */;
+ case 108 /* PublicKeyword */: return 16 /* Public */;
+ case 107 /* ProtectedKeyword */: return 64 /* Protected */;
+ case 106 /* PrivateKeyword */: return 32 /* Private */;
case 78 /* ExportKeyword */: return 1 /* Export */;
case 115 /* DeclareKeyword */: return 2 /* Ambient */;
case 70 /* ConstKeyword */: return 8192 /* Const */;
@@ -7004,7 +7008,7 @@ var ts;
}
// If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is
// considered a keyword and is not an identifier.
- if (token === 111 /* YieldKeyword */ && inYieldContext()) {
+ if (token === 110 /* YieldKeyword */ && inYieldContext()) {
return false;
}
return token > 101 /* LastReservedWord */;
@@ -7282,7 +7286,7 @@ var ts;
// extends {} extends
// extends {} implements
var next = nextToken();
- return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 79 /* ExtendsKeyword */ || next === 103 /* ImplementsKeyword */;
+ return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 79 /* ExtendsKeyword */ || next === 102 /* ImplementsKeyword */;
}
return true;
}
@@ -7291,7 +7295,7 @@ var ts;
return isIdentifier();
}
function isHeritageClauseExtendsOrImplementsKeyword() {
- if (token === 103 /* ImplementsKeyword */ ||
+ if (token === 102 /* ImplementsKeyword */ ||
token === 79 /* ExtendsKeyword */) {
return lookAhead(nextTokenIsStartOfExpression);
}
@@ -7321,12 +7325,12 @@ var ts;
case 4 /* SwitchClauseStatements */:
return token === 15 /* CloseBraceToken */ || token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */;
case 8 /* HeritageClauseElement */:
- return token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */;
+ return token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */;
case 9 /* VariableDeclarations */:
return isVariableDeclaratorListTerminator();
case 16 /* TypeParameters */:
// Tokens other than '>' are here for better error recovery
- return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */;
+ return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */;
case 12 /* ArgumentExpressions */:
// Tokens other than ')' are here for better error recovery
return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */;
@@ -8363,7 +8367,7 @@ var ts;
case 38 /* PlusPlusToken */:
case 39 /* MinusMinusToken */:
case 24 /* LessThanToken */:
- case 111 /* YieldKeyword */:
+ case 110 /* YieldKeyword */:
// Yield always starts an expression. Either it is an identifier (in which case
// it is definitely an expression). Or it's a keyword (either because we're in
// a generator, or in strict mode (or both)) and it started a yield expression.
@@ -8478,7 +8482,7 @@ var ts;
return parseConditionalExpressionRest(expr);
}
function isYieldExpression() {
- if (token === 111 /* YieldKeyword */) {
+ if (token === 110 /* YieldKeyword */) {
// If we have a 'yield' keyword, and htis is a context where yield expressions are
// allowed, then definitely parse out a yield expression.
if (inYieldContext()) {
@@ -9319,7 +9323,7 @@ var ts;
parseExpected(16 /* OpenParenToken */);
var initializer = undefined;
if (token !== 22 /* SemicolonToken */) {
- if (token === 98 /* VarKeyword */ || token === 105 /* LetKeyword */ || token === 70 /* ConstKeyword */) {
+ if (token === 98 /* VarKeyword */ || token === 104 /* LetKeyword */ || token === 70 /* ConstKeyword */) {
initializer = parseVariableDeclarationList(true);
}
else {
@@ -9503,7 +9507,7 @@ var ts;
return !inErrorRecovery;
case 14 /* OpenBraceToken */:
case 98 /* VarKeyword */:
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
case 83 /* FunctionKeyword */:
case 69 /* ClassKeyword */:
case 84 /* IfKeyword */:
@@ -9529,7 +9533,7 @@ var ts;
// In ES 6 'enum' is a future reserved keyword, so it should not be used as identifier
var isConstEnum = lookAhead(nextTokenIsEnumKeyword);
return !isConstEnum;
- case 104 /* InterfaceKeyword */:
+ case 103 /* InterfaceKeyword */:
case 117 /* ModuleKeyword */:
case 77 /* EnumKeyword */:
case 123 /* TypeKeyword */:
@@ -9538,10 +9542,10 @@ var ts;
if (isDeclarationStart()) {
return false;
}
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
- case 110 /* StaticKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
+ case 109 /* StaticKeyword */:
// When followed by an identifier or keyword, these do not start a statement but
// might instead be following type members
if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) {
@@ -9600,7 +9604,7 @@ var ts;
return parseTryStatement();
case 72 /* DebuggerKeyword */:
return parseDebuggerStatement();
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
// If let follows identifier on the same line, it is declaration parse it as variable statement
if (isLetDeclaration()) {
return parseVariableStatement(scanner.getStartPos(), undefined, undefined);
@@ -9635,7 +9639,7 @@ var ts;
return undefined;
}
return parseVariableStatement(start, decorators, modifiers);
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
if (!isLetDeclaration()) {
return undefined;
}
@@ -9722,7 +9726,7 @@ var ts;
switch (token) {
case 98 /* VarKeyword */:
break;
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
node.flags |= 4096 /* Let */;
break;
case 70 /* ConstKeyword */:
@@ -9832,10 +9836,10 @@ var ts;
}
function isClassMemberModifier(idToken) {
switch (idToken) {
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
- case 110 /* StaticKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
+ case 109 /* StaticKeyword */:
return true;
default:
return false;
@@ -10028,7 +10032,7 @@ var ts;
return parseList(19 /* HeritageClauses */, false, parseHeritageClause);
}
function parseHeritageClause() {
- if (token === 79 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */) {
+ if (token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */) {
var node = createNode(222 /* HeritageClause */);
node.token = token;
nextToken();
@@ -10046,7 +10050,7 @@ var ts;
return finishNode(node);
}
function isHeritageClause() {
- return token === 79 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */;
+ return token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */;
}
function parseClassMembers() {
return parseList(6 /* ClassMembers */, false, parseClassElement);
@@ -10055,7 +10059,7 @@ var ts;
var node = createNode(202 /* InterfaceDeclaration */, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
- parseExpected(104 /* InterfaceKeyword */);
+ parseExpected(103 /* InterfaceKeyword */);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
node.heritageClauses = parseHeritageClauses(false);
@@ -10234,7 +10238,7 @@ var ts;
// * as ImportedBinding
var namespaceImport = createNode(211 /* NamespaceImport */);
parseExpected(35 /* AsteriskToken */);
- parseExpected(102 /* AsKeyword */);
+ parseExpected(111 /* AsKeyword */);
namespaceImport.name = parseIdentifier();
return finishNode(namespaceImport);
}
@@ -10268,9 +10272,9 @@ var ts;
var checkIdentifierStart = scanner.getTokenPos();
var checkIdentifierEnd = scanner.getTextPos();
var identifierName = parseIdentifierName();
- if (token === 102 /* AsKeyword */) {
+ if (token === 111 /* AsKeyword */) {
node.propertyName = identifierName;
- parseExpected(102 /* AsKeyword */);
+ parseExpected(111 /* AsKeyword */);
checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier();
checkIdentifierStart = scanner.getTokenPos();
checkIdentifierEnd = scanner.getTextPos();
@@ -10327,10 +10331,10 @@ var ts;
case 70 /* ConstKeyword */:
case 83 /* FunctionKeyword */:
return true;
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
return isLetDeclaration();
case 69 /* ClassKeyword */:
- case 104 /* InterfaceKeyword */:
+ case 103 /* InterfaceKeyword */:
case 77 /* EnumKeyword */:
case 123 /* TypeKeyword */:
// Not true keywords so ensure an identifier follows
@@ -10345,10 +10349,10 @@ var ts;
// Check for export assignment or modifier on source element
return lookAhead(nextTokenCanFollowExportKeyword);
case 115 /* DeclareKeyword */:
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
- case 110 /* StaticKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
+ case 109 /* StaticKeyword */:
// Check for modifier on source element
return lookAhead(nextTokenIsDeclarationStart);
case 52 /* AtToken */:
@@ -10383,7 +10387,7 @@ var ts;
return isDeclarationStart(true);
}
function nextTokenIsAsKeyword() {
- return nextToken() === 102 /* AsKeyword */;
+ return nextToken() === 111 /* AsKeyword */;
}
function parseDeclaration() {
var fullStart = getNodePos();
@@ -10400,14 +10404,14 @@ var ts;
}
switch (token) {
case 98 /* VarKeyword */:
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
case 70 /* ConstKeyword */:
return parseVariableStatement(fullStart, decorators, modifiers);
case 83 /* FunctionKeyword */:
return parseFunctionDeclaration(fullStart, decorators, modifiers);
case 69 /* ClassKeyword */:
return parseClassDeclaration(fullStart, decorators, modifiers);
- case 104 /* InterfaceKeyword */:
+ case 103 /* InterfaceKeyword */:
return parseInterfaceDeclaration(fullStart, decorators, modifiers);
case 123 /* TypeKeyword */:
return parseTypeAliasDeclaration(fullStart, decorators, modifiers);
@@ -13228,15 +13232,16 @@ var ts;
return result;
}
function getPropertiesOfType(type) {
- if (type.flags & 16384 /* Union */) {
- return getPropertiesOfUnionType(type);
- }
- return getPropertiesOfObjectType(getApparentType(type));
+ type = getApparentType(type);
+ return type.flags & 16384 /* Union */ ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type);
}
// For a type parameter, return the base constraint of the type parameter. For the string, number,
// boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
// type itself. Note that the apparent type of a union type is the union type itself.
function getApparentType(type) {
+ if (type.flags & 16384 /* Union */) {
+ type = getReducedTypeOfUnionType(type);
+ }
if (type.flags & 512 /* TypeParameter */) {
do {
type = getConstraintOfTypeParameter(type);
@@ -13308,28 +13313,27 @@ var ts;
// necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from
// Object and Function as appropriate.
function getPropertyOfType(type, name) {
+ type = getApparentType(type);
+ if (type.flags & 48128 /* ObjectType */) {
+ var resolved = resolveObjectOrUnionTypeMembers(type);
+ if (ts.hasProperty(resolved.members, name)) {
+ var symbol = resolved.members[name];
+ if (symbolIsValue(symbol)) {
+ return symbol;
+ }
+ }
+ if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
+ var symbol = getPropertyOfObjectType(globalFunctionType, name);
+ if (symbol) {
+ return symbol;
+ }
+ }
+ return getPropertyOfObjectType(globalObjectType, name);
+ }
if (type.flags & 16384 /* Union */) {
return getPropertyOfUnionType(type, name);
}
- if (!(type.flags & 48128 /* ObjectType */)) {
- type = getApparentType(type);
- if (!(type.flags & 48128 /* ObjectType */)) {
- return undefined;
- }
- }
- var resolved = resolveObjectOrUnionTypeMembers(type);
- if (ts.hasProperty(resolved.members, name)) {
- var symbol = resolved.members[name];
- if (symbolIsValue(symbol)) {
- return symbol;
- }
- }
- if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
- var symbol = getPropertyOfObjectType(globalFunctionType, name);
- if (symbol)
- return symbol;
- }
- return getPropertyOfObjectType(globalObjectType, name);
+ return undefined;
}
function getSignaturesOfObjectOrUnionType(type, kind) {
if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) {
@@ -13852,6 +13856,10 @@ var ts;
}
}
}
+ // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag
+ // is true when creating a union type from a type node and when instantiating a union type. In both of those
+ // cases subtype reduction has to be deferred to properly support recursive union types. For example, a
+ // type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration.
function getUnionType(types, noSubtypeReduction) {
if (types.length === 0) {
return emptyObjectType;
@@ -13876,9 +13884,17 @@ var ts;
if (!type) {
type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(sortedTypes));
type.types = sortedTypes;
+ type.reducedType = noSubtypeReduction ? undefined : type;
}
return type;
}
+ function getReducedTypeOfUnionType(type) {
+ // If union type was created without subtype reduction, perform the deferred reduction now
+ if (!type.reducedType) {
+ type.reducedType = getUnionType(type.types, false);
+ }
+ return type.reducedType;
+ }
function getTypeFromUnionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
@@ -19153,7 +19169,10 @@ var ts;
return checkElementTypeOfArrayOrString(inputType, errorNode);
}
if (isArrayLikeType(inputType)) {
- return getIndexTypeOfType(inputType, 1 /* Number */);
+ var indexType = getIndexTypeOfType(inputType, 1 /* Number */);
+ if (indexType) {
+ return indexType;
+ }
}
error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType));
return unknownType;
@@ -21385,7 +21404,7 @@ var ts;
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 */);
+ (node.originalKeywordKind >= 102 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 110 /* 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.)
@@ -21565,14 +21584,14 @@ var ts;
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
var modifier = _a[_i];
switch (modifier.kind) {
- case 109 /* PublicKeyword */:
- case 108 /* ProtectedKeyword */:
- case 107 /* PrivateKeyword */:
+ case 108 /* PublicKeyword */:
+ case 107 /* ProtectedKeyword */:
+ case 106 /* PrivateKeyword */:
var text = void 0;
- if (modifier.kind === 109 /* PublicKeyword */) {
+ if (modifier.kind === 108 /* PublicKeyword */) {
text = "public";
}
- else if (modifier.kind === 108 /* ProtectedKeyword */) {
+ else if (modifier.kind === 107 /* ProtectedKeyword */) {
text = "protected";
lastProtected = modifier;
}
@@ -21591,7 +21610,7 @@ var ts;
}
flags |= ts.modifierToFlag(modifier.kind);
break;
- case 110 /* StaticKeyword */:
+ case 109 /* StaticKeyword */:
if (flags & 128 /* Static */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
}
@@ -21823,7 +21842,7 @@ var ts;
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */);
+ ts.Debug.assert(heritageClause.token === 102 /* ImplementsKeyword */);
if (seenImplementsClause) {
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
}
@@ -21846,7 +21865,7 @@ var ts;
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */);
+ ts.Debug.assert(heritageClause.token === 102 /* ImplementsKeyword */);
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
}
// Grammar checking heritageClause inside class declaration
@@ -24947,7 +24966,7 @@ var ts;
emit(node.expression);
}
function emitYieldExpression(node) {
- write(ts.tokenToString(111 /* YieldKeyword */));
+ write(ts.tokenToString(110 /* YieldKeyword */));
if (node.asteriskToken) {
write("*");
}
@@ -25638,7 +25657,7 @@ var ts;
var tokenKind = 98 /* VarKeyword */;
if (decl && languageVersion >= 2 /* ES6 */) {
if (ts.isLet(decl)) {
- tokenKind = 105 /* LetKeyword */;
+ tokenKind = 104 /* LetKeyword */;
}
else if (ts.isConst(decl)) {
tokenKind = 70 /* ConstKeyword */;
@@ -25651,7 +25670,7 @@ var ts;
switch (tokenKind) {
case 98 /* VarKeyword */:
return write("var ");
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
return write("let ");
case 70 /* ConstKeyword */:
return write("const ");
@@ -28582,7 +28601,7 @@ var ts;
}
return {
getSourceFile: getSourceFile,
- getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), getDefaultLibFileName(options)); },
+ getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
writeFile: writeFile,
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
@@ -28622,10 +28641,6 @@ 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 = [];
@@ -29527,32 +29542,34 @@ var ts;
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
ts.forEach(program.getSourceFiles(), function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
- var declarations = sourceFile.getNamedDeclarations();
- for (var _i = 0; _i < declarations.length; _i++) {
- var declaration = declarations[_i];
- var name = getDeclarationName(declaration);
- if (name !== undefined) {
+ var nameToDeclarations = sourceFile.getNamedDeclarations();
+ for (var name_21 in nameToDeclarations) {
+ var declarations = ts.getProperty(nameToDeclarations, name_21);
+ if (declarations) {
// First do a quick check to see if the name of the declaration matches the
// last portion of the (possibly) dotted name they're searching for.
- var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name);
+ var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_21);
if (!matches) {
continue;
}
- // It was a match! If the pattern has dots in it, then also see if the
- // declaration container matches as well.
- if (patternMatcher.patternContainsDots) {
- var containers = getContainers(declaration);
- if (!containers) {
- return undefined;
- }
- matches = patternMatcher.getMatches(containers, name);
- if (!matches) {
- continue;
+ for (var _i = 0; _i < declarations.length; _i++) {
+ var declaration = declarations[_i];
+ // It was a match! If the pattern has dots in it, then also see if the
+ // declaration container matches as well.
+ if (patternMatcher.patternContainsDots) {
+ var containers = getContainers(declaration);
+ if (!containers) {
+ return undefined;
+ }
+ matches = patternMatcher.getMatches(containers, name_21);
+ if (!matches) {
+ continue;
+ }
}
+ var fileName = sourceFile.fileName;
+ var matchKind = bestMatchKind(matches);
+ rawItems.push({ name: name_21, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration });
}
- var fileName = sourceFile.fileName;
- var matchKind = bestMatchKind(matches);
- rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration });
}
}
});
@@ -29573,25 +29590,13 @@ var ts;
}
return true;
}
- function getDeclarationName(declaration) {
- var result = getTextOfIdentifierOrLiteral(declaration.name);
- if (result !== undefined) {
- return result;
- }
- if (declaration.name.kind === 127 /* ComputedPropertyName */) {
- var expr = declaration.name.expression;
- if (expr.kind === 155 /* PropertyAccessExpression */) {
- return expr.name.text;
- }
- return getTextOfIdentifierOrLiteral(expr);
- }
- return undefined;
- }
function getTextOfIdentifierOrLiteral(node) {
- if (node.kind === 65 /* Identifier */ ||
- node.kind === 8 /* StringLiteral */ ||
- node.kind === 7 /* NumericLiteral */) {
- return node.text;
+ if (node) {
+ if (node.kind === 65 /* Identifier */ ||
+ node.kind === 8 /* StringLiteral */ ||
+ node.kind === 7 /* NumericLiteral */) {
+ return node.text;
+ }
}
return undefined;
}
@@ -29946,9 +29951,9 @@ var ts;
case 198 /* VariableDeclaration */:
case 152 /* BindingElement */:
var variableDeclarationNode;
- var name_21;
+ var name_22;
if (node.kind === 152 /* BindingElement */) {
- name_21 = node.name;
+ name_22 = node.name;
variableDeclarationNode = node;
// binding elements are added only for variable declarations
// bubble up to the containing variable declaration
@@ -29960,16 +29965,16 @@ var ts;
else {
ts.Debug.assert(!ts.isBindingPattern(node.name));
variableDeclarationNode = node;
- name_21 = node.name;
+ name_22 = node.name;
}
if (ts.isConst(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.constElement);
+ return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.constElement);
}
else if (ts.isLet(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.letElement);
+ return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.letElement);
}
else {
- return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.variableElement);
+ return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.variableElement);
}
case 135 /* Constructor */:
return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement);
@@ -30868,7 +30873,8 @@ var ts;
ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments";
ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments";
})(ArgumentListKind || (ArgumentListKind = {}));
- function getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken) {
+ function getSignatureHelpItems(program, sourceFile, position, cancellationToken) {
+ var typeChecker = program.getTypeChecker();
// Decide whether to show signature help
var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position);
if (!startingToken) {
@@ -30883,12 +30889,54 @@ var ts;
}
var call = argumentInfo.invocation;
var candidates = [];
- var resolvedSignature = typeInfoResolver.getResolvedSignature(call, candidates);
+ var resolvedSignature = typeChecker.getResolvedSignature(call, candidates);
cancellationToken.throwIfCancellationRequested();
if (!candidates.length) {
+ // We didn't have any sig help items produced by the TS compiler. If this is a JS
+ // file, then see if we can figure out anything better.
+ if (ts.isJavaScript(sourceFile.fileName)) {
+ return createJavaScriptSignatureHelpItems(argumentInfo);
+ }
return undefined;
}
return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo);
+ function createJavaScriptSignatureHelpItems(argumentInfo) {
+ if (argumentInfo.invocation.kind !== 157 /* CallExpression */) {
+ return undefined;
+ }
+ // See if we can find some symbol with the call expression name that has call signatures.
+ var callExpression = argumentInfo.invocation;
+ var expression = callExpression.expression;
+ var name = expression.kind === 65 /* Identifier */
+ ? expression
+ : expression.kind === 155 /* PropertyAccessExpression */
+ ? expression.name
+ : undefined;
+ if (!name || !name.text) {
+ return undefined;
+ }
+ var typeChecker = program.getTypeChecker();
+ for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
+ var sourceFile_1 = _a[_i];
+ var nameToDeclarations = sourceFile_1.getNamedDeclarations();
+ var declarations = ts.getProperty(nameToDeclarations, name.text);
+ if (declarations) {
+ for (var _b = 0; _b < declarations.length; _b++) {
+ var declaration = declarations[_b];
+ var symbol = declaration.symbol;
+ if (symbol) {
+ var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
+ if (type) {
+ var callSignatures = type.getCallSignatures();
+ if (callSignatures && callSignatures.length) {
+ return createSignatureHelpItems(callSignatures, callSignatures[0], argumentInfo);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
/**
* Returns relevant information for the argument list and the current argument if we are
* in the argument of an invocation; returns undefined otherwise.
@@ -31142,8 +31190,8 @@ var ts;
var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */;
var invocation = argumentListInfo.invocation;
var callTarget = ts.getInvokedExpression(invocation);
- var callTargetSymbol = typeInfoResolver.getSymbolAtLocation(callTarget);
- var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeInfoResolver, callTargetSymbol, undefined, undefined);
+ var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget);
+ var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined);
var items = ts.map(candidates, function (candidateSignature) {
var signatureHelpParameters;
var prefixDisplayParts = [];
@@ -31157,13 +31205,13 @@ var ts;
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
suffixDisplayParts.push(ts.punctuationPart(25 /* GreaterThanToken */));
var parameterParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation);
});
suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts);
}
else {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation);
});
prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts);
prefixDisplayParts.push(ts.punctuationPart(16 /* OpenParenToken */));
@@ -31172,7 +31220,7 @@ var ts;
suffixDisplayParts.push(ts.punctuationPart(17 /* CloseParenToken */));
}
var returnTypeParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation);
});
suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts);
return {
@@ -31201,7 +31249,7 @@ var ts;
};
function createSignatureHelpParameterForParameter(parameter) {
var displayParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation);
});
var isOptional = ts.hasQuestionToken(parameter.valueDeclaration);
return {
@@ -31213,7 +31261,7 @@ var ts;
}
function createSignatureHelpParameterForTypeParameter(typeParameter) {
var displayParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation);
});
return {
name: typeParameter.symbol.name,
@@ -31661,9 +31709,9 @@ var ts;
ts.isInsideTemplateLiteral = isInsideTemplateLiteral;
function isAccessibilityModifier(kind) {
switch (kind) {
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
return true;
}
return false;
@@ -31855,6 +31903,10 @@ var ts;
});
}
ts.signatureToDisplayParts = signatureToDisplayParts;
+ function isJavaScript(fileName) {
+ return ts.fileExtensionIs(fileName, ".js");
+ }
+ ts.isJavaScript = isJavaScript;
})(ts || (ts = {}));
///
///
@@ -32376,7 +32428,7 @@ var ts;
this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* MinusToken */, 39 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([98 /* VarKeyword */, 94 /* ThrowKeyword */, 88 /* NewKeyword */, 74 /* DeleteKeyword */, 90 /* ReturnKeyword */, 97 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105 /* LetKeyword */, 70 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */));
+ this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104 /* LetKeyword */, 70 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */));
this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */));
this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(83 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */));
@@ -32399,8 +32451,8 @@ var ts;
// Use of module as a function call. e.g.: import m2 = module("m2");
this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117 /* ModuleKeyword */, 118 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Add a space around certain TypeScript keywords
- this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 103 /* ImplementsKeyword */, 85 /* ImportKeyword */, 104 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 107 /* PrivateKeyword */, 109 /* PublicKeyword */, 120 /* SetKeyword */, 110 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 103 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 120 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 102 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */));
// Lambda expressions
@@ -32419,7 +32471,7 @@ var ts;
// decorators
this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 110 /* StaticKeyword */, 109 /* PublicKeyword */, 107 /* PrivateKeyword */, 108 /* ProtectedKeyword */, 116 /* GetKeyword */, 120 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */));
+ this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 120 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -32509,9 +32561,9 @@ var ts;
}
Rules.prototype.getRuleName = function (rule) {
var o = this;
- for (var name_22 in o) {
- if (o[name_22] === rule) {
- return name_22;
+ for (var name_23 in o) {
+ if (o[name_23] === rule) {
+ return name_23;
}
}
throw new Error("Unknown rule");
@@ -33436,7 +33488,7 @@ var ts;
}
switch (node.kind) {
case 201 /* ClassDeclaration */: return 69 /* ClassKeyword */;
- case 202 /* InterfaceDeclaration */: return 104 /* InterfaceKeyword */;
+ case 202 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */;
case 200 /* FunctionDeclaration */: return 83 /* FunctionKeyword */;
case 204 /* EnumDeclaration */: return 204 /* EnumDeclaration */;
case 136 /* GetAccessor */: return 116 /* GetKeyword */;
@@ -34909,29 +34961,65 @@ var ts;
return this.namedDeclarations;
};
SourceFileObject.prototype.computeNamedDeclarations = function () {
- var namedDeclarations = [];
+ var result = {};
ts.forEachChild(this, visit);
- return namedDeclarations;
+ return result;
+ function addDeclaration(declaration) {
+ var name = getDeclarationName(declaration);
+ if (name) {
+ var declarations = getDeclarations(name);
+ declarations.push(declaration);
+ }
+ }
+ function getDeclarations(name) {
+ return ts.getProperty(result, name) || (result[name] = []);
+ }
+ function getDeclarationName(declaration) {
+ if (declaration.name) {
+ var result_2 = getTextOfIdentifierOrLiteral(declaration.name);
+ if (result_2 !== undefined) {
+ return result_2;
+ }
+ if (declaration.name.kind === 127 /* ComputedPropertyName */) {
+ var expr = declaration.name.expression;
+ if (expr.kind === 155 /* PropertyAccessExpression */) {
+ return expr.name.text;
+ }
+ return getTextOfIdentifierOrLiteral(expr);
+ }
+ }
+ return undefined;
+ }
+ function getTextOfIdentifierOrLiteral(node) {
+ if (node) {
+ if (node.kind === 65 /* Identifier */ ||
+ node.kind === 8 /* StringLiteral */ ||
+ node.kind === 7 /* NumericLiteral */) {
+ return node.text;
+ }
+ }
+ return undefined;
+ }
function visit(node) {
switch (node.kind) {
case 200 /* FunctionDeclaration */:
case 134 /* MethodDeclaration */:
case 133 /* MethodSignature */:
var functionDeclaration = node;
- if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) {
- var lastDeclaration = namedDeclarations.length > 0 ?
- namedDeclarations[namedDeclarations.length - 1] :
- undefined;
+ var declarationName = getDeclarationName(functionDeclaration);
+ if (declarationName) {
+ var declarations = getDeclarations(declarationName);
+ var lastDeclaration = ts.lastOrUndefined(declarations);
// Check whether this declaration belongs to an "overload group".
- if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) {
+ if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) {
// Overwrite the last declaration if it was an overload
// and this one is an implementation.
if (functionDeclaration.body && !lastDeclaration.body) {
- namedDeclarations[namedDeclarations.length - 1] = functionDeclaration;
+ declarations[declarations.length - 1] = functionDeclaration;
}
}
else {
- namedDeclarations.push(functionDeclaration);
+ declarations.push(functionDeclaration);
}
ts.forEachChild(node, visit);
}
@@ -34950,9 +35038,7 @@ var ts;
case 136 /* GetAccessor */:
case 137 /* SetAccessor */:
case 145 /* TypeLiteral */:
- if (node.name) {
- namedDeclarations.push(node);
- }
+ addDeclaration(node);
// fall through
case 135 /* Constructor */:
case 180 /* VariableStatement */:
@@ -34982,7 +35068,7 @@ var ts;
case 226 /* EnumMember */:
case 132 /* PropertyDeclaration */:
case 131 /* PropertySignature */:
- namedDeclarations.push(node);
+ addDeclaration(node);
break;
case 215 /* ExportDeclaration */:
// Handle named exports case e.g.:
@@ -34997,14 +35083,14 @@ var ts;
// Handle default import case e.g.:
// import d from "mod";
if (importClause.name) {
- namedDeclarations.push(importClause);
+ addDeclaration(importClause);
}
// Handle named bindings in imports e.g.:
// import * as NS from "mod";
// import {a, b as B} from "mod";
if (importClause.namedBindings) {
if (importClause.namedBindings.kind === 211 /* NamespaceImport */) {
- namedDeclarations.push(importClause.namedBindings);
+ addDeclaration(importClause.namedBindings);
}
else {
ts.forEach(importClause.namedBindings.elements, visit);
@@ -35593,7 +35679,7 @@ var ts;
}
else if (token === 35 /* AsteriskToken */) {
token = scanner.scan();
- if (token === 102 /* AsKeyword */) {
+ if (token === 111 /* AsKeyword */) {
token = scanner.scan();
if (token === 65 /* Identifier */) {
token = scanner.scan();
@@ -35864,8 +35950,6 @@ var ts;
var syntaxTreeCache = new SyntaxTreeCache(host);
var ruleProvider;
var program;
- // this checker is used to answer all LS questions except errors
- var typeInfoResolver;
var useCaseSensitivefileNames = false;
var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
// Check if the localized messages json is set, otherwise query the host for it
@@ -35935,7 +36019,9 @@ var ts;
}
}
program = newProgram;
- typeInfoResolver = program.getTypeChecker();
+ // Make sure all the nodes in the program are both bound, and have their parent
+ // pointers set property.
+ program.getTypeChecker();
return;
function getOrCreateSourceFile(fileName) {
// The program is asking for this file, check first if the host can locate it.
@@ -36007,15 +36093,8 @@ var ts;
synchronizeHostData();
return program;
}
- /**
- * Clean up any semantic caches that are not needed.
- * The host can call this method if it wants to jettison unused memory.
- * We will just dump the typeChecker and recreate a new one. this should have the effect of destroying all the semantic caches.
- */
function cleanupSemanticCache() {
- if (program) {
- typeInfoResolver = program.getTypeChecker();
- }
+ // TODO: Should we jettison the program (or it's type checker) here?
}
function dispose() {
if (program) {
@@ -36029,9 +36108,6 @@ var ts;
synchronizeHostData();
return program.getSyntacticDiagnostics(getValidSourceFile(fileName));
}
- function isJavaScript(fileName) {
- return ts.fileExtensionIs(fileName, ".js");
- }
/**
* getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors
* If '-d' enabled, report both semantic and emitter errors
@@ -36042,7 +36118,7 @@ var ts;
// For JavaScript files, we don't want to report the normal typescript semantic errors.
// Instead, we just report errors for using TypeScript-only constructs from within a
// JavaScript file.
- if (isJavaScript(fileName)) {
+ if (ts.isJavaScript(fileName)) {
return getJavaScriptSemanticDiagnostics(targetSourceFile);
}
// Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file.
@@ -36079,7 +36155,7 @@ var ts;
break;
case 222 /* HeritageClause */:
var heritageClause = node;
- if (heritageClause.token === 103 /* ImplementsKeyword */) {
+ if (heritageClause.token === 102 /* ImplementsKeyword */) {
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file));
return true;
}
@@ -36182,14 +36258,14 @@ var ts;
for (var _i = 0; _i < modifiers.length; _i++) {
var modifier = modifiers[_i];
switch (modifier.kind) {
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
case 115 /* DeclareKeyword */:
diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind)));
return true;
// These are all legal modifiers.
- case 110 /* StaticKeyword */:
+ case 109 /* StaticKeyword */:
case 78 /* ExportKeyword */:
case 70 /* ConstKeyword */:
case 73 /* DefaultKeyword */:
@@ -36251,29 +36327,8 @@ var ts;
}
return ts.unescapeIdentifier(displayName);
}
- function createCompletionEntry(symbol, typeChecker, location) {
- // Try to get a valid display name for this symbol, if we could not find one, then ignore it.
- // We would like to only show things that can be added after a dot, so for instance numeric properties can
- // not be accessed with a dot (a.1 <- invalid)
- var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true);
- if (!displayName) {
- return undefined;
- }
- // TODO(drosen): Right now we just permit *all* semantic meanings when calling
- // 'getSymbolKind' which is permissible given that it is backwards compatible; but
- // really we should consider passing the meaning for the node so that we don't report
- // that a suggestion for a value is an interface. We COULD also just do what
- // 'getSymbolModifiers' does, which is to use the first declaration.
- // Use a 'sortText' of 0' so that all symbol completion entries come before any other
- // entries (like JavaScript identifier entries).
- return {
- name: displayName,
- kind: getSymbolKind(symbol, typeChecker, location),
- kindModifiers: getSymbolModifiers(symbol),
- sortText: "0"
- };
- }
function getCompletionData(fileName, position) {
+ var typeChecker = program.getTypeChecker();
var syntacticStart = new Date().getTime();
var sourceFile = getValidSourceFile(fileName);
var start = new Date().getTime();
@@ -36342,26 +36397,26 @@ var ts;
isMemberCompletion = true;
isNewIdentifierLocation = false;
if (node.kind === 65 /* Identifier */ || node.kind === 126 /* QualifiedName */ || node.kind === 155 /* PropertyAccessExpression */) {
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
// This is an alias, follow what it aliases
if (symbol && symbol.flags & 8388608 /* Alias */) {
- symbol = typeInfoResolver.getAliasedSymbol(symbol);
+ symbol = typeChecker.getAliasedSymbol(symbol);
}
if (symbol && symbol.flags & 1952 /* HasExports */) {
// Extract module or enum members
- var exportedSymbols = typeInfoResolver.getExportsOfModule(symbol);
+ var exportedSymbols = typeChecker.getExportsOfModule(symbol);
ts.forEach(exportedSymbols, function (symbol) {
- if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) {
+ if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) {
symbols.push(symbol);
}
});
}
}
- var type = typeInfoResolver.getTypeAtLocation(node);
+ var type = typeChecker.getTypeAtLocation(node);
if (type) {
// Filter private properties
ts.forEach(type.getApparentProperties(), function (symbol) {
- if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) {
+ if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) {
symbols.push(symbol);
}
});
@@ -36373,11 +36428,11 @@ var ts;
// Object literal expression, look up possible property names from contextual type
isMemberCompletion = true;
isNewIdentifierLocation = true;
- var contextualType = typeInfoResolver.getContextualType(containingObjectLiteral);
+ var contextualType = typeChecker.getContextualType(containingObjectLiteral);
if (!contextualType) {
return false;
}
- var contextualTypeMembers = typeInfoResolver.getPropertiesOfType(contextualType);
+ var contextualTypeMembers = typeChecker.getPropertiesOfType(contextualType);
if (contextualTypeMembers && contextualTypeMembers.length > 0) {
// Add filtered items to the completion list
symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties);
@@ -36393,9 +36448,9 @@ var ts;
ts.Debug.assert(importDeclaration !== undefined);
var exports;
if (importDeclaration.moduleSpecifier) {
- var moduleSpecifierSymbol = typeInfoResolver.getSymbolAtLocation(importDeclaration.moduleSpecifier);
+ var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier);
if (moduleSpecifierSymbol) {
- exports = typeInfoResolver.getExportsOfModule(moduleSpecifierSymbol);
+ exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol);
}
}
//let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration);
@@ -36440,7 +36495,7 @@ var ts;
var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
/// TODO filter meaning based on the current context
var symbolMeanings = 793056 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 8388608 /* Alias */;
- symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings);
+ symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings);
}
return true;
}
@@ -36503,9 +36558,9 @@ var ts;
return containingNodeKind === 171 /* TemplateExpression */; // `aa ${|
case 12 /* TemplateMiddle */:
return containingNodeKind === 176 /* TemplateSpan */; // `aa ${10} dd ${|
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
return containingNodeKind === 132 /* PropertyDeclaration */; // class A{ public |
}
// Previous token may have been a keyword that was converted to an identifier.
@@ -36595,6 +36650,7 @@ var ts;
containingNodeKind === 150 /* ObjectBindingPattern */; // function func({ x|
case 22 /* SemicolonToken */:
return containingNodeKind === 131 /* PropertySignature */ &&
+ previousToken.parent && previousToken.parent.parent &&
(previousToken.parent.parent.kind === 202 /* InterfaceDeclaration */ ||
previousToken.parent.parent.kind === 145 /* TypeLiteral */); // let x : { a; |
case 24 /* LessThanToken */:
@@ -36602,27 +36658,28 @@ var ts;
containingNodeKind === 200 /* FunctionDeclaration */ ||
containingNodeKind === 202 /* InterfaceDeclaration */ ||
isFunction(containingNodeKind);
- case 110 /* StaticKeyword */:
+ case 109 /* StaticKeyword */:
return containingNodeKind === 132 /* PropertyDeclaration */;
case 21 /* DotDotDotToken */:
return containingNodeKind === 129 /* Parameter */ ||
containingNodeKind === 135 /* Constructor */ ||
- (previousToken.parent.parent.kind === 151 /* ArrayBindingPattern */); // var [ ...z|
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
+ (previousToken.parent && previousToken.parent.parent &&
+ previousToken.parent.parent.kind === 151 /* ArrayBindingPattern */); // var [ ...z|
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
return containingNodeKind === 129 /* Parameter */;
case 69 /* ClassKeyword */:
case 77 /* EnumKeyword */:
- case 104 /* InterfaceKeyword */:
+ case 103 /* InterfaceKeyword */:
case 83 /* FunctionKeyword */:
case 98 /* VarKeyword */:
case 116 /* GetKeyword */:
case 120 /* SetKeyword */:
case 85 /* ImportKeyword */:
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
case 70 /* ConstKeyword */:
- case 111 /* YieldKeyword */:
+ case 110 /* YieldKeyword */:
return true;
}
// Previous token may have been a keyword that was converted to an identifier.
@@ -36699,7 +36756,7 @@ var ts;
}
var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot;
var entries;
- if (isRightOfDot && isJavaScript(fileName)) {
+ if (isRightOfDot && ts.isJavaScript(fileName)) {
entries = getCompletionEntriesFromSymbols(symbols);
ts.addRange(entries, getJavaScriptCompletionEntries());
}
@@ -36721,10 +36778,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_23 in nameTable) {
- if (!allNames[name_23]) {
- allNames[name_23] = name_23;
- var displayName = getCompletionEntryDisplayName(name_23, target, true);
+ for (var name_24 in nameTable) {
+ if (!allNames[name_24]) {
+ allNames[name_24] = name_24;
+ var displayName = getCompletionEntryDisplayName(name_24, target, true);
if (displayName) {
var entry = {
name: displayName,
@@ -36739,6 +36796,28 @@ var ts;
}
return entries;
}
+ function createCompletionEntry(symbol, location) {
+ // Try to get a valid display name for this symbol, if we could not find one, then ignore it.
+ // We would like to only show things that can be added after a dot, so for instance numeric properties can
+ // not be accessed with a dot (a.1 <- invalid)
+ var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true);
+ if (!displayName) {
+ return undefined;
+ }
+ // TODO(drosen): Right now we just permit *all* semantic meanings when calling
+ // 'getSymbolKind' which is permissible given that it is backwards compatible; but
+ // really we should consider passing the meaning for the node so that we don't report
+ // that a suggestion for a value is an interface. We COULD also just do what
+ // 'getSymbolModifiers' does, which is to use the first declaration.
+ // Use a 'sortText' of 0' so that all symbol completion entries come before any other
+ // entries (like JavaScript identifier entries).
+ return {
+ name: displayName,
+ kind: getSymbolKind(symbol, location),
+ kindModifiers: getSymbolModifiers(symbol),
+ sortText: "0"
+ };
+ }
function getCompletionEntriesFromSymbols(symbols) {
var start = new Date().getTime();
var entries = [];
@@ -36746,7 +36825,7 @@ var ts;
var nameToSymbol = {};
for (var _i = 0; _i < symbols.length; _i++) {
var symbol = symbols[_i];
- var entry = createCompletionEntry(symbol, typeInfoResolver, location);
+ var entry = createCompletionEntry(symbol, location);
if (entry) {
var id = ts.escapeIdentifier(entry.name);
if (!ts.lookUp(nameToSymbol, id)) {
@@ -36773,7 +36852,7 @@ var ts;
// completion entry.
var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false) === entryName ? s : undefined; });
if (symbol) {
- var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, typeInfoResolver, location_2, 7 /* All */);
+ var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */);
return {
name: entryName,
kind: displayPartsDocumentationsAndSymbolKind.symbolKind,
@@ -36797,7 +36876,7 @@ var ts;
return undefined;
}
// TODO(drosen): use contextual SemanticMeaning.
- function getSymbolKind(symbol, typeResolver, location) {
+ function getSymbolKind(symbol, location) {
var flags = symbol.getFlags();
if (flags & 32 /* Class */)
return ScriptElementKind.classElement;
@@ -36809,7 +36888,7 @@ var ts;
return ScriptElementKind.interfaceElement;
if (flags & 262144 /* TypeParameter */)
return ScriptElementKind.typeParameterElement;
- var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver, location);
+ var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location);
if (result === ScriptElementKind.unknown) {
if (flags & 262144 /* TypeParameter */)
return ScriptElementKind.typeParameterElement;
@@ -36822,11 +36901,12 @@ var ts;
}
return result;
}
- function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver, location) {
- if (typeResolver.isUndefinedSymbol(symbol)) {
+ function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location) {
+ var typeChecker = program.getTypeChecker();
+ if (typeChecker.isUndefinedSymbol(symbol)) {
return ScriptElementKind.variableElement;
}
- if (typeResolver.isArgumentsSymbol(symbol)) {
+ if (typeChecker.isArgumentsSymbol(symbol)) {
return ScriptElementKind.localVariableElement;
}
if (flags & 3 /* Variable */) {
@@ -36854,7 +36934,7 @@ var ts;
if (flags & 4 /* Property */) {
if (flags & 268435456 /* UnionProperty */) {
// If union property is result of union of non method (property/accessors/variables), it is labeled as property
- var unionPropertyKind = ts.forEach(typeInfoResolver.getRootSymbols(symbol), function (rootSymbol) {
+ var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) {
var rootSymbolFlags = rootSymbol.getFlags();
if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) {
return ScriptElementKind.memberVariableElement;
@@ -36864,7 +36944,7 @@ var ts;
if (!unionPropertyKind) {
// If this was union of all methods,
//make sure it has call signatures before we can label it as method
- var typeOfUnionProperty = typeInfoResolver.getTypeOfSymbolAtLocation(symbol, location);
+ var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (typeOfUnionProperty.getCallSignatures().length) {
return ScriptElementKind.memberFunctionElement;
}
@@ -36897,14 +36977,14 @@ var ts;
? ts.getNodeModifiers(symbol.declarations[0])
: ScriptElementKindModifier.none;
}
- function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, typeResolver, location,
- // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location
- semanticMeaning) {
+ // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location
+ function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) {
if (semanticMeaning === void 0) { semanticMeaning = getMeaningFromLocation(location); }
+ var typeChecker = program.getTypeChecker();
var displayParts = [];
var documentation;
var symbolFlags = symbol.flags;
- var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver, location);
+ var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location);
var hasAddedSymbolInfo;
var type;
// Class at constructor site need to be shown as constructor apart from property,method, vars
@@ -36914,7 +36994,7 @@ var ts;
symbolKind = ScriptElementKind.memberVariableElement;
}
var signature;
- type = typeResolver.getTypeOfSymbolAtLocation(symbol, location);
+ type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (type) {
if (location.parent && location.parent.kind === 155 /* PropertyAccessExpression */) {
var right = location.parent.name;
@@ -36933,7 +37013,7 @@ var ts;
}
if (callExpression) {
var candidateSignatures = [];
- signature = typeResolver.getResolvedSignature(callExpression, candidateSignatures);
+ signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures);
if (!signature && candidateSignatures.length) {
// Use the first candidate:
signature = candidateSignatures[0];
@@ -36978,7 +37058,7 @@ var ts;
displayParts.push(ts.spacePart());
}
if (!(type.flags & 32768 /* Anonymous */)) {
- displayParts.push.apply(displayParts, ts.symbolToDisplayParts(typeResolver, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */));
+ displayParts.push.apply(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */));
}
addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */);
break;
@@ -36994,8 +37074,8 @@ var ts;
// get the signature from the declaration and write it
var functionDeclaration = location.parent;
var allSignatures = functionDeclaration.kind === 135 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures();
- if (!typeResolver.isImplementationOfOverload(functionDeclaration)) {
- signature = typeResolver.getSignatureFromDeclaration(functionDeclaration);
+ if (!typeChecker.isImplementationOfOverload(functionDeclaration)) {
+ signature = typeChecker.getSignatureFromDeclaration(functionDeclaration);
}
else {
signature = allSignatures[0];
@@ -37023,7 +37103,7 @@ var ts;
}
if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) {
addNewLineIfDisplayPartsExist();
- displayParts.push(ts.keywordPart(104 /* InterfaceKeyword */));
+ displayParts.push(ts.keywordPart(103 /* InterfaceKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
@@ -37036,7 +37116,7 @@ var ts;
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(53 /* EqualsToken */));
displayParts.push(ts.spacePart());
- displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
+ displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
}
if (symbolFlags & 384 /* Enum */) {
addNewLineIfDisplayPartsExist();
@@ -37072,7 +37152,7 @@ var ts;
else {
// Method/function type parameter
var signatureDeclaration = ts.getDeclarationOfKind(symbol, 128 /* TypeParameter */).parent;
- var signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration);
+ var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
if (signatureDeclaration.kind === 139 /* ConstructSignature */) {
displayParts.push(ts.keywordPart(88 /* NewKeyword */));
displayParts.push(ts.spacePart());
@@ -37080,14 +37160,14 @@ var ts;
else if (signatureDeclaration.kind !== 138 /* CallSignature */ && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
- displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
+ displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
}
}
if (symbolFlags & 8 /* EnumMember */) {
addPrefixForAnyFunctionOrVar(symbol, "enum member");
var declaration = symbol.declarations[0];
if (declaration.kind === 226 /* EnumMember */) {
- var constantValue = typeResolver.getConstantValue(declaration);
+ var constantValue = typeChecker.getConstantValue(declaration);
if (constantValue !== undefined) {
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(53 /* EqualsToken */));
@@ -37114,7 +37194,7 @@ var ts;
displayParts.push(ts.punctuationPart(17 /* CloseParenToken */));
}
else {
- var internalAliasSymbol = typeResolver.getSymbolAtLocation(importEqualsDeclaration.moduleReference);
+ var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference);
if (internalAliasSymbol) {
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(53 /* EqualsToken */));
@@ -37139,12 +37219,12 @@ var ts;
// If the type is type parameter, format it specially
if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
- typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration);
+ typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration);
});
displayParts.push.apply(displayParts, typeParameterParts);
}
else {
- displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, type, enclosingDeclaration));
+ displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration));
}
}
else if (symbolFlags & 16 /* Function */ ||
@@ -37159,7 +37239,7 @@ var ts;
}
}
else {
- symbolKind = getSymbolKind(symbol, typeResolver, location);
+ symbolKind = getSymbolKind(symbol, location);
}
}
if (!documentation) {
@@ -37172,7 +37252,7 @@ var ts;
}
}
function addFullSymbolName(symbol, enclosingDeclaration) {
- var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeResolver, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */);
+ var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */);
displayParts.push.apply(displayParts, fullSymbolDisplayParts);
}
function addPrefixForAnyFunctionOrVar(symbol, symbolKind) {
@@ -37200,7 +37280,7 @@ var ts;
}
}
function addSignatureDisplayParts(signature, allSignatures, flags) {
- displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */));
+ displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */));
if (allSignatures.length > 1) {
displayParts.push(ts.spacePart());
displayParts.push(ts.punctuationPart(16 /* OpenParenToken */));
@@ -37214,7 +37294,7 @@ var ts;
}
function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
- typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration);
+ typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration);
});
displayParts.push.apply(displayParts, typeParameterParts);
}
@@ -37226,7 +37306,11 @@ var ts;
if (!node) {
return undefined;
}
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ if (isLabelName(node)) {
+ return undefined;
+ }
+ var typeChecker = program.getTypeChecker();
+ var symbol = typeChecker.getSymbolAtLocation(node);
if (!symbol) {
// Try getting just type at this position and show
switch (node.kind) {
@@ -37236,20 +37320,20 @@ var ts;
case 93 /* ThisKeyword */:
case 91 /* SuperKeyword */:
// For the identifiers/this/super etc get the type at position
- var type = typeInfoResolver.getTypeAtLocation(node);
+ var type = typeChecker.getTypeAtLocation(node);
if (type) {
return {
kind: ScriptElementKind.unknown,
kindModifiers: ScriptElementKindModifier.none,
textSpan: ts.createTextSpan(node.getStart(), node.getWidth()),
- displayParts: ts.typeToDisplayParts(typeInfoResolver, type, getContainerNode(node)),
+ displayParts: ts.typeToDisplayParts(typeChecker, type, getContainerNode(node)),
documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined
};
}
}
return undefined;
}
- var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), typeInfoResolver, node);
+ var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), node);
return {
kind: displayPartsDocumentationsAndKind.symbolKind,
kindModifiers: getSymbolModifiers(symbol),
@@ -37298,7 +37382,8 @@ var ts;
}
return undefined;
}
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var typeChecker = program.getTypeChecker();
+ var symbol = typeChecker.getSymbolAtLocation(node);
// Could not find a symbol e.g. node is string or number keyword,
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
if (!symbol) {
@@ -37311,7 +37396,7 @@ var ts;
if (symbol.flags & 8388608 /* Alias */) {
var declaration = symbol.declarations[0];
if (node.kind === 65 /* Identifier */ && node.parent === declaration) {
- symbol = typeInfoResolver.getAliasedSymbol(symbol);
+ symbol = typeChecker.getAliasedSymbol(symbol);
}
}
// Because name in short-hand property assignment has two different meanings: property name and property value,
@@ -37320,22 +37405,22 @@ var ts;
// is performed at the location of property access, we would like to go to definition of the property in the short-hand
// assignment. This case and others are handled by the following code.
if (node.parent.kind === 225 /* ShorthandPropertyAssignment */) {
- var shorthandSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
+ var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
if (!shorthandSymbol) {
return [];
}
var shorthandDeclarations = shorthandSymbol.getDeclarations();
- var shorthandSymbolKind = getSymbolKind(shorthandSymbol, typeInfoResolver, node);
- var shorthandSymbolName = typeInfoResolver.symbolToString(shorthandSymbol);
- var shorthandContainerName = typeInfoResolver.symbolToString(symbol.parent, node);
+ var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node);
+ var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol);
+ var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node);
return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); });
}
var result = [];
var declarations = symbol.getDeclarations();
- var symbolName = typeInfoResolver.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
- var symbolKind = getSymbolKind(symbol, typeInfoResolver, node);
+ var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
+ var symbolKind = getSymbolKind(symbol, node);
var containerSymbol = symbol.parent;
- var containerName = containerSymbol ? typeInfoResolver.symbolToString(containerSymbol, node) : "";
+ var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
// Just add all the declarations.
@@ -37390,7 +37475,7 @@ var ts;
var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName));
// Get occurrences only supports reporting occurrences for the file queried. So
// filter down to that list.
- results = ts.filter(results, function (r) { return r.fileName === fileName; });
+ results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; });
}
return results;
}
@@ -37653,7 +37738,7 @@ var ts;
return undefined;
}
}
- else if (modifier === 110 /* StaticKeyword */) {
+ else if (modifier === 109 /* StaticKeyword */) {
if (container.kind !== 201 /* ClassDeclaration */) {
return undefined;
}
@@ -37702,13 +37787,13 @@ var ts;
return ts.map(keywords, getHighlightSpanForNode);
function getFlagFromModifier(modifier) {
switch (modifier) {
- case 109 /* PublicKeyword */:
+ case 108 /* PublicKeyword */:
return 16 /* Public */;
- case 107 /* PrivateKeyword */:
+ case 106 /* PrivateKeyword */:
return 32 /* Private */;
- case 108 /* ProtectedKeyword */:
+ case 107 /* ProtectedKeyword */:
return 64 /* Protected */;
- case 110 /* StaticKeyword */:
+ case 109 /* StaticKeyword */:
return 128 /* Static */;
case 78 /* ExportKeyword */:
return 1 /* Export */;
@@ -37969,6 +38054,7 @@ var ts;
return getReferencedSymbolsForNodes(node, program.getSourceFiles(), findInStrings, findInComments);
}
function getReferencedSymbolsForNodes(node, sourceFiles, findInStrings, findInComments) {
+ var typeChecker = program.getTypeChecker();
// Labels
if (isLabelName(node)) {
if (isJumpStatementTarget(node)) {
@@ -37988,7 +38074,7 @@ var ts;
if (node.kind === 91 /* SuperKeyword */) {
return getReferencesForSuperKeyword(node);
}
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
// Could not find a symbol e.g. unknown identifier
if (!symbol) {
// Can't have references to something that we have no symbol for.
@@ -38027,7 +38113,7 @@ var ts;
}
return result;
function getDefinition(symbol) {
- var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), typeInfoResolver, node);
+ var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node);
var name = ts.map(info.displayParts, function (p) { return p.text; }).join("");
var declarations = symbol.declarations;
if (!declarations || declarations.length === 0) {
@@ -38070,7 +38156,7 @@ var ts;
if (isImportOrExportSpecifierName(location)) {
return location.getText();
}
- name = typeInfoResolver.symbolToString(symbol);
+ name = typeChecker.symbolToString(symbol);
return stripQuotes(name);
}
function getInternedName(symbol, location, declarations) {
@@ -38258,10 +38344,10 @@ var ts;
if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) {
return;
}
- var referenceSymbol = typeInfoResolver.getSymbolAtLocation(referenceLocation);
+ var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation);
if (referenceSymbol) {
var referenceSymbolDeclaration = referenceSymbol.valueDeclaration;
- var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
+ var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation);
if (relatedSymbol) {
var referencedSymbol = getReferencedSymbol(relatedSymbol);
@@ -38450,14 +38536,14 @@ var ts;
var result = [symbol];
// If the symbol is an alias, add what it alaises to the list
if (isImportOrExportSpecifierImportSymbol(symbol)) {
- result.push(typeInfoResolver.getAliasedSymbol(symbol));
+ result.push(typeChecker.getAliasedSymbol(symbol));
}
// If the location is in a context sensitive location (i.e. in an object literal) try
// to get a contextual type for it, and add the property symbol from the contextual
// type to the search set
if (isNameOfPropertyAssignment(location)) {
ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) {
- result.push.apply(result, typeInfoResolver.getRootSymbols(contextualSymbol));
+ result.push.apply(result, typeChecker.getRootSymbols(contextualSymbol));
});
/* Because in short-hand property assignment, location has two meaning : property name and as value of the property
* When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of
@@ -38470,14 +38556,14 @@ var ts;
* so that when matching with potential reference symbol, both symbols from property declaration and variable declaration
* will be included correctly.
*/
- var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(location.parent);
+ var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent);
if (shorthandValueSymbol) {
result.push(shorthandValueSymbol);
}
}
// If this is a union property, add all the symbols from all its source symbols in all unioned types.
// If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list
- ts.forEach(typeInfoResolver.getRootSymbols(symbol), function (rootSymbol) {
+ ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) {
if (rootSymbol !== symbol) {
result.push(rootSymbol);
}
@@ -38503,9 +38589,9 @@ var ts;
return;
function getPropertySymbolFromTypeReference(typeReference) {
if (typeReference) {
- var type = typeInfoResolver.getTypeAtLocation(typeReference);
+ var type = typeChecker.getTypeAtLocation(typeReference);
if (type) {
- var propertySymbol = typeInfoResolver.getPropertyOfType(type, propertyName);
+ var propertySymbol = typeChecker.getPropertyOfType(type, propertyName);
if (propertySymbol) {
result.push(propertySymbol);
}
@@ -38522,7 +38608,7 @@ var ts;
// If the reference symbol is an alias, check if what it is aliasing is one of the search
// symbols.
if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) {
- var aliasedSymbol = typeInfoResolver.getAliasedSymbol(referenceSymbol);
+ var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol);
if (searchSymbols.indexOf(aliasedSymbol) >= 0) {
return aliasedSymbol;
}
@@ -38532,12 +38618,12 @@ var ts;
// compare to our searchSymbol
if (isNameOfPropertyAssignment(referenceLocation)) {
return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) {
- return ts.forEach(typeInfoResolver.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
+ return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
});
}
// Unwrap symbols to get to the root (e.g. transient symbols as a result of widening)
// Or a union property, use its underlying unioned symbols
- return ts.forEach(typeInfoResolver.getRootSymbols(referenceSymbol), function (rootSymbol) {
+ return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) {
// if it is in the list, then we are done
if (searchSymbols.indexOf(rootSymbol) >= 0) {
return rootSymbol;
@@ -38545,9 +38631,9 @@ var ts;
// Finally, try all properties with the same name in any type the containing type extended or implemented, and
// see if any is in the list
if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) {
- var result_2 = [];
- getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_2);
- return ts.forEach(result_2, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
+ var result_3 = [];
+ getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3);
+ return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
}
return undefined;
});
@@ -38555,29 +38641,29 @@ var ts;
function getPropertySymbolsFromContextualType(node) {
if (isNameOfPropertyAssignment(node)) {
var objectLiteral = node.parent.parent;
- var contextualType = typeInfoResolver.getContextualType(objectLiteral);
- var name_24 = node.text;
+ var contextualType = typeChecker.getContextualType(objectLiteral);
+ var name_25 = 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_24);
+ var unionProperty = contextualType.getProperty(name_25);
if (unionProperty) {
return [unionProperty];
}
else {
- var result_3 = [];
+ var result_4 = [];
ts.forEach(contextualType.types, function (t) {
- var symbol = t.getProperty(name_24);
+ var symbol = t.getProperty(name_25);
if (symbol) {
- result_3.push(symbol);
+ result_4.push(symbol);
}
});
- return result_3;
+ return result_4;
}
}
else {
- var symbol_1 = contextualType.getProperty(name_24);
+ var symbol_1 = contextualType.getProperty(name_25);
if (symbol_1) {
return [symbol_1];
}
@@ -38742,7 +38828,7 @@ var ts;
}
if (!isLastClause && root.parent.kind === 177 /* HeritageClauseElement */ && root.parent.parent.kind === 222 /* HeritageClause */) {
var decl = root.parent.parent.parent;
- return (decl.kind === 201 /* ClassDeclaration */ && root.parent.parent.token === 103 /* ImplementsKeyword */) ||
+ return (decl.kind === 201 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) ||
(decl.kind === 202 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */);
}
return false;
@@ -38803,7 +38889,7 @@ var ts;
function getSignatureHelpItems(fileName, position) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
- return ts.SignatureHelp.getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken);
+ return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken);
}
/// Syntactic features
function getSourceFile(fileName) {
@@ -38870,6 +38956,7 @@ var ts;
function getSemanticClassifications(fileName, span) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
+ var typeChecker = program.getTypeChecker();
var result = [];
processNode(sourceFile);
return result;
@@ -38915,7 +39002,7 @@ var ts;
// Only walk into nodes that intersect the requested span.
if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) {
if (node.kind === 65 /* Identifier */ && node.getWidth() > 0) {
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
if (symbol) {
var type = classifySymbol(symbol, getMeaningFromLocation(node));
if (type) {
@@ -39327,10 +39414,11 @@ var ts;
function getRenameInfo(fileName, position) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
+ var typeChecker = program.getTypeChecker();
var node = ts.getTouchingWord(sourceFile, position);
// Can only rename an identifier.
if (node && node.kind === 65 /* Identifier */) {
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
// Only allow a symbol to be renamed if it actually has at least one declaration.
if (symbol) {
var declarations = symbol.getDeclarations();
@@ -39340,19 +39428,19 @@ var ts;
if (defaultLibFileName) {
for (var _i = 0; _i < declarations.length; _i++) {
var current = declarations[_i];
- var sourceFile_1 = current.getSourceFile();
- if (sourceFile_1 && getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) {
+ var sourceFile_2 = current.getSourceFile();
+ if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) {
return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key));
}
}
}
- var kind = getSymbolKind(symbol, typeInfoResolver, node);
+ var kind = getSymbolKind(symbol, node);
if (kind) {
return {
canRename: true,
localizedErrorMessage: undefined,
displayName: symbol.name,
- fullDisplayName: typeInfoResolver.getFullyQualifiedName(symbol),
+ fullDisplayName: typeChecker.getFullyQualifiedName(symbol),
kind: kind,
kindModifiers: getSymbolModifiers(symbol),
triggerSpan: ts.createTextSpan(node.getStart(), node.getWidth())
@@ -39497,7 +39585,7 @@ var ts;
if (keyword2 === 116 /* GetKeyword */ ||
keyword2 === 120 /* SetKeyword */ ||
keyword2 === 114 /* ConstructorKeyword */ ||
- keyword2 === 110 /* StaticKeyword */) {
+ keyword2 === 109 /* StaticKeyword */) {
// Allow things like "public get", "public constructor" and "public static".
// These are all legal.
return true;
diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts
index 9e9df4fdc78..8903e33391b 100644
--- a/bin/typescriptServices.d.ts
+++ b/bin/typescriptServices.d.ts
@@ -124,16 +124,16 @@ declare module ts {
VoidKeyword = 99,
WhileKeyword = 100,
WithKeyword = 101,
- AsKeyword = 102,
- ImplementsKeyword = 103,
- InterfaceKeyword = 104,
- LetKeyword = 105,
- PackageKeyword = 106,
- PrivateKeyword = 107,
- ProtectedKeyword = 108,
- PublicKeyword = 109,
- StaticKeyword = 110,
- YieldKeyword = 111,
+ ImplementsKeyword = 102,
+ InterfaceKeyword = 103,
+ LetKeyword = 104,
+ PackageKeyword = 105,
+ PrivateKeyword = 106,
+ ProtectedKeyword = 107,
+ PublicKeyword = 108,
+ StaticKeyword = 109,
+ YieldKeyword = 110,
+ AsKeyword = 111,
AnyKeyword = 112,
BooleanKeyword = 113,
ConstructorKeyword = 114,
@@ -258,8 +258,8 @@ declare module ts {
LastReservedWord = 101,
FirstKeyword = 66,
LastKeyword = 125,
- FirstFutureReservedWord = 103,
- LastFutureReservedWord = 111,
+ FirstFutureReservedWord = 102,
+ LastFutureReservedWord = 110,
FirstTypeNode = 141,
LastTypeNode = 149,
FirstPunctuation = 14,
@@ -1183,6 +1183,7 @@ declare module ts {
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
}
declare module ts {
+ function getDefaultLibFileName(options: CompilerOptions): string;
function textSpanEnd(span: TextSpan): number;
function textSpanIsEmpty(span: TextSpan): boolean;
function textSpanContainsPosition(span: TextSpan, position: number): boolean;
@@ -1227,7 +1228,6 @@ 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 {
@@ -1289,7 +1289,6 @@ declare module ts {
getDocumentationComment(): SymbolDisplayPart[];
}
interface SourceFile {
- getNamedDeclarations(): Declaration[];
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionOfLineAndCharacter(line: number, character: number): number;
diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js
index 4544cc24ec1..57271ad41ac 100644
--- a/bin/typescriptServices.js
+++ b/bin/typescriptServices.js
@@ -128,17 +128,17 @@ var ts;
SyntaxKind[SyntaxKind["WhileKeyword"] = 100] = "WhileKeyword";
SyntaxKind[SyntaxKind["WithKeyword"] = 101] = "WithKeyword";
// Strict mode reserved words
- SyntaxKind[SyntaxKind["AsKeyword"] = 102] = "AsKeyword";
- SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword";
- SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword";
- SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword";
- SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword";
- SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword";
- SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword";
- SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword";
- SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword";
- SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword";
+ SyntaxKind[SyntaxKind["ImplementsKeyword"] = 102] = "ImplementsKeyword";
+ SyntaxKind[SyntaxKind["InterfaceKeyword"] = 103] = "InterfaceKeyword";
+ SyntaxKind[SyntaxKind["LetKeyword"] = 104] = "LetKeyword";
+ SyntaxKind[SyntaxKind["PackageKeyword"] = 105] = "PackageKeyword";
+ SyntaxKind[SyntaxKind["PrivateKeyword"] = 106] = "PrivateKeyword";
+ SyntaxKind[SyntaxKind["ProtectedKeyword"] = 107] = "ProtectedKeyword";
+ SyntaxKind[SyntaxKind["PublicKeyword"] = 108] = "PublicKeyword";
+ SyntaxKind[SyntaxKind["StaticKeyword"] = 109] = "StaticKeyword";
+ SyntaxKind[SyntaxKind["YieldKeyword"] = 110] = "YieldKeyword";
// Contextual keywords
+ SyntaxKind[SyntaxKind["AsKeyword"] = 111] = "AsKeyword";
SyntaxKind[SyntaxKind["AnyKeyword"] = 112] = "AnyKeyword";
SyntaxKind[SyntaxKind["BooleanKeyword"] = 113] = "BooleanKeyword";
SyntaxKind[SyntaxKind["ConstructorKeyword"] = 114] = "ConstructorKeyword";
@@ -280,8 +280,8 @@ var ts;
SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord";
SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword";
SyntaxKind[SyntaxKind["LastKeyword"] = 125] = "LastKeyword";
- SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord";
- SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord";
+ SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord";
+ SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord";
SyntaxKind[SyntaxKind["FirstTypeNode"] = 141] = "FirstTypeNode";
SyntaxKind[SyntaxKind["LastTypeNode"] = 149] = "LastTypeNode";
SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation";
@@ -2178,7 +2178,7 @@ var ts;
(function (ts) {
var textToToken = {
"any": 112 /* AnyKeyword */,
- "as": 102 /* AsKeyword */,
+ "as": 111 /* AsKeyword */,
"boolean": 113 /* BooleanKeyword */,
"break": 66 /* BreakKeyword */,
"case": 67 /* CaseKeyword */,
@@ -2203,24 +2203,24 @@ var ts;
"function": 83 /* FunctionKeyword */,
"get": 116 /* GetKeyword */,
"if": 84 /* IfKeyword */,
- "implements": 103 /* ImplementsKeyword */,
+ "implements": 102 /* ImplementsKeyword */,
"import": 85 /* ImportKeyword */,
"in": 86 /* InKeyword */,
"instanceof": 87 /* InstanceOfKeyword */,
- "interface": 104 /* InterfaceKeyword */,
- "let": 105 /* LetKeyword */,
+ "interface": 103 /* InterfaceKeyword */,
+ "let": 104 /* LetKeyword */,
"module": 117 /* ModuleKeyword */,
"new": 88 /* NewKeyword */,
"null": 89 /* NullKeyword */,
"number": 119 /* NumberKeyword */,
- "package": 106 /* PackageKeyword */,
- "private": 107 /* PrivateKeyword */,
- "protected": 108 /* ProtectedKeyword */,
- "public": 109 /* PublicKeyword */,
+ "package": 105 /* PackageKeyword */,
+ "private": 106 /* PrivateKeyword */,
+ "protected": 107 /* ProtectedKeyword */,
+ "public": 108 /* PublicKeyword */,
"require": 118 /* RequireKeyword */,
"return": 90 /* ReturnKeyword */,
"set": 120 /* SetKeyword */,
- "static": 110 /* StaticKeyword */,
+ "static": 109 /* StaticKeyword */,
"string": 121 /* StringKeyword */,
"super": 91 /* SuperKeyword */,
"switch": 92 /* SwitchKeyword */,
@@ -2235,7 +2235,7 @@ var ts;
"void": 99 /* VoidKeyword */,
"while": 100 /* WhileKeyword */,
"with": 101 /* WithKeyword */,
- "yield": 111 /* YieldKeyword */,
+ "yield": 110 /* YieldKeyword */,
"of": 125 /* OfKeyword */,
"{": 14 /* OpenBraceToken */,
"}": 15 /* CloseBraceToken */,
@@ -5027,7 +5027,7 @@ var ts;
}
ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement;
function getClassImplementsHeritageClauseElements(node) {
- var heritageClause = getHeritageClause(node.heritageClauses, 103 /* ImplementsKeyword */);
+ var heritageClause = getHeritageClause(node.heritageClauses, 102 /* ImplementsKeyword */);
return heritageClause ? heritageClause.types : undefined;
}
ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements;
@@ -5157,10 +5157,10 @@ var ts;
ts.isESSymbolIdentifier = isESSymbolIdentifier;
function isModifier(token) {
switch (token) {
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
- case 110 /* StaticKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
+ case 109 /* StaticKeyword */:
case 78 /* ExportKeyword */:
case 115 /* DeclareKeyword */:
case 70 /* ConstKeyword */:
@@ -5609,6 +5609,10 @@ var ts;
})(ts || (ts = {}));
var ts;
(function (ts) {
+ function getDefaultLibFileName(options) {
+ return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts";
+ }
+ ts.getDefaultLibFileName = getDefaultLibFileName;
function textSpanEnd(span) {
return span.start + span.length;
}
@@ -6185,10 +6189,10 @@ var ts;
;
function modifierToFlag(token) {
switch (token) {
- case 110 /* StaticKeyword */: return 128 /* Static */;
- case 109 /* PublicKeyword */: return 16 /* Public */;
- case 108 /* ProtectedKeyword */: return 64 /* Protected */;
- case 107 /* PrivateKeyword */: return 32 /* Private */;
+ case 109 /* StaticKeyword */: return 128 /* Static */;
+ case 108 /* PublicKeyword */: return 16 /* Public */;
+ case 107 /* ProtectedKeyword */: return 64 /* Protected */;
+ case 106 /* PrivateKeyword */: return 32 /* Private */;
case 78 /* ExportKeyword */: return 1 /* Export */;
case 115 /* DeclareKeyword */: return 2 /* Ambient */;
case 70 /* ConstKeyword */: return 8192 /* Const */;
@@ -7004,7 +7008,7 @@ var ts;
}
// If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is
// considered a keyword and is not an identifier.
- if (token === 111 /* YieldKeyword */ && inYieldContext()) {
+ if (token === 110 /* YieldKeyword */ && inYieldContext()) {
return false;
}
return token > 101 /* LastReservedWord */;
@@ -7282,7 +7286,7 @@ var ts;
// extends {} extends
// extends {} implements
var next = nextToken();
- return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 79 /* ExtendsKeyword */ || next === 103 /* ImplementsKeyword */;
+ return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 79 /* ExtendsKeyword */ || next === 102 /* ImplementsKeyword */;
}
return true;
}
@@ -7291,7 +7295,7 @@ var ts;
return isIdentifier();
}
function isHeritageClauseExtendsOrImplementsKeyword() {
- if (token === 103 /* ImplementsKeyword */ ||
+ if (token === 102 /* ImplementsKeyword */ ||
token === 79 /* ExtendsKeyword */) {
return lookAhead(nextTokenIsStartOfExpression);
}
@@ -7321,12 +7325,12 @@ var ts;
case 4 /* SwitchClauseStatements */:
return token === 15 /* CloseBraceToken */ || token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */;
case 8 /* HeritageClauseElement */:
- return token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */;
+ return token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */;
case 9 /* VariableDeclarations */:
return isVariableDeclaratorListTerminator();
case 16 /* TypeParameters */:
// Tokens other than '>' are here for better error recovery
- return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */;
+ return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */;
case 12 /* ArgumentExpressions */:
// Tokens other than ')' are here for better error recovery
return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */;
@@ -8363,7 +8367,7 @@ var ts;
case 38 /* PlusPlusToken */:
case 39 /* MinusMinusToken */:
case 24 /* LessThanToken */:
- case 111 /* YieldKeyword */:
+ case 110 /* YieldKeyword */:
// Yield always starts an expression. Either it is an identifier (in which case
// it is definitely an expression). Or it's a keyword (either because we're in
// a generator, or in strict mode (or both)) and it started a yield expression.
@@ -8478,7 +8482,7 @@ var ts;
return parseConditionalExpressionRest(expr);
}
function isYieldExpression() {
- if (token === 111 /* YieldKeyword */) {
+ if (token === 110 /* YieldKeyword */) {
// If we have a 'yield' keyword, and htis is a context where yield expressions are
// allowed, then definitely parse out a yield expression.
if (inYieldContext()) {
@@ -9319,7 +9323,7 @@ var ts;
parseExpected(16 /* OpenParenToken */);
var initializer = undefined;
if (token !== 22 /* SemicolonToken */) {
- if (token === 98 /* VarKeyword */ || token === 105 /* LetKeyword */ || token === 70 /* ConstKeyword */) {
+ if (token === 98 /* VarKeyword */ || token === 104 /* LetKeyword */ || token === 70 /* ConstKeyword */) {
initializer = parseVariableDeclarationList(true);
}
else {
@@ -9503,7 +9507,7 @@ var ts;
return !inErrorRecovery;
case 14 /* OpenBraceToken */:
case 98 /* VarKeyword */:
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
case 83 /* FunctionKeyword */:
case 69 /* ClassKeyword */:
case 84 /* IfKeyword */:
@@ -9529,7 +9533,7 @@ var ts;
// In ES 6 'enum' is a future reserved keyword, so it should not be used as identifier
var isConstEnum = lookAhead(nextTokenIsEnumKeyword);
return !isConstEnum;
- case 104 /* InterfaceKeyword */:
+ case 103 /* InterfaceKeyword */:
case 117 /* ModuleKeyword */:
case 77 /* EnumKeyword */:
case 123 /* TypeKeyword */:
@@ -9538,10 +9542,10 @@ var ts;
if (isDeclarationStart()) {
return false;
}
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
- case 110 /* StaticKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
+ case 109 /* StaticKeyword */:
// When followed by an identifier or keyword, these do not start a statement but
// might instead be following type members
if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) {
@@ -9600,7 +9604,7 @@ var ts;
return parseTryStatement();
case 72 /* DebuggerKeyword */:
return parseDebuggerStatement();
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
// If let follows identifier on the same line, it is declaration parse it as variable statement
if (isLetDeclaration()) {
return parseVariableStatement(scanner.getStartPos(), undefined, undefined);
@@ -9635,7 +9639,7 @@ var ts;
return undefined;
}
return parseVariableStatement(start, decorators, modifiers);
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
if (!isLetDeclaration()) {
return undefined;
}
@@ -9722,7 +9726,7 @@ var ts;
switch (token) {
case 98 /* VarKeyword */:
break;
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
node.flags |= 4096 /* Let */;
break;
case 70 /* ConstKeyword */:
@@ -9832,10 +9836,10 @@ var ts;
}
function isClassMemberModifier(idToken) {
switch (idToken) {
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
- case 110 /* StaticKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
+ case 109 /* StaticKeyword */:
return true;
default:
return false;
@@ -10028,7 +10032,7 @@ var ts;
return parseList(19 /* HeritageClauses */, false, parseHeritageClause);
}
function parseHeritageClause() {
- if (token === 79 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */) {
+ if (token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */) {
var node = createNode(222 /* HeritageClause */);
node.token = token;
nextToken();
@@ -10046,7 +10050,7 @@ var ts;
return finishNode(node);
}
function isHeritageClause() {
- return token === 79 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */;
+ return token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */;
}
function parseClassMembers() {
return parseList(6 /* ClassMembers */, false, parseClassElement);
@@ -10055,7 +10059,7 @@ var ts;
var node = createNode(202 /* InterfaceDeclaration */, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
- parseExpected(104 /* InterfaceKeyword */);
+ parseExpected(103 /* InterfaceKeyword */);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
node.heritageClauses = parseHeritageClauses(false);
@@ -10234,7 +10238,7 @@ var ts;
// * as ImportedBinding
var namespaceImport = createNode(211 /* NamespaceImport */);
parseExpected(35 /* AsteriskToken */);
- parseExpected(102 /* AsKeyword */);
+ parseExpected(111 /* AsKeyword */);
namespaceImport.name = parseIdentifier();
return finishNode(namespaceImport);
}
@@ -10268,9 +10272,9 @@ var ts;
var checkIdentifierStart = scanner.getTokenPos();
var checkIdentifierEnd = scanner.getTextPos();
var identifierName = parseIdentifierName();
- if (token === 102 /* AsKeyword */) {
+ if (token === 111 /* AsKeyword */) {
node.propertyName = identifierName;
- parseExpected(102 /* AsKeyword */);
+ parseExpected(111 /* AsKeyword */);
checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier();
checkIdentifierStart = scanner.getTokenPos();
checkIdentifierEnd = scanner.getTextPos();
@@ -10327,10 +10331,10 @@ var ts;
case 70 /* ConstKeyword */:
case 83 /* FunctionKeyword */:
return true;
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
return isLetDeclaration();
case 69 /* ClassKeyword */:
- case 104 /* InterfaceKeyword */:
+ case 103 /* InterfaceKeyword */:
case 77 /* EnumKeyword */:
case 123 /* TypeKeyword */:
// Not true keywords so ensure an identifier follows
@@ -10345,10 +10349,10 @@ var ts;
// Check for export assignment or modifier on source element
return lookAhead(nextTokenCanFollowExportKeyword);
case 115 /* DeclareKeyword */:
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
- case 110 /* StaticKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
+ case 109 /* StaticKeyword */:
// Check for modifier on source element
return lookAhead(nextTokenIsDeclarationStart);
case 52 /* AtToken */:
@@ -10383,7 +10387,7 @@ var ts;
return isDeclarationStart(true);
}
function nextTokenIsAsKeyword() {
- return nextToken() === 102 /* AsKeyword */;
+ return nextToken() === 111 /* AsKeyword */;
}
function parseDeclaration() {
var fullStart = getNodePos();
@@ -10400,14 +10404,14 @@ var ts;
}
switch (token) {
case 98 /* VarKeyword */:
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
case 70 /* ConstKeyword */:
return parseVariableStatement(fullStart, decorators, modifiers);
case 83 /* FunctionKeyword */:
return parseFunctionDeclaration(fullStart, decorators, modifiers);
case 69 /* ClassKeyword */:
return parseClassDeclaration(fullStart, decorators, modifiers);
- case 104 /* InterfaceKeyword */:
+ case 103 /* InterfaceKeyword */:
return parseInterfaceDeclaration(fullStart, decorators, modifiers);
case 123 /* TypeKeyword */:
return parseTypeAliasDeclaration(fullStart, decorators, modifiers);
@@ -13228,15 +13232,16 @@ var ts;
return result;
}
function getPropertiesOfType(type) {
- if (type.flags & 16384 /* Union */) {
- return getPropertiesOfUnionType(type);
- }
- return getPropertiesOfObjectType(getApparentType(type));
+ type = getApparentType(type);
+ return type.flags & 16384 /* Union */ ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type);
}
// For a type parameter, return the base constraint of the type parameter. For the string, number,
// boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
// type itself. Note that the apparent type of a union type is the union type itself.
function getApparentType(type) {
+ if (type.flags & 16384 /* Union */) {
+ type = getReducedTypeOfUnionType(type);
+ }
if (type.flags & 512 /* TypeParameter */) {
do {
type = getConstraintOfTypeParameter(type);
@@ -13308,28 +13313,27 @@ var ts;
// necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from
// Object and Function as appropriate.
function getPropertyOfType(type, name) {
+ type = getApparentType(type);
+ if (type.flags & 48128 /* ObjectType */) {
+ var resolved = resolveObjectOrUnionTypeMembers(type);
+ if (ts.hasProperty(resolved.members, name)) {
+ var symbol = resolved.members[name];
+ if (symbolIsValue(symbol)) {
+ return symbol;
+ }
+ }
+ if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
+ var symbol = getPropertyOfObjectType(globalFunctionType, name);
+ if (symbol) {
+ return symbol;
+ }
+ }
+ return getPropertyOfObjectType(globalObjectType, name);
+ }
if (type.flags & 16384 /* Union */) {
return getPropertyOfUnionType(type, name);
}
- if (!(type.flags & 48128 /* ObjectType */)) {
- type = getApparentType(type);
- if (!(type.flags & 48128 /* ObjectType */)) {
- return undefined;
- }
- }
- var resolved = resolveObjectOrUnionTypeMembers(type);
- if (ts.hasProperty(resolved.members, name)) {
- var symbol = resolved.members[name];
- if (symbolIsValue(symbol)) {
- return symbol;
- }
- }
- if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
- var symbol = getPropertyOfObjectType(globalFunctionType, name);
- if (symbol)
- return symbol;
- }
- return getPropertyOfObjectType(globalObjectType, name);
+ return undefined;
}
function getSignaturesOfObjectOrUnionType(type, kind) {
if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) {
@@ -13852,6 +13856,10 @@ var ts;
}
}
}
+ // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag
+ // is true when creating a union type from a type node and when instantiating a union type. In both of those
+ // cases subtype reduction has to be deferred to properly support recursive union types. For example, a
+ // type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration.
function getUnionType(types, noSubtypeReduction) {
if (types.length === 0) {
return emptyObjectType;
@@ -13876,9 +13884,17 @@ var ts;
if (!type) {
type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(sortedTypes));
type.types = sortedTypes;
+ type.reducedType = noSubtypeReduction ? undefined : type;
}
return type;
}
+ function getReducedTypeOfUnionType(type) {
+ // If union type was created without subtype reduction, perform the deferred reduction now
+ if (!type.reducedType) {
+ type.reducedType = getUnionType(type.types, false);
+ }
+ return type.reducedType;
+ }
function getTypeFromUnionTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
@@ -19153,7 +19169,10 @@ var ts;
return checkElementTypeOfArrayOrString(inputType, errorNode);
}
if (isArrayLikeType(inputType)) {
- return getIndexTypeOfType(inputType, 1 /* Number */);
+ var indexType = getIndexTypeOfType(inputType, 1 /* Number */);
+ if (indexType) {
+ return indexType;
+ }
}
error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType));
return unknownType;
@@ -21385,7 +21404,7 @@ var ts;
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 */);
+ (node.originalKeywordKind >= 102 /* FirstFutureReservedWord */ && node.originalKeywordKind <= 110 /* 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.)
@@ -21565,14 +21584,14 @@ var ts;
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
var modifier = _a[_i];
switch (modifier.kind) {
- case 109 /* PublicKeyword */:
- case 108 /* ProtectedKeyword */:
- case 107 /* PrivateKeyword */:
+ case 108 /* PublicKeyword */:
+ case 107 /* ProtectedKeyword */:
+ case 106 /* PrivateKeyword */:
var text = void 0;
- if (modifier.kind === 109 /* PublicKeyword */) {
+ if (modifier.kind === 108 /* PublicKeyword */) {
text = "public";
}
- else if (modifier.kind === 108 /* ProtectedKeyword */) {
+ else if (modifier.kind === 107 /* ProtectedKeyword */) {
text = "protected";
lastProtected = modifier;
}
@@ -21591,7 +21610,7 @@ var ts;
}
flags |= ts.modifierToFlag(modifier.kind);
break;
- case 110 /* StaticKeyword */:
+ case 109 /* StaticKeyword */:
if (flags & 128 /* Static */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
}
@@ -21823,7 +21842,7 @@ var ts;
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */);
+ ts.Debug.assert(heritageClause.token === 102 /* ImplementsKeyword */);
if (seenImplementsClause) {
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
}
@@ -21846,7 +21865,7 @@ var ts;
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */);
+ ts.Debug.assert(heritageClause.token === 102 /* ImplementsKeyword */);
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
}
// Grammar checking heritageClause inside class declaration
@@ -24947,7 +24966,7 @@ var ts;
emit(node.expression);
}
function emitYieldExpression(node) {
- write(ts.tokenToString(111 /* YieldKeyword */));
+ write(ts.tokenToString(110 /* YieldKeyword */));
if (node.asteriskToken) {
write("*");
}
@@ -25638,7 +25657,7 @@ var ts;
var tokenKind = 98 /* VarKeyword */;
if (decl && languageVersion >= 2 /* ES6 */) {
if (ts.isLet(decl)) {
- tokenKind = 105 /* LetKeyword */;
+ tokenKind = 104 /* LetKeyword */;
}
else if (ts.isConst(decl)) {
tokenKind = 70 /* ConstKeyword */;
@@ -25651,7 +25670,7 @@ var ts;
switch (tokenKind) {
case 98 /* VarKeyword */:
return write("var ");
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
return write("let ");
case 70 /* ConstKeyword */:
return write("const ");
@@ -28582,7 +28601,7 @@ var ts;
}
return {
getSourceFile: getSourceFile,
- getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), getDefaultLibFileName(options)); },
+ getDefaultLibFileName: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), ts.getDefaultLibFileName(options)); },
writeFile: writeFile,
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); },
useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; },
@@ -28622,10 +28641,6 @@ 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 = [];
@@ -29527,32 +29542,34 @@ var ts;
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
ts.forEach(program.getSourceFiles(), function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
- var declarations = sourceFile.getNamedDeclarations();
- for (var _i = 0; _i < declarations.length; _i++) {
- var declaration = declarations[_i];
- var name = getDeclarationName(declaration);
- if (name !== undefined) {
+ var nameToDeclarations = sourceFile.getNamedDeclarations();
+ for (var name_21 in nameToDeclarations) {
+ var declarations = ts.getProperty(nameToDeclarations, name_21);
+ if (declarations) {
// First do a quick check to see if the name of the declaration matches the
// last portion of the (possibly) dotted name they're searching for.
- var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name);
+ var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_21);
if (!matches) {
continue;
}
- // It was a match! If the pattern has dots in it, then also see if the
- // declaration container matches as well.
- if (patternMatcher.patternContainsDots) {
- var containers = getContainers(declaration);
- if (!containers) {
- return undefined;
- }
- matches = patternMatcher.getMatches(containers, name);
- if (!matches) {
- continue;
+ for (var _i = 0; _i < declarations.length; _i++) {
+ var declaration = declarations[_i];
+ // It was a match! If the pattern has dots in it, then also see if the
+ // declaration container matches as well.
+ if (patternMatcher.patternContainsDots) {
+ var containers = getContainers(declaration);
+ if (!containers) {
+ return undefined;
+ }
+ matches = patternMatcher.getMatches(containers, name_21);
+ if (!matches) {
+ continue;
+ }
}
+ var fileName = sourceFile.fileName;
+ var matchKind = bestMatchKind(matches);
+ rawItems.push({ name: name_21, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration });
}
- var fileName = sourceFile.fileName;
- var matchKind = bestMatchKind(matches);
- rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration });
}
}
});
@@ -29573,25 +29590,13 @@ var ts;
}
return true;
}
- function getDeclarationName(declaration) {
- var result = getTextOfIdentifierOrLiteral(declaration.name);
- if (result !== undefined) {
- return result;
- }
- if (declaration.name.kind === 127 /* ComputedPropertyName */) {
- var expr = declaration.name.expression;
- if (expr.kind === 155 /* PropertyAccessExpression */) {
- return expr.name.text;
- }
- return getTextOfIdentifierOrLiteral(expr);
- }
- return undefined;
- }
function getTextOfIdentifierOrLiteral(node) {
- if (node.kind === 65 /* Identifier */ ||
- node.kind === 8 /* StringLiteral */ ||
- node.kind === 7 /* NumericLiteral */) {
- return node.text;
+ if (node) {
+ if (node.kind === 65 /* Identifier */ ||
+ node.kind === 8 /* StringLiteral */ ||
+ node.kind === 7 /* NumericLiteral */) {
+ return node.text;
+ }
}
return undefined;
}
@@ -29946,9 +29951,9 @@ var ts;
case 198 /* VariableDeclaration */:
case 152 /* BindingElement */:
var variableDeclarationNode;
- var name_21;
+ var name_22;
if (node.kind === 152 /* BindingElement */) {
- name_21 = node.name;
+ name_22 = node.name;
variableDeclarationNode = node;
// binding elements are added only for variable declarations
// bubble up to the containing variable declaration
@@ -29960,16 +29965,16 @@ var ts;
else {
ts.Debug.assert(!ts.isBindingPattern(node.name));
variableDeclarationNode = node;
- name_21 = node.name;
+ name_22 = node.name;
}
if (ts.isConst(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.constElement);
+ return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.constElement);
}
else if (ts.isLet(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.letElement);
+ return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.letElement);
}
else {
- return createItem(node, getTextOfNode(name_21), ts.ScriptElementKind.variableElement);
+ return createItem(node, getTextOfNode(name_22), ts.ScriptElementKind.variableElement);
}
case 135 /* Constructor */:
return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement);
@@ -30868,7 +30873,8 @@ var ts;
ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments";
ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments";
})(ArgumentListKind || (ArgumentListKind = {}));
- function getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken) {
+ function getSignatureHelpItems(program, sourceFile, position, cancellationToken) {
+ var typeChecker = program.getTypeChecker();
// Decide whether to show signature help
var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position);
if (!startingToken) {
@@ -30883,12 +30889,54 @@ var ts;
}
var call = argumentInfo.invocation;
var candidates = [];
- var resolvedSignature = typeInfoResolver.getResolvedSignature(call, candidates);
+ var resolvedSignature = typeChecker.getResolvedSignature(call, candidates);
cancellationToken.throwIfCancellationRequested();
if (!candidates.length) {
+ // We didn't have any sig help items produced by the TS compiler. If this is a JS
+ // file, then see if we can figure out anything better.
+ if (ts.isJavaScript(sourceFile.fileName)) {
+ return createJavaScriptSignatureHelpItems(argumentInfo);
+ }
return undefined;
}
return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo);
+ function createJavaScriptSignatureHelpItems(argumentInfo) {
+ if (argumentInfo.invocation.kind !== 157 /* CallExpression */) {
+ return undefined;
+ }
+ // See if we can find some symbol with the call expression name that has call signatures.
+ var callExpression = argumentInfo.invocation;
+ var expression = callExpression.expression;
+ var name = expression.kind === 65 /* Identifier */
+ ? expression
+ : expression.kind === 155 /* PropertyAccessExpression */
+ ? expression.name
+ : undefined;
+ if (!name || !name.text) {
+ return undefined;
+ }
+ var typeChecker = program.getTypeChecker();
+ for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
+ var sourceFile_1 = _a[_i];
+ var nameToDeclarations = sourceFile_1.getNamedDeclarations();
+ var declarations = ts.getProperty(nameToDeclarations, name.text);
+ if (declarations) {
+ for (var _b = 0; _b < declarations.length; _b++) {
+ var declaration = declarations[_b];
+ var symbol = declaration.symbol;
+ if (symbol) {
+ var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
+ if (type) {
+ var callSignatures = type.getCallSignatures();
+ if (callSignatures && callSignatures.length) {
+ return createSignatureHelpItems(callSignatures, callSignatures[0], argumentInfo);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
/**
* Returns relevant information for the argument list and the current argument if we are
* in the argument of an invocation; returns undefined otherwise.
@@ -31142,8 +31190,8 @@ var ts;
var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */;
var invocation = argumentListInfo.invocation;
var callTarget = ts.getInvokedExpression(invocation);
- var callTargetSymbol = typeInfoResolver.getSymbolAtLocation(callTarget);
- var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeInfoResolver, callTargetSymbol, undefined, undefined);
+ var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget);
+ var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined);
var items = ts.map(candidates, function (candidateSignature) {
var signatureHelpParameters;
var prefixDisplayParts = [];
@@ -31157,13 +31205,13 @@ var ts;
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
suffixDisplayParts.push(ts.punctuationPart(25 /* GreaterThanToken */));
var parameterParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation);
});
suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts);
}
else {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation);
});
prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts);
prefixDisplayParts.push(ts.punctuationPart(16 /* OpenParenToken */));
@@ -31172,7 +31220,7 @@ var ts;
suffixDisplayParts.push(ts.punctuationPart(17 /* CloseParenToken */));
}
var returnTypeParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation);
});
suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts);
return {
@@ -31201,7 +31249,7 @@ var ts;
};
function createSignatureHelpParameterForParameter(parameter) {
var displayParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation);
});
var isOptional = ts.hasQuestionToken(parameter.valueDeclaration);
return {
@@ -31213,7 +31261,7 @@ var ts;
}
function createSignatureHelpParameterForTypeParameter(typeParameter) {
var displayParts = ts.mapToDisplayParts(function (writer) {
- return typeInfoResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation);
+ return typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation);
});
return {
name: typeParameter.symbol.name,
@@ -31661,9 +31709,9 @@ var ts;
ts.isInsideTemplateLiteral = isInsideTemplateLiteral;
function isAccessibilityModifier(kind) {
switch (kind) {
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
return true;
}
return false;
@@ -31855,6 +31903,10 @@ var ts;
});
}
ts.signatureToDisplayParts = signatureToDisplayParts;
+ function isJavaScript(fileName) {
+ return ts.fileExtensionIs(fileName, ".js");
+ }
+ ts.isJavaScript = isJavaScript;
})(ts || (ts = {}));
///
///
@@ -32376,7 +32428,7 @@ var ts;
this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* MinusToken */, 39 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([98 /* VarKeyword */, 94 /* ThrowKeyword */, 88 /* NewKeyword */, 74 /* DeleteKeyword */, 90 /* ReturnKeyword */, 97 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105 /* LetKeyword */, 70 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */));
+ this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104 /* LetKeyword */, 70 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */));
this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */));
this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(83 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */));
@@ -32399,8 +32451,8 @@ var ts;
// Use of module as a function call. e.g.: import m2 = module("m2");
this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([117 /* ModuleKeyword */, 118 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Add a space around certain TypeScript keywords
- this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 103 /* ImplementsKeyword */, 85 /* ImportKeyword */, 104 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 107 /* PrivateKeyword */, 109 /* PublicKeyword */, 120 /* SetKeyword */, 110 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 103 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 117 /* ModuleKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 120 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 102 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */));
// Lambda expressions
@@ -32419,7 +32471,7 @@ var ts;
// decorators
this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 110 /* StaticKeyword */, 109 /* PublicKeyword */, 107 /* PrivateKeyword */, 108 /* ProtectedKeyword */, 116 /* GetKeyword */, 120 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */));
+ this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 120 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -32509,9 +32561,9 @@ var ts;
}
Rules.prototype.getRuleName = function (rule) {
var o = this;
- for (var name_22 in o) {
- if (o[name_22] === rule) {
- return name_22;
+ for (var name_23 in o) {
+ if (o[name_23] === rule) {
+ return name_23;
}
}
throw new Error("Unknown rule");
@@ -33436,7 +33488,7 @@ var ts;
}
switch (node.kind) {
case 201 /* ClassDeclaration */: return 69 /* ClassKeyword */;
- case 202 /* InterfaceDeclaration */: return 104 /* InterfaceKeyword */;
+ case 202 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */;
case 200 /* FunctionDeclaration */: return 83 /* FunctionKeyword */;
case 204 /* EnumDeclaration */: return 204 /* EnumDeclaration */;
case 136 /* GetAccessor */: return 116 /* GetKeyword */;
@@ -34909,29 +34961,65 @@ var ts;
return this.namedDeclarations;
};
SourceFileObject.prototype.computeNamedDeclarations = function () {
- var namedDeclarations = [];
+ var result = {};
ts.forEachChild(this, visit);
- return namedDeclarations;
+ return result;
+ function addDeclaration(declaration) {
+ var name = getDeclarationName(declaration);
+ if (name) {
+ var declarations = getDeclarations(name);
+ declarations.push(declaration);
+ }
+ }
+ function getDeclarations(name) {
+ return ts.getProperty(result, name) || (result[name] = []);
+ }
+ function getDeclarationName(declaration) {
+ if (declaration.name) {
+ var result_2 = getTextOfIdentifierOrLiteral(declaration.name);
+ if (result_2 !== undefined) {
+ return result_2;
+ }
+ if (declaration.name.kind === 127 /* ComputedPropertyName */) {
+ var expr = declaration.name.expression;
+ if (expr.kind === 155 /* PropertyAccessExpression */) {
+ return expr.name.text;
+ }
+ return getTextOfIdentifierOrLiteral(expr);
+ }
+ }
+ return undefined;
+ }
+ function getTextOfIdentifierOrLiteral(node) {
+ if (node) {
+ if (node.kind === 65 /* Identifier */ ||
+ node.kind === 8 /* StringLiteral */ ||
+ node.kind === 7 /* NumericLiteral */) {
+ return node.text;
+ }
+ }
+ return undefined;
+ }
function visit(node) {
switch (node.kind) {
case 200 /* FunctionDeclaration */:
case 134 /* MethodDeclaration */:
case 133 /* MethodSignature */:
var functionDeclaration = node;
- if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) {
- var lastDeclaration = namedDeclarations.length > 0 ?
- namedDeclarations[namedDeclarations.length - 1] :
- undefined;
+ var declarationName = getDeclarationName(functionDeclaration);
+ if (declarationName) {
+ var declarations = getDeclarations(declarationName);
+ var lastDeclaration = ts.lastOrUndefined(declarations);
// Check whether this declaration belongs to an "overload group".
- if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) {
+ if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) {
// Overwrite the last declaration if it was an overload
// and this one is an implementation.
if (functionDeclaration.body && !lastDeclaration.body) {
- namedDeclarations[namedDeclarations.length - 1] = functionDeclaration;
+ declarations[declarations.length - 1] = functionDeclaration;
}
}
else {
- namedDeclarations.push(functionDeclaration);
+ declarations.push(functionDeclaration);
}
ts.forEachChild(node, visit);
}
@@ -34950,9 +35038,7 @@ var ts;
case 136 /* GetAccessor */:
case 137 /* SetAccessor */:
case 145 /* TypeLiteral */:
- if (node.name) {
- namedDeclarations.push(node);
- }
+ addDeclaration(node);
// fall through
case 135 /* Constructor */:
case 180 /* VariableStatement */:
@@ -34982,7 +35068,7 @@ var ts;
case 226 /* EnumMember */:
case 132 /* PropertyDeclaration */:
case 131 /* PropertySignature */:
- namedDeclarations.push(node);
+ addDeclaration(node);
break;
case 215 /* ExportDeclaration */:
// Handle named exports case e.g.:
@@ -34997,14 +35083,14 @@ var ts;
// Handle default import case e.g.:
// import d from "mod";
if (importClause.name) {
- namedDeclarations.push(importClause);
+ addDeclaration(importClause);
}
// Handle named bindings in imports e.g.:
// import * as NS from "mod";
// import {a, b as B} from "mod";
if (importClause.namedBindings) {
if (importClause.namedBindings.kind === 211 /* NamespaceImport */) {
- namedDeclarations.push(importClause.namedBindings);
+ addDeclaration(importClause.namedBindings);
}
else {
ts.forEach(importClause.namedBindings.elements, visit);
@@ -35593,7 +35679,7 @@ var ts;
}
else if (token === 35 /* AsteriskToken */) {
token = scanner.scan();
- if (token === 102 /* AsKeyword */) {
+ if (token === 111 /* AsKeyword */) {
token = scanner.scan();
if (token === 65 /* Identifier */) {
token = scanner.scan();
@@ -35864,8 +35950,6 @@ var ts;
var syntaxTreeCache = new SyntaxTreeCache(host);
var ruleProvider;
var program;
- // this checker is used to answer all LS questions except errors
- var typeInfoResolver;
var useCaseSensitivefileNames = false;
var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
// Check if the localized messages json is set, otherwise query the host for it
@@ -35935,7 +36019,9 @@ var ts;
}
}
program = newProgram;
- typeInfoResolver = program.getTypeChecker();
+ // Make sure all the nodes in the program are both bound, and have their parent
+ // pointers set property.
+ program.getTypeChecker();
return;
function getOrCreateSourceFile(fileName) {
// The program is asking for this file, check first if the host can locate it.
@@ -36007,15 +36093,8 @@ var ts;
synchronizeHostData();
return program;
}
- /**
- * Clean up any semantic caches that are not needed.
- * The host can call this method if it wants to jettison unused memory.
- * We will just dump the typeChecker and recreate a new one. this should have the effect of destroying all the semantic caches.
- */
function cleanupSemanticCache() {
- if (program) {
- typeInfoResolver = program.getTypeChecker();
- }
+ // TODO: Should we jettison the program (or it's type checker) here?
}
function dispose() {
if (program) {
@@ -36029,9 +36108,6 @@ var ts;
synchronizeHostData();
return program.getSyntacticDiagnostics(getValidSourceFile(fileName));
}
- function isJavaScript(fileName) {
- return ts.fileExtensionIs(fileName, ".js");
- }
/**
* getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors
* If '-d' enabled, report both semantic and emitter errors
@@ -36042,7 +36118,7 @@ var ts;
// For JavaScript files, we don't want to report the normal typescript semantic errors.
// Instead, we just report errors for using TypeScript-only constructs from within a
// JavaScript file.
- if (isJavaScript(fileName)) {
+ if (ts.isJavaScript(fileName)) {
return getJavaScriptSemanticDiagnostics(targetSourceFile);
}
// Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file.
@@ -36079,7 +36155,7 @@ var ts;
break;
case 222 /* HeritageClause */:
var heritageClause = node;
- if (heritageClause.token === 103 /* ImplementsKeyword */) {
+ if (heritageClause.token === 102 /* ImplementsKeyword */) {
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file));
return true;
}
@@ -36182,14 +36258,14 @@ var ts;
for (var _i = 0; _i < modifiers.length; _i++) {
var modifier = modifiers[_i];
switch (modifier.kind) {
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
case 115 /* DeclareKeyword */:
diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind)));
return true;
// These are all legal modifiers.
- case 110 /* StaticKeyword */:
+ case 109 /* StaticKeyword */:
case 78 /* ExportKeyword */:
case 70 /* ConstKeyword */:
case 73 /* DefaultKeyword */:
@@ -36251,29 +36327,8 @@ var ts;
}
return ts.unescapeIdentifier(displayName);
}
- function createCompletionEntry(symbol, typeChecker, location) {
- // Try to get a valid display name for this symbol, if we could not find one, then ignore it.
- // We would like to only show things that can be added after a dot, so for instance numeric properties can
- // not be accessed with a dot (a.1 <- invalid)
- var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true);
- if (!displayName) {
- return undefined;
- }
- // TODO(drosen): Right now we just permit *all* semantic meanings when calling
- // 'getSymbolKind' which is permissible given that it is backwards compatible; but
- // really we should consider passing the meaning for the node so that we don't report
- // that a suggestion for a value is an interface. We COULD also just do what
- // 'getSymbolModifiers' does, which is to use the first declaration.
- // Use a 'sortText' of 0' so that all symbol completion entries come before any other
- // entries (like JavaScript identifier entries).
- return {
- name: displayName,
- kind: getSymbolKind(symbol, typeChecker, location),
- kindModifiers: getSymbolModifiers(symbol),
- sortText: "0"
- };
- }
function getCompletionData(fileName, position) {
+ var typeChecker = program.getTypeChecker();
var syntacticStart = new Date().getTime();
var sourceFile = getValidSourceFile(fileName);
var start = new Date().getTime();
@@ -36342,26 +36397,26 @@ var ts;
isMemberCompletion = true;
isNewIdentifierLocation = false;
if (node.kind === 65 /* Identifier */ || node.kind === 126 /* QualifiedName */ || node.kind === 155 /* PropertyAccessExpression */) {
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
// This is an alias, follow what it aliases
if (symbol && symbol.flags & 8388608 /* Alias */) {
- symbol = typeInfoResolver.getAliasedSymbol(symbol);
+ symbol = typeChecker.getAliasedSymbol(symbol);
}
if (symbol && symbol.flags & 1952 /* HasExports */) {
// Extract module or enum members
- var exportedSymbols = typeInfoResolver.getExportsOfModule(symbol);
+ var exportedSymbols = typeChecker.getExportsOfModule(symbol);
ts.forEach(exportedSymbols, function (symbol) {
- if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) {
+ if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) {
symbols.push(symbol);
}
});
}
}
- var type = typeInfoResolver.getTypeAtLocation(node);
+ var type = typeChecker.getTypeAtLocation(node);
if (type) {
// Filter private properties
ts.forEach(type.getApparentProperties(), function (symbol) {
- if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) {
+ if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) {
symbols.push(symbol);
}
});
@@ -36373,11 +36428,11 @@ var ts;
// Object literal expression, look up possible property names from contextual type
isMemberCompletion = true;
isNewIdentifierLocation = true;
- var contextualType = typeInfoResolver.getContextualType(containingObjectLiteral);
+ var contextualType = typeChecker.getContextualType(containingObjectLiteral);
if (!contextualType) {
return false;
}
- var contextualTypeMembers = typeInfoResolver.getPropertiesOfType(contextualType);
+ var contextualTypeMembers = typeChecker.getPropertiesOfType(contextualType);
if (contextualTypeMembers && contextualTypeMembers.length > 0) {
// Add filtered items to the completion list
symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties);
@@ -36393,9 +36448,9 @@ var ts;
ts.Debug.assert(importDeclaration !== undefined);
var exports;
if (importDeclaration.moduleSpecifier) {
- var moduleSpecifierSymbol = typeInfoResolver.getSymbolAtLocation(importDeclaration.moduleSpecifier);
+ var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier);
if (moduleSpecifierSymbol) {
- exports = typeInfoResolver.getExportsOfModule(moduleSpecifierSymbol);
+ exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol);
}
}
//let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration);
@@ -36440,7 +36495,7 @@ var ts;
var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
/// TODO filter meaning based on the current context
var symbolMeanings = 793056 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 8388608 /* Alias */;
- symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings);
+ symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings);
}
return true;
}
@@ -36503,9 +36558,9 @@ var ts;
return containingNodeKind === 171 /* TemplateExpression */; // `aa ${|
case 12 /* TemplateMiddle */:
return containingNodeKind === 176 /* TemplateSpan */; // `aa ${10} dd ${|
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
return containingNodeKind === 132 /* PropertyDeclaration */; // class A{ public |
}
// Previous token may have been a keyword that was converted to an identifier.
@@ -36595,6 +36650,7 @@ var ts;
containingNodeKind === 150 /* ObjectBindingPattern */; // function func({ x|
case 22 /* SemicolonToken */:
return containingNodeKind === 131 /* PropertySignature */ &&
+ previousToken.parent && previousToken.parent.parent &&
(previousToken.parent.parent.kind === 202 /* InterfaceDeclaration */ ||
previousToken.parent.parent.kind === 145 /* TypeLiteral */); // let x : { a; |
case 24 /* LessThanToken */:
@@ -36602,27 +36658,28 @@ var ts;
containingNodeKind === 200 /* FunctionDeclaration */ ||
containingNodeKind === 202 /* InterfaceDeclaration */ ||
isFunction(containingNodeKind);
- case 110 /* StaticKeyword */:
+ case 109 /* StaticKeyword */:
return containingNodeKind === 132 /* PropertyDeclaration */;
case 21 /* DotDotDotToken */:
return containingNodeKind === 129 /* Parameter */ ||
containingNodeKind === 135 /* Constructor */ ||
- (previousToken.parent.parent.kind === 151 /* ArrayBindingPattern */); // var [ ...z|
- case 109 /* PublicKeyword */:
- case 107 /* PrivateKeyword */:
- case 108 /* ProtectedKeyword */:
+ (previousToken.parent && previousToken.parent.parent &&
+ previousToken.parent.parent.kind === 151 /* ArrayBindingPattern */); // var [ ...z|
+ case 108 /* PublicKeyword */:
+ case 106 /* PrivateKeyword */:
+ case 107 /* ProtectedKeyword */:
return containingNodeKind === 129 /* Parameter */;
case 69 /* ClassKeyword */:
case 77 /* EnumKeyword */:
- case 104 /* InterfaceKeyword */:
+ case 103 /* InterfaceKeyword */:
case 83 /* FunctionKeyword */:
case 98 /* VarKeyword */:
case 116 /* GetKeyword */:
case 120 /* SetKeyword */:
case 85 /* ImportKeyword */:
- case 105 /* LetKeyword */:
+ case 104 /* LetKeyword */:
case 70 /* ConstKeyword */:
- case 111 /* YieldKeyword */:
+ case 110 /* YieldKeyword */:
return true;
}
// Previous token may have been a keyword that was converted to an identifier.
@@ -36699,7 +36756,7 @@ var ts;
}
var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot;
var entries;
- if (isRightOfDot && isJavaScript(fileName)) {
+ if (isRightOfDot && ts.isJavaScript(fileName)) {
entries = getCompletionEntriesFromSymbols(symbols);
ts.addRange(entries, getJavaScriptCompletionEntries());
}
@@ -36721,10 +36778,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_23 in nameTable) {
- if (!allNames[name_23]) {
- allNames[name_23] = name_23;
- var displayName = getCompletionEntryDisplayName(name_23, target, true);
+ for (var name_24 in nameTable) {
+ if (!allNames[name_24]) {
+ allNames[name_24] = name_24;
+ var displayName = getCompletionEntryDisplayName(name_24, target, true);
if (displayName) {
var entry = {
name: displayName,
@@ -36739,6 +36796,28 @@ var ts;
}
return entries;
}
+ function createCompletionEntry(symbol, location) {
+ // Try to get a valid display name for this symbol, if we could not find one, then ignore it.
+ // We would like to only show things that can be added after a dot, so for instance numeric properties can
+ // not be accessed with a dot (a.1 <- invalid)
+ var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true);
+ if (!displayName) {
+ return undefined;
+ }
+ // TODO(drosen): Right now we just permit *all* semantic meanings when calling
+ // 'getSymbolKind' which is permissible given that it is backwards compatible; but
+ // really we should consider passing the meaning for the node so that we don't report
+ // that a suggestion for a value is an interface. We COULD also just do what
+ // 'getSymbolModifiers' does, which is to use the first declaration.
+ // Use a 'sortText' of 0' so that all symbol completion entries come before any other
+ // entries (like JavaScript identifier entries).
+ return {
+ name: displayName,
+ kind: getSymbolKind(symbol, location),
+ kindModifiers: getSymbolModifiers(symbol),
+ sortText: "0"
+ };
+ }
function getCompletionEntriesFromSymbols(symbols) {
var start = new Date().getTime();
var entries = [];
@@ -36746,7 +36825,7 @@ var ts;
var nameToSymbol = {};
for (var _i = 0; _i < symbols.length; _i++) {
var symbol = symbols[_i];
- var entry = createCompletionEntry(symbol, typeInfoResolver, location);
+ var entry = createCompletionEntry(symbol, location);
if (entry) {
var id = ts.escapeIdentifier(entry.name);
if (!ts.lookUp(nameToSymbol, id)) {
@@ -36773,7 +36852,7 @@ var ts;
// completion entry.
var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false) === entryName ? s : undefined; });
if (symbol) {
- var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, typeInfoResolver, location_2, 7 /* All */);
+ var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */);
return {
name: entryName,
kind: displayPartsDocumentationsAndSymbolKind.symbolKind,
@@ -36797,7 +36876,7 @@ var ts;
return undefined;
}
// TODO(drosen): use contextual SemanticMeaning.
- function getSymbolKind(symbol, typeResolver, location) {
+ function getSymbolKind(symbol, location) {
var flags = symbol.getFlags();
if (flags & 32 /* Class */)
return ScriptElementKind.classElement;
@@ -36809,7 +36888,7 @@ var ts;
return ScriptElementKind.interfaceElement;
if (flags & 262144 /* TypeParameter */)
return ScriptElementKind.typeParameterElement;
- var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver, location);
+ var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location);
if (result === ScriptElementKind.unknown) {
if (flags & 262144 /* TypeParameter */)
return ScriptElementKind.typeParameterElement;
@@ -36822,11 +36901,12 @@ var ts;
}
return result;
}
- function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver, location) {
- if (typeResolver.isUndefinedSymbol(symbol)) {
+ function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location) {
+ var typeChecker = program.getTypeChecker();
+ if (typeChecker.isUndefinedSymbol(symbol)) {
return ScriptElementKind.variableElement;
}
- if (typeResolver.isArgumentsSymbol(symbol)) {
+ if (typeChecker.isArgumentsSymbol(symbol)) {
return ScriptElementKind.localVariableElement;
}
if (flags & 3 /* Variable */) {
@@ -36854,7 +36934,7 @@ var ts;
if (flags & 4 /* Property */) {
if (flags & 268435456 /* UnionProperty */) {
// If union property is result of union of non method (property/accessors/variables), it is labeled as property
- var unionPropertyKind = ts.forEach(typeInfoResolver.getRootSymbols(symbol), function (rootSymbol) {
+ var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) {
var rootSymbolFlags = rootSymbol.getFlags();
if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) {
return ScriptElementKind.memberVariableElement;
@@ -36864,7 +36944,7 @@ var ts;
if (!unionPropertyKind) {
// If this was union of all methods,
//make sure it has call signatures before we can label it as method
- var typeOfUnionProperty = typeInfoResolver.getTypeOfSymbolAtLocation(symbol, location);
+ var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (typeOfUnionProperty.getCallSignatures().length) {
return ScriptElementKind.memberFunctionElement;
}
@@ -36897,14 +36977,14 @@ var ts;
? ts.getNodeModifiers(symbol.declarations[0])
: ScriptElementKindModifier.none;
}
- function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, typeResolver, location,
- // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location
- semanticMeaning) {
+ // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location
+ function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) {
if (semanticMeaning === void 0) { semanticMeaning = getMeaningFromLocation(location); }
+ var typeChecker = program.getTypeChecker();
var displayParts = [];
var documentation;
var symbolFlags = symbol.flags;
- var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver, location);
+ var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location);
var hasAddedSymbolInfo;
var type;
// Class at constructor site need to be shown as constructor apart from property,method, vars
@@ -36914,7 +36994,7 @@ var ts;
symbolKind = ScriptElementKind.memberVariableElement;
}
var signature;
- type = typeResolver.getTypeOfSymbolAtLocation(symbol, location);
+ type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (type) {
if (location.parent && location.parent.kind === 155 /* PropertyAccessExpression */) {
var right = location.parent.name;
@@ -36933,7 +37013,7 @@ var ts;
}
if (callExpression) {
var candidateSignatures = [];
- signature = typeResolver.getResolvedSignature(callExpression, candidateSignatures);
+ signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures);
if (!signature && candidateSignatures.length) {
// Use the first candidate:
signature = candidateSignatures[0];
@@ -36978,7 +37058,7 @@ var ts;
displayParts.push(ts.spacePart());
}
if (!(type.flags & 32768 /* Anonymous */)) {
- displayParts.push.apply(displayParts, ts.symbolToDisplayParts(typeResolver, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */));
+ displayParts.push.apply(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */));
}
addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */);
break;
@@ -36994,8 +37074,8 @@ var ts;
// get the signature from the declaration and write it
var functionDeclaration = location.parent;
var allSignatures = functionDeclaration.kind === 135 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures();
- if (!typeResolver.isImplementationOfOverload(functionDeclaration)) {
- signature = typeResolver.getSignatureFromDeclaration(functionDeclaration);
+ if (!typeChecker.isImplementationOfOverload(functionDeclaration)) {
+ signature = typeChecker.getSignatureFromDeclaration(functionDeclaration);
}
else {
signature = allSignatures[0];
@@ -37023,7 +37103,7 @@ var ts;
}
if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) {
addNewLineIfDisplayPartsExist();
- displayParts.push(ts.keywordPart(104 /* InterfaceKeyword */));
+ displayParts.push(ts.keywordPart(103 /* InterfaceKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
@@ -37036,7 +37116,7 @@ var ts;
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(53 /* EqualsToken */));
displayParts.push(ts.spacePart());
- displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
+ displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
}
if (symbolFlags & 384 /* Enum */) {
addNewLineIfDisplayPartsExist();
@@ -37072,7 +37152,7 @@ var ts;
else {
// Method/function type parameter
var signatureDeclaration = ts.getDeclarationOfKind(symbol, 128 /* TypeParameter */).parent;
- var signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration);
+ var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
if (signatureDeclaration.kind === 139 /* ConstructSignature */) {
displayParts.push(ts.keywordPart(88 /* NewKeyword */));
displayParts.push(ts.spacePart());
@@ -37080,14 +37160,14 @@ var ts;
else if (signatureDeclaration.kind !== 138 /* CallSignature */ && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
- displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
+ displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
}
}
if (symbolFlags & 8 /* EnumMember */) {
addPrefixForAnyFunctionOrVar(symbol, "enum member");
var declaration = symbol.declarations[0];
if (declaration.kind === 226 /* EnumMember */) {
- var constantValue = typeResolver.getConstantValue(declaration);
+ var constantValue = typeChecker.getConstantValue(declaration);
if (constantValue !== undefined) {
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(53 /* EqualsToken */));
@@ -37114,7 +37194,7 @@ var ts;
displayParts.push(ts.punctuationPart(17 /* CloseParenToken */));
}
else {
- var internalAliasSymbol = typeResolver.getSymbolAtLocation(importEqualsDeclaration.moduleReference);
+ var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference);
if (internalAliasSymbol) {
displayParts.push(ts.spacePart());
displayParts.push(ts.operatorPart(53 /* EqualsToken */));
@@ -37139,12 +37219,12 @@ var ts;
// If the type is type parameter, format it specially
if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
- typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration);
+ typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration);
});
displayParts.push.apply(displayParts, typeParameterParts);
}
else {
- displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeResolver, type, enclosingDeclaration));
+ displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration));
}
}
else if (symbolFlags & 16 /* Function */ ||
@@ -37159,7 +37239,7 @@ var ts;
}
}
else {
- symbolKind = getSymbolKind(symbol, typeResolver, location);
+ symbolKind = getSymbolKind(symbol, location);
}
}
if (!documentation) {
@@ -37172,7 +37252,7 @@ var ts;
}
}
function addFullSymbolName(symbol, enclosingDeclaration) {
- var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeResolver, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */);
+ var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */);
displayParts.push.apply(displayParts, fullSymbolDisplayParts);
}
function addPrefixForAnyFunctionOrVar(symbol, symbolKind) {
@@ -37200,7 +37280,7 @@ var ts;
}
}
function addSignatureDisplayParts(signature, allSignatures, flags) {
- displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */));
+ displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */));
if (allSignatures.length > 1) {
displayParts.push(ts.spacePart());
displayParts.push(ts.punctuationPart(16 /* OpenParenToken */));
@@ -37214,7 +37294,7 @@ var ts;
}
function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
- typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration);
+ typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration);
});
displayParts.push.apply(displayParts, typeParameterParts);
}
@@ -37226,7 +37306,11 @@ var ts;
if (!node) {
return undefined;
}
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ if (isLabelName(node)) {
+ return undefined;
+ }
+ var typeChecker = program.getTypeChecker();
+ var symbol = typeChecker.getSymbolAtLocation(node);
if (!symbol) {
// Try getting just type at this position and show
switch (node.kind) {
@@ -37236,20 +37320,20 @@ var ts;
case 93 /* ThisKeyword */:
case 91 /* SuperKeyword */:
// For the identifiers/this/super etc get the type at position
- var type = typeInfoResolver.getTypeAtLocation(node);
+ var type = typeChecker.getTypeAtLocation(node);
if (type) {
return {
kind: ScriptElementKind.unknown,
kindModifiers: ScriptElementKindModifier.none,
textSpan: ts.createTextSpan(node.getStart(), node.getWidth()),
- displayParts: ts.typeToDisplayParts(typeInfoResolver, type, getContainerNode(node)),
+ displayParts: ts.typeToDisplayParts(typeChecker, type, getContainerNode(node)),
documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined
};
}
}
return undefined;
}
- var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), typeInfoResolver, node);
+ var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), node);
return {
kind: displayPartsDocumentationsAndKind.symbolKind,
kindModifiers: getSymbolModifiers(symbol),
@@ -37298,7 +37382,8 @@ var ts;
}
return undefined;
}
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var typeChecker = program.getTypeChecker();
+ var symbol = typeChecker.getSymbolAtLocation(node);
// Could not find a symbol e.g. node is string or number keyword,
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
if (!symbol) {
@@ -37311,7 +37396,7 @@ var ts;
if (symbol.flags & 8388608 /* Alias */) {
var declaration = symbol.declarations[0];
if (node.kind === 65 /* Identifier */ && node.parent === declaration) {
- symbol = typeInfoResolver.getAliasedSymbol(symbol);
+ symbol = typeChecker.getAliasedSymbol(symbol);
}
}
// Because name in short-hand property assignment has two different meanings: property name and property value,
@@ -37320,22 +37405,22 @@ var ts;
// is performed at the location of property access, we would like to go to definition of the property in the short-hand
// assignment. This case and others are handled by the following code.
if (node.parent.kind === 225 /* ShorthandPropertyAssignment */) {
- var shorthandSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
+ var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
if (!shorthandSymbol) {
return [];
}
var shorthandDeclarations = shorthandSymbol.getDeclarations();
- var shorthandSymbolKind = getSymbolKind(shorthandSymbol, typeInfoResolver, node);
- var shorthandSymbolName = typeInfoResolver.symbolToString(shorthandSymbol);
- var shorthandContainerName = typeInfoResolver.symbolToString(symbol.parent, node);
+ var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node);
+ var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol);
+ var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node);
return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); });
}
var result = [];
var declarations = symbol.getDeclarations();
- var symbolName = typeInfoResolver.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
- var symbolKind = getSymbolKind(symbol, typeInfoResolver, node);
+ var symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
+ var symbolKind = getSymbolKind(symbol, node);
var containerSymbol = symbol.parent;
- var containerName = containerSymbol ? typeInfoResolver.symbolToString(containerSymbol, node) : "";
+ var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
// Just add all the declarations.
@@ -37390,7 +37475,7 @@ var ts;
var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName));
// Get occurrences only supports reporting occurrences for the file queried. So
// filter down to that list.
- results = ts.filter(results, function (r) { return r.fileName === fileName; });
+ results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; });
}
return results;
}
@@ -37653,7 +37738,7 @@ var ts;
return undefined;
}
}
- else if (modifier === 110 /* StaticKeyword */) {
+ else if (modifier === 109 /* StaticKeyword */) {
if (container.kind !== 201 /* ClassDeclaration */) {
return undefined;
}
@@ -37702,13 +37787,13 @@ var ts;
return ts.map(keywords, getHighlightSpanForNode);
function getFlagFromModifier(modifier) {
switch (modifier) {
- case 109 /* PublicKeyword */:
+ case 108 /* PublicKeyword */:
return 16 /* Public */;
- case 107 /* PrivateKeyword */:
+ case 106 /* PrivateKeyword */:
return 32 /* Private */;
- case 108 /* ProtectedKeyword */:
+ case 107 /* ProtectedKeyword */:
return 64 /* Protected */;
- case 110 /* StaticKeyword */:
+ case 109 /* StaticKeyword */:
return 128 /* Static */;
case 78 /* ExportKeyword */:
return 1 /* Export */;
@@ -37969,6 +38054,7 @@ var ts;
return getReferencedSymbolsForNodes(node, program.getSourceFiles(), findInStrings, findInComments);
}
function getReferencedSymbolsForNodes(node, sourceFiles, findInStrings, findInComments) {
+ var typeChecker = program.getTypeChecker();
// Labels
if (isLabelName(node)) {
if (isJumpStatementTarget(node)) {
@@ -37988,7 +38074,7 @@ var ts;
if (node.kind === 91 /* SuperKeyword */) {
return getReferencesForSuperKeyword(node);
}
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
// Could not find a symbol e.g. unknown identifier
if (!symbol) {
// Can't have references to something that we have no symbol for.
@@ -38027,7 +38113,7 @@ var ts;
}
return result;
function getDefinition(symbol) {
- var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), typeInfoResolver, node);
+ var info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node);
var name = ts.map(info.displayParts, function (p) { return p.text; }).join("");
var declarations = symbol.declarations;
if (!declarations || declarations.length === 0) {
@@ -38070,7 +38156,7 @@ var ts;
if (isImportOrExportSpecifierName(location)) {
return location.getText();
}
- name = typeInfoResolver.symbolToString(symbol);
+ name = typeChecker.symbolToString(symbol);
return stripQuotes(name);
}
function getInternedName(symbol, location, declarations) {
@@ -38258,10 +38344,10 @@ var ts;
if (!(getMeaningFromLocation(referenceLocation) & searchMeaning)) {
return;
}
- var referenceSymbol = typeInfoResolver.getSymbolAtLocation(referenceLocation);
+ var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation);
if (referenceSymbol) {
var referenceSymbolDeclaration = referenceSymbol.valueDeclaration;
- var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
+ var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation);
if (relatedSymbol) {
var referencedSymbol = getReferencedSymbol(relatedSymbol);
@@ -38450,14 +38536,14 @@ var ts;
var result = [symbol];
// If the symbol is an alias, add what it alaises to the list
if (isImportOrExportSpecifierImportSymbol(symbol)) {
- result.push(typeInfoResolver.getAliasedSymbol(symbol));
+ result.push(typeChecker.getAliasedSymbol(symbol));
}
// If the location is in a context sensitive location (i.e. in an object literal) try
// to get a contextual type for it, and add the property symbol from the contextual
// type to the search set
if (isNameOfPropertyAssignment(location)) {
ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) {
- result.push.apply(result, typeInfoResolver.getRootSymbols(contextualSymbol));
+ result.push.apply(result, typeChecker.getRootSymbols(contextualSymbol));
});
/* Because in short-hand property assignment, location has two meaning : property name and as value of the property
* When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of
@@ -38470,14 +38556,14 @@ var ts;
* so that when matching with potential reference symbol, both symbols from property declaration and variable declaration
* will be included correctly.
*/
- var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(location.parent);
+ var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent);
if (shorthandValueSymbol) {
result.push(shorthandValueSymbol);
}
}
// If this is a union property, add all the symbols from all its source symbols in all unioned types.
// If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list
- ts.forEach(typeInfoResolver.getRootSymbols(symbol), function (rootSymbol) {
+ ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) {
if (rootSymbol !== symbol) {
result.push(rootSymbol);
}
@@ -38503,9 +38589,9 @@ var ts;
return;
function getPropertySymbolFromTypeReference(typeReference) {
if (typeReference) {
- var type = typeInfoResolver.getTypeAtLocation(typeReference);
+ var type = typeChecker.getTypeAtLocation(typeReference);
if (type) {
- var propertySymbol = typeInfoResolver.getPropertyOfType(type, propertyName);
+ var propertySymbol = typeChecker.getPropertyOfType(type, propertyName);
if (propertySymbol) {
result.push(propertySymbol);
}
@@ -38522,7 +38608,7 @@ var ts;
// If the reference symbol is an alias, check if what it is aliasing is one of the search
// symbols.
if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) {
- var aliasedSymbol = typeInfoResolver.getAliasedSymbol(referenceSymbol);
+ var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol);
if (searchSymbols.indexOf(aliasedSymbol) >= 0) {
return aliasedSymbol;
}
@@ -38532,12 +38618,12 @@ var ts;
// compare to our searchSymbol
if (isNameOfPropertyAssignment(referenceLocation)) {
return ts.forEach(getPropertySymbolsFromContextualType(referenceLocation), function (contextualSymbol) {
- return ts.forEach(typeInfoResolver.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
+ return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
});
}
// Unwrap symbols to get to the root (e.g. transient symbols as a result of widening)
// Or a union property, use its underlying unioned symbols
- return ts.forEach(typeInfoResolver.getRootSymbols(referenceSymbol), function (rootSymbol) {
+ return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) {
// if it is in the list, then we are done
if (searchSymbols.indexOf(rootSymbol) >= 0) {
return rootSymbol;
@@ -38545,9 +38631,9 @@ var ts;
// Finally, try all properties with the same name in any type the containing type extended or implemented, and
// see if any is in the list
if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) {
- var result_2 = [];
- getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_2);
- return ts.forEach(result_2, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
+ var result_3 = [];
+ getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3);
+ return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; });
}
return undefined;
});
@@ -38555,29 +38641,29 @@ var ts;
function getPropertySymbolsFromContextualType(node) {
if (isNameOfPropertyAssignment(node)) {
var objectLiteral = node.parent.parent;
- var contextualType = typeInfoResolver.getContextualType(objectLiteral);
- var name_24 = node.text;
+ var contextualType = typeChecker.getContextualType(objectLiteral);
+ var name_25 = 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_24);
+ var unionProperty = contextualType.getProperty(name_25);
if (unionProperty) {
return [unionProperty];
}
else {
- var result_3 = [];
+ var result_4 = [];
ts.forEach(contextualType.types, function (t) {
- var symbol = t.getProperty(name_24);
+ var symbol = t.getProperty(name_25);
if (symbol) {
- result_3.push(symbol);
+ result_4.push(symbol);
}
});
- return result_3;
+ return result_4;
}
}
else {
- var symbol_1 = contextualType.getProperty(name_24);
+ var symbol_1 = contextualType.getProperty(name_25);
if (symbol_1) {
return [symbol_1];
}
@@ -38742,7 +38828,7 @@ var ts;
}
if (!isLastClause && root.parent.kind === 177 /* HeritageClauseElement */ && root.parent.parent.kind === 222 /* HeritageClause */) {
var decl = root.parent.parent.parent;
- return (decl.kind === 201 /* ClassDeclaration */ && root.parent.parent.token === 103 /* ImplementsKeyword */) ||
+ return (decl.kind === 201 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) ||
(decl.kind === 202 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */);
}
return false;
@@ -38803,7 +38889,7 @@ var ts;
function getSignatureHelpItems(fileName, position) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
- return ts.SignatureHelp.getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken);
+ return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken);
}
/// Syntactic features
function getSourceFile(fileName) {
@@ -38870,6 +38956,7 @@ var ts;
function getSemanticClassifications(fileName, span) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
+ var typeChecker = program.getTypeChecker();
var result = [];
processNode(sourceFile);
return result;
@@ -38915,7 +39002,7 @@ var ts;
// Only walk into nodes that intersect the requested span.
if (node && ts.textSpanIntersectsWith(span, node.getStart(), node.getWidth())) {
if (node.kind === 65 /* Identifier */ && node.getWidth() > 0) {
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
if (symbol) {
var type = classifySymbol(symbol, getMeaningFromLocation(node));
if (type) {
@@ -39327,10 +39414,11 @@ var ts;
function getRenameInfo(fileName, position) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
+ var typeChecker = program.getTypeChecker();
var node = ts.getTouchingWord(sourceFile, position);
// Can only rename an identifier.
if (node && node.kind === 65 /* Identifier */) {
- var symbol = typeInfoResolver.getSymbolAtLocation(node);
+ var symbol = typeChecker.getSymbolAtLocation(node);
// Only allow a symbol to be renamed if it actually has at least one declaration.
if (symbol) {
var declarations = symbol.getDeclarations();
@@ -39340,19 +39428,19 @@ var ts;
if (defaultLibFileName) {
for (var _i = 0; _i < declarations.length; _i++) {
var current = declarations[_i];
- var sourceFile_1 = current.getSourceFile();
- if (sourceFile_1 && getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) {
+ var sourceFile_2 = current.getSourceFile();
+ if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) {
return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key));
}
}
}
- var kind = getSymbolKind(symbol, typeInfoResolver, node);
+ var kind = getSymbolKind(symbol, node);
if (kind) {
return {
canRename: true,
localizedErrorMessage: undefined,
displayName: symbol.name,
- fullDisplayName: typeInfoResolver.getFullyQualifiedName(symbol),
+ fullDisplayName: typeChecker.getFullyQualifiedName(symbol),
kind: kind,
kindModifiers: getSymbolModifiers(symbol),
triggerSpan: ts.createTextSpan(node.getStart(), node.getWidth())
@@ -39497,7 +39585,7 @@ var ts;
if (keyword2 === 116 /* GetKeyword */ ||
keyword2 === 120 /* SetKeyword */ ||
keyword2 === 114 /* ConstructorKeyword */ ||
- keyword2 === 110 /* StaticKeyword */) {
+ keyword2 === 109 /* StaticKeyword */) {
// Allow things like "public get", "public constructor" and "public static".
// These are all legal.
return true;