|
/*! ***************************************************************************** |
|
Copyright (c) Microsoft Corporation. All rights reserved. |
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use |
|
this file except in compliance with the License. You may obtain a copy of the |
|
License at http://www.apache.org/licenses/LICENSE-2.0 |
|
|
|
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED |
|
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, |
|
MERCHANTABLITY OR NON-INFRINGEMENT. |
|
|
|
See the Apache Version 2.0 License for specific language governing permissions |
|
and limitations under the License. |
|
***************************************************************************** */ |
|
|
|
var __extends = (this && this.__extends) || function (d, b) { |
|
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; |
|
function __() { this.constructor = d; } |
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
}; |
|
var ts; |
|
(function (ts) { |
|
// token > SyntaxKind.Identifer => token is a keyword |
|
// Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync |
|
(function (SyntaxKind) { |
|
SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; |
|
SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; |
|
SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; |
|
SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; |
|
SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; |
|
SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; |
|
// We detect and preserve #! on the first line |
|
SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; |
|
// We detect and provide better error recovery when we encounter a git merge marker. This |
|
// allows us to edit files with git-conflict markers in them in a much more pleasant manner. |
|
SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; |
|
// Literals |
|
SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; |
|
SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; |
|
SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; |
|
SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; |
|
// Pseudo-literals |
|
SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; |
|
SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; |
|
SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "TemplateTail"; |
|
// Punctuation |
|
SyntaxKind[SyntaxKind["OpenBraceToken"] = 15] = "OpenBraceToken"; |
|
SyntaxKind[SyntaxKind["CloseBraceToken"] = 16] = "CloseBraceToken"; |
|
SyntaxKind[SyntaxKind["OpenParenToken"] = 17] = "OpenParenToken"; |
|
SyntaxKind[SyntaxKind["CloseParenToken"] = 18] = "CloseParenToken"; |
|
SyntaxKind[SyntaxKind["OpenBracketToken"] = 19] = "OpenBracketToken"; |
|
SyntaxKind[SyntaxKind["CloseBracketToken"] = 20] = "CloseBracketToken"; |
|
SyntaxKind[SyntaxKind["DotToken"] = 21] = "DotToken"; |
|
SyntaxKind[SyntaxKind["DotDotDotToken"] = 22] = "DotDotDotToken"; |
|
SyntaxKind[SyntaxKind["SemicolonToken"] = 23] = "SemicolonToken"; |
|
SyntaxKind[SyntaxKind["CommaToken"] = 24] = "CommaToken"; |
|
SyntaxKind[SyntaxKind["LessThanToken"] = 25] = "LessThanToken"; |
|
SyntaxKind[SyntaxKind["LessThanSlashToken"] = 26] = "LessThanSlashToken"; |
|
SyntaxKind[SyntaxKind["GreaterThanToken"] = 27] = "GreaterThanToken"; |
|
SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 28] = "LessThanEqualsToken"; |
|
SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 29] = "GreaterThanEqualsToken"; |
|
SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 30] = "EqualsEqualsToken"; |
|
SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 31] = "ExclamationEqualsToken"; |
|
SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 32] = "EqualsEqualsEqualsToken"; |
|
SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 33] = "ExclamationEqualsEqualsToken"; |
|
SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 34] = "EqualsGreaterThanToken"; |
|
SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; |
|
SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; |
|
SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; |
|
SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 38] = "AsteriskAsteriskToken"; |
|
SyntaxKind[SyntaxKind["SlashToken"] = 39] = "SlashToken"; |
|
SyntaxKind[SyntaxKind["PercentToken"] = 40] = "PercentToken"; |
|
SyntaxKind[SyntaxKind["PlusPlusToken"] = 41] = "PlusPlusToken"; |
|
SyntaxKind[SyntaxKind["MinusMinusToken"] = 42] = "MinusMinusToken"; |
|
SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 43] = "LessThanLessThanToken"; |
|
SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanToken"; |
|
SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanGreaterThanToken"; |
|
SyntaxKind[SyntaxKind["AmpersandToken"] = 46] = "AmpersandToken"; |
|
SyntaxKind[SyntaxKind["BarToken"] = 47] = "BarToken"; |
|
SyntaxKind[SyntaxKind["CaretToken"] = 48] = "CaretToken"; |
|
SyntaxKind[SyntaxKind["ExclamationToken"] = 49] = "ExclamationToken"; |
|
SyntaxKind[SyntaxKind["TildeToken"] = 50] = "TildeToken"; |
|
SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 51] = "AmpersandAmpersandToken"; |
|
SyntaxKind[SyntaxKind["BarBarToken"] = 52] = "BarBarToken"; |
|
SyntaxKind[SyntaxKind["QuestionToken"] = 53] = "QuestionToken"; |
|
SyntaxKind[SyntaxKind["ColonToken"] = 54] = "ColonToken"; |
|
SyntaxKind[SyntaxKind["AtToken"] = 55] = "AtToken"; |
|
// Assignments |
|
SyntaxKind[SyntaxKind["EqualsToken"] = 56] = "EqualsToken"; |
|
SyntaxKind[SyntaxKind["PlusEqualsToken"] = 57] = "PlusEqualsToken"; |
|
SyntaxKind[SyntaxKind["MinusEqualsToken"] = 58] = "MinusEqualsToken"; |
|
SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 59] = "AsteriskEqualsToken"; |
|
SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 60] = "AsteriskAsteriskEqualsToken"; |
|
SyntaxKind[SyntaxKind["SlashEqualsToken"] = 61] = "SlashEqualsToken"; |
|
SyntaxKind[SyntaxKind["PercentEqualsToken"] = 62] = "PercentEqualsToken"; |
|
SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 63] = "LessThanLessThanEqualsToken"; |
|
SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 64] = "GreaterThanGreaterThanEqualsToken"; |
|
SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanGreaterThanEqualsToken"; |
|
SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 66] = "AmpersandEqualsToken"; |
|
SyntaxKind[SyntaxKind["BarEqualsToken"] = 67] = "BarEqualsToken"; |
|
SyntaxKind[SyntaxKind["CaretEqualsToken"] = 68] = "CaretEqualsToken"; |
|
// Identifiers |
|
SyntaxKind[SyntaxKind["Identifier"] = 69] = "Identifier"; |
|
// Reserved words |
|
SyntaxKind[SyntaxKind["BreakKeyword"] = 70] = "BreakKeyword"; |
|
SyntaxKind[SyntaxKind["CaseKeyword"] = 71] = "CaseKeyword"; |
|
SyntaxKind[SyntaxKind["CatchKeyword"] = 72] = "CatchKeyword"; |
|
SyntaxKind[SyntaxKind["ClassKeyword"] = 73] = "ClassKeyword"; |
|
SyntaxKind[SyntaxKind["ConstKeyword"] = 74] = "ConstKeyword"; |
|
SyntaxKind[SyntaxKind["ContinueKeyword"] = 75] = "ContinueKeyword"; |
|
SyntaxKind[SyntaxKind["DebuggerKeyword"] = 76] = "DebuggerKeyword"; |
|
SyntaxKind[SyntaxKind["DefaultKeyword"] = 77] = "DefaultKeyword"; |
|
SyntaxKind[SyntaxKind["DeleteKeyword"] = 78] = "DeleteKeyword"; |
|
SyntaxKind[SyntaxKind["DoKeyword"] = 79] = "DoKeyword"; |
|
SyntaxKind[SyntaxKind["ElseKeyword"] = 80] = "ElseKeyword"; |
|
SyntaxKind[SyntaxKind["EnumKeyword"] = 81] = "EnumKeyword"; |
|
SyntaxKind[SyntaxKind["ExportKeyword"] = 82] = "ExportKeyword"; |
|
SyntaxKind[SyntaxKind["ExtendsKeyword"] = 83] = "ExtendsKeyword"; |
|
SyntaxKind[SyntaxKind["FalseKeyword"] = 84] = "FalseKeyword"; |
|
SyntaxKind[SyntaxKind["FinallyKeyword"] = 85] = "FinallyKeyword"; |
|
SyntaxKind[SyntaxKind["ForKeyword"] = 86] = "ForKeyword"; |
|
SyntaxKind[SyntaxKind["FunctionKeyword"] = 87] = "FunctionKeyword"; |
|
SyntaxKind[SyntaxKind["IfKeyword"] = 88] = "IfKeyword"; |
|
SyntaxKind[SyntaxKind["ImportKeyword"] = 89] = "ImportKeyword"; |
|
SyntaxKind[SyntaxKind["InKeyword"] = 90] = "InKeyword"; |
|
SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 91] = "InstanceOfKeyword"; |
|
SyntaxKind[SyntaxKind["NewKeyword"] = 92] = "NewKeyword"; |
|
SyntaxKind[SyntaxKind["NullKeyword"] = 93] = "NullKeyword"; |
|
SyntaxKind[SyntaxKind["ReturnKeyword"] = 94] = "ReturnKeyword"; |
|
SyntaxKind[SyntaxKind["SuperKeyword"] = 95] = "SuperKeyword"; |
|
SyntaxKind[SyntaxKind["SwitchKeyword"] = 96] = "SwitchKeyword"; |
|
SyntaxKind[SyntaxKind["ThisKeyword"] = 97] = "ThisKeyword"; |
|
SyntaxKind[SyntaxKind["ThrowKeyword"] = 98] = "ThrowKeyword"; |
|
SyntaxKind[SyntaxKind["TrueKeyword"] = 99] = "TrueKeyword"; |
|
SyntaxKind[SyntaxKind["TryKeyword"] = 100] = "TryKeyword"; |
|
SyntaxKind[SyntaxKind["TypeOfKeyword"] = 101] = "TypeOfKeyword"; |
|
SyntaxKind[SyntaxKind["VarKeyword"] = 102] = "VarKeyword"; |
|
SyntaxKind[SyntaxKind["VoidKeyword"] = 103] = "VoidKeyword"; |
|
SyntaxKind[SyntaxKind["WhileKeyword"] = 104] = "WhileKeyword"; |
|
SyntaxKind[SyntaxKind["WithKeyword"] = 105] = "WithKeyword"; |
|
// Strict mode reserved words |
|
SyntaxKind[SyntaxKind["ImplementsKeyword"] = 106] = "ImplementsKeyword"; |
|
SyntaxKind[SyntaxKind["InterfaceKeyword"] = 107] = "InterfaceKeyword"; |
|
SyntaxKind[SyntaxKind["LetKeyword"] = 108] = "LetKeyword"; |
|
SyntaxKind[SyntaxKind["PackageKeyword"] = 109] = "PackageKeyword"; |
|
SyntaxKind[SyntaxKind["PrivateKeyword"] = 110] = "PrivateKeyword"; |
|
SyntaxKind[SyntaxKind["ProtectedKeyword"] = 111] = "ProtectedKeyword"; |
|
SyntaxKind[SyntaxKind["PublicKeyword"] = 112] = "PublicKeyword"; |
|
SyntaxKind[SyntaxKind["StaticKeyword"] = 113] = "StaticKeyword"; |
|
SyntaxKind[SyntaxKind["YieldKeyword"] = 114] = "YieldKeyword"; |
|
// Contextual keywords |
|
SyntaxKind[SyntaxKind["AbstractKeyword"] = 115] = "AbstractKeyword"; |
|
SyntaxKind[SyntaxKind["AsKeyword"] = 116] = "AsKeyword"; |
|
SyntaxKind[SyntaxKind["AnyKeyword"] = 117] = "AnyKeyword"; |
|
SyntaxKind[SyntaxKind["AsyncKeyword"] = 118] = "AsyncKeyword"; |
|
SyntaxKind[SyntaxKind["AwaitKeyword"] = 119] = "AwaitKeyword"; |
|
SyntaxKind[SyntaxKind["BooleanKeyword"] = 120] = "BooleanKeyword"; |
|
SyntaxKind[SyntaxKind["ConstructorKeyword"] = 121] = "ConstructorKeyword"; |
|
SyntaxKind[SyntaxKind["DeclareKeyword"] = 122] = "DeclareKeyword"; |
|
SyntaxKind[SyntaxKind["GetKeyword"] = 123] = "GetKeyword"; |
|
SyntaxKind[SyntaxKind["IsKeyword"] = 124] = "IsKeyword"; |
|
SyntaxKind[SyntaxKind["ModuleKeyword"] = 125] = "ModuleKeyword"; |
|
SyntaxKind[SyntaxKind["NamespaceKeyword"] = 126] = "NamespaceKeyword"; |
|
SyntaxKind[SyntaxKind["RequireKeyword"] = 127] = "RequireKeyword"; |
|
SyntaxKind[SyntaxKind["NumberKeyword"] = 128] = "NumberKeyword"; |
|
SyntaxKind[SyntaxKind["SetKeyword"] = 129] = "SetKeyword"; |
|
SyntaxKind[SyntaxKind["StringKeyword"] = 130] = "StringKeyword"; |
|
SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; |
|
SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; |
|
SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; |
|
SyntaxKind[SyntaxKind["GlobalKeyword"] = 134] = "GlobalKeyword"; |
|
SyntaxKind[SyntaxKind["OfKeyword"] = 135] = "OfKeyword"; |
|
// Parse tree nodes |
|
// Names |
|
SyntaxKind[SyntaxKind["QualifiedName"] = 136] = "QualifiedName"; |
|
SyntaxKind[SyntaxKind["ComputedPropertyName"] = 137] = "ComputedPropertyName"; |
|
// Signature elements |
|
SyntaxKind[SyntaxKind["TypeParameter"] = 138] = "TypeParameter"; |
|
SyntaxKind[SyntaxKind["Parameter"] = 139] = "Parameter"; |
|
SyntaxKind[SyntaxKind["Decorator"] = 140] = "Decorator"; |
|
// TypeMember |
|
SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; |
|
SyntaxKind[SyntaxKind["PropertyDeclaration"] = 142] = "PropertyDeclaration"; |
|
SyntaxKind[SyntaxKind["MethodSignature"] = 143] = "MethodSignature"; |
|
SyntaxKind[SyntaxKind["MethodDeclaration"] = 144] = "MethodDeclaration"; |
|
SyntaxKind[SyntaxKind["Constructor"] = 145] = "Constructor"; |
|
SyntaxKind[SyntaxKind["GetAccessor"] = 146] = "GetAccessor"; |
|
SyntaxKind[SyntaxKind["SetAccessor"] = 147] = "SetAccessor"; |
|
SyntaxKind[SyntaxKind["CallSignature"] = 148] = "CallSignature"; |
|
SyntaxKind[SyntaxKind["ConstructSignature"] = 149] = "ConstructSignature"; |
|
SyntaxKind[SyntaxKind["IndexSignature"] = 150] = "IndexSignature"; |
|
// Type |
|
SyntaxKind[SyntaxKind["TypePredicate"] = 151] = "TypePredicate"; |
|
SyntaxKind[SyntaxKind["TypeReference"] = 152] = "TypeReference"; |
|
SyntaxKind[SyntaxKind["FunctionType"] = 153] = "FunctionType"; |
|
SyntaxKind[SyntaxKind["ConstructorType"] = 154] = "ConstructorType"; |
|
SyntaxKind[SyntaxKind["TypeQuery"] = 155] = "TypeQuery"; |
|
SyntaxKind[SyntaxKind["TypeLiteral"] = 156] = "TypeLiteral"; |
|
SyntaxKind[SyntaxKind["ArrayType"] = 157] = "ArrayType"; |
|
SyntaxKind[SyntaxKind["TupleType"] = 158] = "TupleType"; |
|
SyntaxKind[SyntaxKind["UnionType"] = 159] = "UnionType"; |
|
SyntaxKind[SyntaxKind["IntersectionType"] = 160] = "IntersectionType"; |
|
SyntaxKind[SyntaxKind["ParenthesizedType"] = 161] = "ParenthesizedType"; |
|
SyntaxKind[SyntaxKind["ThisType"] = 162] = "ThisType"; |
|
SyntaxKind[SyntaxKind["StringLiteralType"] = 163] = "StringLiteralType"; |
|
// Binding patterns |
|
SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 164] = "ObjectBindingPattern"; |
|
SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 165] = "ArrayBindingPattern"; |
|
SyntaxKind[SyntaxKind["BindingElement"] = 166] = "BindingElement"; |
|
// Expression |
|
SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 167] = "ArrayLiteralExpression"; |
|
SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 168] = "ObjectLiteralExpression"; |
|
SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 169] = "PropertyAccessExpression"; |
|
SyntaxKind[SyntaxKind["ElementAccessExpression"] = 170] = "ElementAccessExpression"; |
|
SyntaxKind[SyntaxKind["CallExpression"] = 171] = "CallExpression"; |
|
SyntaxKind[SyntaxKind["NewExpression"] = 172] = "NewExpression"; |
|
SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 173] = "TaggedTemplateExpression"; |
|
SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 174] = "TypeAssertionExpression"; |
|
SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 175] = "ParenthesizedExpression"; |
|
SyntaxKind[SyntaxKind["FunctionExpression"] = 176] = "FunctionExpression"; |
|
SyntaxKind[SyntaxKind["ArrowFunction"] = 177] = "ArrowFunction"; |
|
SyntaxKind[SyntaxKind["DeleteExpression"] = 178] = "DeleteExpression"; |
|
SyntaxKind[SyntaxKind["TypeOfExpression"] = 179] = "TypeOfExpression"; |
|
SyntaxKind[SyntaxKind["VoidExpression"] = 180] = "VoidExpression"; |
|
SyntaxKind[SyntaxKind["AwaitExpression"] = 181] = "AwaitExpression"; |
|
SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 182] = "PrefixUnaryExpression"; |
|
SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 183] = "PostfixUnaryExpression"; |
|
SyntaxKind[SyntaxKind["BinaryExpression"] = 184] = "BinaryExpression"; |
|
SyntaxKind[SyntaxKind["ConditionalExpression"] = 185] = "ConditionalExpression"; |
|
SyntaxKind[SyntaxKind["TemplateExpression"] = 186] = "TemplateExpression"; |
|
SyntaxKind[SyntaxKind["YieldExpression"] = 187] = "YieldExpression"; |
|
SyntaxKind[SyntaxKind["SpreadElementExpression"] = 188] = "SpreadElementExpression"; |
|
SyntaxKind[SyntaxKind["ClassExpression"] = 189] = "ClassExpression"; |
|
SyntaxKind[SyntaxKind["OmittedExpression"] = 190] = "OmittedExpression"; |
|
SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 191] = "ExpressionWithTypeArguments"; |
|
SyntaxKind[SyntaxKind["AsExpression"] = 192] = "AsExpression"; |
|
// Misc |
|
SyntaxKind[SyntaxKind["TemplateSpan"] = 193] = "TemplateSpan"; |
|
SyntaxKind[SyntaxKind["SemicolonClassElement"] = 194] = "SemicolonClassElement"; |
|
// Element |
|
SyntaxKind[SyntaxKind["Block"] = 195] = "Block"; |
|
SyntaxKind[SyntaxKind["VariableStatement"] = 196] = "VariableStatement"; |
|
SyntaxKind[SyntaxKind["EmptyStatement"] = 197] = "EmptyStatement"; |
|
SyntaxKind[SyntaxKind["ExpressionStatement"] = 198] = "ExpressionStatement"; |
|
SyntaxKind[SyntaxKind["IfStatement"] = 199] = "IfStatement"; |
|
SyntaxKind[SyntaxKind["DoStatement"] = 200] = "DoStatement"; |
|
SyntaxKind[SyntaxKind["WhileStatement"] = 201] = "WhileStatement"; |
|
SyntaxKind[SyntaxKind["ForStatement"] = 202] = "ForStatement"; |
|
SyntaxKind[SyntaxKind["ForInStatement"] = 203] = "ForInStatement"; |
|
SyntaxKind[SyntaxKind["ForOfStatement"] = 204] = "ForOfStatement"; |
|
SyntaxKind[SyntaxKind["ContinueStatement"] = 205] = "ContinueStatement"; |
|
SyntaxKind[SyntaxKind["BreakStatement"] = 206] = "BreakStatement"; |
|
SyntaxKind[SyntaxKind["ReturnStatement"] = 207] = "ReturnStatement"; |
|
SyntaxKind[SyntaxKind["WithStatement"] = 208] = "WithStatement"; |
|
SyntaxKind[SyntaxKind["SwitchStatement"] = 209] = "SwitchStatement"; |
|
SyntaxKind[SyntaxKind["LabeledStatement"] = 210] = "LabeledStatement"; |
|
SyntaxKind[SyntaxKind["ThrowStatement"] = 211] = "ThrowStatement"; |
|
SyntaxKind[SyntaxKind["TryStatement"] = 212] = "TryStatement"; |
|
SyntaxKind[SyntaxKind["DebuggerStatement"] = 213] = "DebuggerStatement"; |
|
SyntaxKind[SyntaxKind["VariableDeclaration"] = 214] = "VariableDeclaration"; |
|
SyntaxKind[SyntaxKind["VariableDeclarationList"] = 215] = "VariableDeclarationList"; |
|
SyntaxKind[SyntaxKind["FunctionDeclaration"] = 216] = "FunctionDeclaration"; |
|
SyntaxKind[SyntaxKind["ClassDeclaration"] = 217] = "ClassDeclaration"; |
|
SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 218] = "InterfaceDeclaration"; |
|
SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 219] = "TypeAliasDeclaration"; |
|
SyntaxKind[SyntaxKind["EnumDeclaration"] = 220] = "EnumDeclaration"; |
|
SyntaxKind[SyntaxKind["ModuleDeclaration"] = 221] = "ModuleDeclaration"; |
|
SyntaxKind[SyntaxKind["ModuleBlock"] = 222] = "ModuleBlock"; |
|
SyntaxKind[SyntaxKind["CaseBlock"] = 223] = "CaseBlock"; |
|
SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 224] = "ImportEqualsDeclaration"; |
|
SyntaxKind[SyntaxKind["ImportDeclaration"] = 225] = "ImportDeclaration"; |
|
SyntaxKind[SyntaxKind["ImportClause"] = 226] = "ImportClause"; |
|
SyntaxKind[SyntaxKind["NamespaceImport"] = 227] = "NamespaceImport"; |
|
SyntaxKind[SyntaxKind["NamedImports"] = 228] = "NamedImports"; |
|
SyntaxKind[SyntaxKind["ImportSpecifier"] = 229] = "ImportSpecifier"; |
|
SyntaxKind[SyntaxKind["ExportAssignment"] = 230] = "ExportAssignment"; |
|
SyntaxKind[SyntaxKind["ExportDeclaration"] = 231] = "ExportDeclaration"; |
|
SyntaxKind[SyntaxKind["NamedExports"] = 232] = "NamedExports"; |
|
SyntaxKind[SyntaxKind["ExportSpecifier"] = 233] = "ExportSpecifier"; |
|
SyntaxKind[SyntaxKind["MissingDeclaration"] = 234] = "MissingDeclaration"; |
|
// Module references |
|
SyntaxKind[SyntaxKind["ExternalModuleReference"] = 235] = "ExternalModuleReference"; |
|
// JSX |
|
SyntaxKind[SyntaxKind["JsxElement"] = 236] = "JsxElement"; |
|
SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 237] = "JsxSelfClosingElement"; |
|
SyntaxKind[SyntaxKind["JsxOpeningElement"] = 238] = "JsxOpeningElement"; |
|
SyntaxKind[SyntaxKind["JsxText"] = 239] = "JsxText"; |
|
SyntaxKind[SyntaxKind["JsxClosingElement"] = 240] = "JsxClosingElement"; |
|
SyntaxKind[SyntaxKind["JsxAttribute"] = 241] = "JsxAttribute"; |
|
SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 242] = "JsxSpreadAttribute"; |
|
SyntaxKind[SyntaxKind["JsxExpression"] = 243] = "JsxExpression"; |
|
// Clauses |
|
SyntaxKind[SyntaxKind["CaseClause"] = 244] = "CaseClause"; |
|
SyntaxKind[SyntaxKind["DefaultClause"] = 245] = "DefaultClause"; |
|
SyntaxKind[SyntaxKind["HeritageClause"] = 246] = "HeritageClause"; |
|
SyntaxKind[SyntaxKind["CatchClause"] = 247] = "CatchClause"; |
|
// Property assignments |
|
SyntaxKind[SyntaxKind["PropertyAssignment"] = 248] = "PropertyAssignment"; |
|
SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 249] = "ShorthandPropertyAssignment"; |
|
// Enum |
|
SyntaxKind[SyntaxKind["EnumMember"] = 250] = "EnumMember"; |
|
// Top-level nodes |
|
SyntaxKind[SyntaxKind["SourceFile"] = 251] = "SourceFile"; |
|
// JSDoc nodes |
|
SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 252] = "JSDocTypeExpression"; |
|
// The * type |
|
SyntaxKind[SyntaxKind["JSDocAllType"] = 253] = "JSDocAllType"; |
|
// The ? type |
|
SyntaxKind[SyntaxKind["JSDocUnknownType"] = 254] = "JSDocUnknownType"; |
|
SyntaxKind[SyntaxKind["JSDocArrayType"] = 255] = "JSDocArrayType"; |
|
SyntaxKind[SyntaxKind["JSDocUnionType"] = 256] = "JSDocUnionType"; |
|
SyntaxKind[SyntaxKind["JSDocTupleType"] = 257] = "JSDocTupleType"; |
|
SyntaxKind[SyntaxKind["JSDocNullableType"] = 258] = "JSDocNullableType"; |
|
SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 259] = "JSDocNonNullableType"; |
|
SyntaxKind[SyntaxKind["JSDocRecordType"] = 260] = "JSDocRecordType"; |
|
SyntaxKind[SyntaxKind["JSDocRecordMember"] = 261] = "JSDocRecordMember"; |
|
SyntaxKind[SyntaxKind["JSDocTypeReference"] = 262] = "JSDocTypeReference"; |
|
SyntaxKind[SyntaxKind["JSDocOptionalType"] = 263] = "JSDocOptionalType"; |
|
SyntaxKind[SyntaxKind["JSDocFunctionType"] = 264] = "JSDocFunctionType"; |
|
SyntaxKind[SyntaxKind["JSDocVariadicType"] = 265] = "JSDocVariadicType"; |
|
SyntaxKind[SyntaxKind["JSDocConstructorType"] = 266] = "JSDocConstructorType"; |
|
SyntaxKind[SyntaxKind["JSDocThisType"] = 267] = "JSDocThisType"; |
|
SyntaxKind[SyntaxKind["JSDocComment"] = 268] = "JSDocComment"; |
|
SyntaxKind[SyntaxKind["JSDocTag"] = 269] = "JSDocTag"; |
|
SyntaxKind[SyntaxKind["JSDocParameterTag"] = 270] = "JSDocParameterTag"; |
|
SyntaxKind[SyntaxKind["JSDocReturnTag"] = 271] = "JSDocReturnTag"; |
|
SyntaxKind[SyntaxKind["JSDocTypeTag"] = 272] = "JSDocTypeTag"; |
|
SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 273] = "JSDocTemplateTag"; |
|
// Synthesized list |
|
SyntaxKind[SyntaxKind["SyntaxList"] = 274] = "SyntaxList"; |
|
// Enum value count |
|
SyntaxKind[SyntaxKind["Count"] = 275] = "Count"; |
|
// Markers |
|
SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; |
|
SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; |
|
SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; |
|
SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; |
|
SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; |
|
SyntaxKind[SyntaxKind["LastKeyword"] = 135] = "LastKeyword"; |
|
SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; |
|
SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; |
|
SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; |
|
SyntaxKind[SyntaxKind["LastTypeNode"] = 163] = "LastTypeNode"; |
|
SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; |
|
SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; |
|
SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; |
|
SyntaxKind[SyntaxKind["LastToken"] = 135] = "LastToken"; |
|
SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; |
|
SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; |
|
SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; |
|
SyntaxKind[SyntaxKind["LastLiteralToken"] = 11] = "LastLiteralToken"; |
|
SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; |
|
SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; |
|
SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; |
|
SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; |
|
SyntaxKind[SyntaxKind["FirstNode"] = 136] = "FirstNode"; |
|
})(ts.SyntaxKind || (ts.SyntaxKind = {})); |
|
var SyntaxKind = ts.SyntaxKind; |
|
(function (NodeFlags) { |
|
NodeFlags[NodeFlags["None"] = 0] = "None"; |
|
NodeFlags[NodeFlags["Export"] = 2] = "Export"; |
|
NodeFlags[NodeFlags["Ambient"] = 4] = "Ambient"; |
|
NodeFlags[NodeFlags["Public"] = 8] = "Public"; |
|
NodeFlags[NodeFlags["Private"] = 16] = "Private"; |
|
NodeFlags[NodeFlags["Protected"] = 32] = "Protected"; |
|
NodeFlags[NodeFlags["Static"] = 64] = "Static"; |
|
NodeFlags[NodeFlags["Abstract"] = 128] = "Abstract"; |
|
NodeFlags[NodeFlags["Async"] = 256] = "Async"; |
|
NodeFlags[NodeFlags["Default"] = 512] = "Default"; |
|
NodeFlags[NodeFlags["MultiLine"] = 1024] = "MultiLine"; |
|
NodeFlags[NodeFlags["Synthetic"] = 2048] = "Synthetic"; |
|
NodeFlags[NodeFlags["DeclarationFile"] = 4096] = "DeclarationFile"; |
|
NodeFlags[NodeFlags["Let"] = 8192] = "Let"; |
|
NodeFlags[NodeFlags["Const"] = 16384] = "Const"; |
|
NodeFlags[NodeFlags["OctalLiteral"] = 32768] = "OctalLiteral"; |
|
NodeFlags[NodeFlags["Namespace"] = 65536] = "Namespace"; |
|
NodeFlags[NodeFlags["ExportContext"] = 131072] = "ExportContext"; |
|
NodeFlags[NodeFlags["ContainsThis"] = 262144] = "ContainsThis"; |
|
NodeFlags[NodeFlags["HasImplicitReturn"] = 524288] = "HasImplicitReturn"; |
|
NodeFlags[NodeFlags["HasExplicitReturn"] = 1048576] = "HasExplicitReturn"; |
|
NodeFlags[NodeFlags["GlobalAugmentation"] = 2097152] = "GlobalAugmentation"; |
|
NodeFlags[NodeFlags["HasClassExtends"] = 4194304] = "HasClassExtends"; |
|
NodeFlags[NodeFlags["HasDecorators"] = 8388608] = "HasDecorators"; |
|
NodeFlags[NodeFlags["HasParamDecorators"] = 16777216] = "HasParamDecorators"; |
|
NodeFlags[NodeFlags["HasAsyncFunctions"] = 33554432] = "HasAsyncFunctions"; |
|
// This was picked out from the 'master' branch. |
|
// To keep the flags consistent, we're skipping a few ahead. |
|
NodeFlags[NodeFlags["HasJsxSpreadAttribute"] = 1073741824] = "HasJsxSpreadAttribute"; |
|
NodeFlags[NodeFlags["Modifier"] = 1022] = "Modifier"; |
|
NodeFlags[NodeFlags["AccessibilityModifier"] = 56] = "AccessibilityModifier"; |
|
NodeFlags[NodeFlags["BlockScoped"] = 24576] = "BlockScoped"; |
|
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 1572864] = "ReachabilityCheckFlags"; |
|
NodeFlags[NodeFlags["EmitHelperFlags"] = 62914560] = "EmitHelperFlags"; |
|
})(ts.NodeFlags || (ts.NodeFlags = {})); |
|
var NodeFlags = ts.NodeFlags; |
|
/* @internal */ |
|
(function (ParserContextFlags) { |
|
ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; |
|
// If this node was parsed in a context where 'in-expressions' are not allowed. |
|
ParserContextFlags[ParserContextFlags["DisallowIn"] = 1] = "DisallowIn"; |
|
// If this node was parsed in the 'yield' context created when parsing a generator. |
|
ParserContextFlags[ParserContextFlags["Yield"] = 2] = "Yield"; |
|
// If this node was parsed as part of a decorator |
|
ParserContextFlags[ParserContextFlags["Decorator"] = 4] = "Decorator"; |
|
// If this node was parsed in the 'await' context created when parsing an async function. |
|
ParserContextFlags[ParserContextFlags["Await"] = 8] = "Await"; |
|
// If the parser encountered an error when parsing the code that created this node. Note |
|
// the parser only sets this directly on the node it creates right after encountering the |
|
// error. |
|
ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 16] = "ThisNodeHasError"; |
|
// This node was parsed in a JavaScript file and can be processed differently. For example |
|
// its type can be specified usign a JSDoc comment. |
|
ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 32] = "JavaScriptFile"; |
|
// Context flags set directly by the parser. |
|
ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 63] = "ParserGeneratedFlags"; |
|
// Exclude these flags when parsing a Type |
|
ParserContextFlags[ParserContextFlags["TypeExcludesFlags"] = 10] = "TypeExcludesFlags"; |
|
// Context flags computed by aggregating child flags upwards. |
|
// Used during incremental parsing to determine if this node or any of its children had an |
|
// error. Computed only once and then cached. |
|
ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 64] = "ThisNodeOrAnySubNodesHasError"; |
|
// Used to know if we've computed data from children and cached it in this node. |
|
ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 128] = "HasAggregatedChildData"; |
|
})(ts.ParserContextFlags || (ts.ParserContextFlags = {})); |
|
var ParserContextFlags = ts.ParserContextFlags; |
|
(function (JsxFlags) { |
|
JsxFlags[JsxFlags["None"] = 0] = "None"; |
|
/** An element from a named property of the JSX.IntrinsicElements interface */ |
|
JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; |
|
/** An element inferred from the string index signature of the JSX.IntrinsicElements interface */ |
|
JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; |
|
/** An element backed by a class, class-like, or function value */ |
|
JsxFlags[JsxFlags["ValueElement"] = 4] = "ValueElement"; |
|
/** Element resolution failed */ |
|
JsxFlags[JsxFlags["UnknownElement"] = 16] = "UnknownElement"; |
|
JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; |
|
})(ts.JsxFlags || (ts.JsxFlags = {})); |
|
var JsxFlags = ts.JsxFlags; |
|
/* @internal */ |
|
(function (RelationComparisonResult) { |
|
RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; |
|
RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; |
|
RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; |
|
})(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); |
|
var RelationComparisonResult = ts.RelationComparisonResult; |
|
var OperationCanceledException = (function () { |
|
function OperationCanceledException() { |
|
} |
|
return OperationCanceledException; |
|
}()); |
|
ts.OperationCanceledException = OperationCanceledException; |
|
/** Return code used by getEmitOutput function to indicate status of the function */ |
|
(function (ExitStatus) { |
|
// Compiler ran successfully. Either this was a simple do-nothing compilation (for example, |
|
// when -version or -help was provided, or this was a normal compilation, no diagnostics |
|
// were produced, and all outputs were generated successfully. |
|
ExitStatus[ExitStatus["Success"] = 0] = "Success"; |
|
// Diagnostics were produced and because of them no code was generated. |
|
ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; |
|
// Diagnostics were produced and outputs were generated in spite of them. |
|
ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; |
|
})(ts.ExitStatus || (ts.ExitStatus = {})); |
|
var ExitStatus = ts.ExitStatus; |
|
(function (TypeFormatFlags) { |
|
TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; |
|
TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; |
|
TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; |
|
TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; |
|
TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; |
|
TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; |
|
TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; |
|
TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; |
|
TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; |
|
})(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); |
|
var TypeFormatFlags = ts.TypeFormatFlags; |
|
(function (SymbolFormatFlags) { |
|
SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; |
|
// Write symbols's type argument if it is instantiated symbol |
|
// eg. class C<T> { p: T } <-- Show p as C<T>.p here |
|
// var a: C<number>; |
|
// var p = a.p; <--- Here p is property of C<number> so show it as C<number>.p instead of just C.p |
|
SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; |
|
// Use only external alias information to get the symbol name in the given context |
|
// eg. module m { export class c { } } import x = m.c; |
|
// When this flag is specified m.c will be used to refer to the class instead of alias symbol x |
|
SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; |
|
})(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); |
|
var SymbolFormatFlags = ts.SymbolFormatFlags; |
|
/* @internal */ |
|
(function (SymbolAccessibility) { |
|
SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; |
|
SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; |
|
SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; |
|
})(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); |
|
var SymbolAccessibility = ts.SymbolAccessibility; |
|
(function (TypePredicateKind) { |
|
TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; |
|
TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; |
|
})(ts.TypePredicateKind || (ts.TypePredicateKind = {})); |
|
var TypePredicateKind = ts.TypePredicateKind; |
|
/** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator |
|
* metadata */ |
|
/* @internal */ |
|
(function (TypeReferenceSerializationKind) { |
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; |
|
// should be emitted using a safe fallback. |
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; |
|
// function that can be reached at runtime (e.g. a `class` |
|
// declaration or a `var` declaration for the static side |
|
// of a type, such as the global `Promise` type in lib.d.ts). |
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; |
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; |
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; |
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; |
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; |
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; |
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; |
|
// with call signatures. |
|
TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "ObjectType"; |
|
})(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); |
|
var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; |
|
(function (SymbolFlags) { |
|
SymbolFlags[SymbolFlags["None"] = 0] = "None"; |
|
SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; |
|
SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; |
|
SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; |
|
SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; |
|
SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; |
|
SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; |
|
SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; |
|
SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; |
|
SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; |
|
SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; |
|
SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; |
|
SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; |
|
SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; |
|
SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; |
|
SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; |
|
SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; |
|
SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; |
|
SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; |
|
SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; |
|
SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; |
|
SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; |
|
SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; |
|
SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; |
|
SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; |
|
SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; |
|
SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; |
|
SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; |
|
SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; |
|
SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; |
|
SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; |
|
SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; |
|
SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; |
|
SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; |
|
SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; |
|
SymbolFlags[SymbolFlags["Type"] = 793056] = "Type"; |
|
SymbolFlags[SymbolFlags["Namespace"] = 1536] = "Namespace"; |
|
SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; |
|
SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; |
|
// Variables can be redeclared, but can not redeclare a block-scoped declaration with the |
|
// same name, or any other value that is not a variable, e.g. ValueModule or Class |
|
SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; |
|
// Block-scoped declarations are not allowed to be re-declared |
|
// they can not merge with anything in the value space |
|
SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; |
|
SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; |
|
SymbolFlags[SymbolFlags["PropertyExcludes"] = 107455] = "PropertyExcludes"; |
|
SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 107455] = "EnumMemberExcludes"; |
|
SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; |
|
SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; |
|
SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792960] = "InterfaceExcludes"; |
|
SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; |
|
SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; |
|
SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; |
|
SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; |
|
SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; |
|
SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; |
|
SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; |
|
SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530912] = "TypeParameterExcludes"; |
|
SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793056] = "TypeAliasExcludes"; |
|
SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; |
|
SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; |
|
SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; |
|
SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; |
|
SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; |
|
SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; |
|
SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; |
|
SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; |
|
/* @internal */ |
|
// The set of things we consider semantically classifiable. Used to speed up the LS during |
|
// classification. |
|
SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; |
|
})(ts.SymbolFlags || (ts.SymbolFlags = {})); |
|
var SymbolFlags = ts.SymbolFlags; |
|
/* @internal */ |
|
(function (NodeCheckFlags) { |
|
NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; |
|
NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; |
|
NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; |
|
NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; |
|
NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; |
|
NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; |
|
NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; |
|
NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; |
|
NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; |
|
// Values for enum members have been computed, and any errors have been reported for them. |
|
NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; |
|
NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; |
|
NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; |
|
NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; |
|
NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; |
|
NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; |
|
NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; |
|
NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; |
|
})(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); |
|
var NodeCheckFlags = ts.NodeCheckFlags; |
|
(function (TypeFlags) { |
|
TypeFlags[TypeFlags["Any"] = 1] = "Any"; |
|
TypeFlags[TypeFlags["String"] = 2] = "String"; |
|
TypeFlags[TypeFlags["Number"] = 4] = "Number"; |
|
TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; |
|
TypeFlags[TypeFlags["Void"] = 16] = "Void"; |
|
TypeFlags[TypeFlags["Undefined"] = 32] = "Undefined"; |
|
TypeFlags[TypeFlags["Null"] = 64] = "Null"; |
|
TypeFlags[TypeFlags["Enum"] = 128] = "Enum"; |
|
TypeFlags[TypeFlags["StringLiteral"] = 256] = "StringLiteral"; |
|
TypeFlags[TypeFlags["TypeParameter"] = 512] = "TypeParameter"; |
|
TypeFlags[TypeFlags["Class"] = 1024] = "Class"; |
|
TypeFlags[TypeFlags["Interface"] = 2048] = "Interface"; |
|
TypeFlags[TypeFlags["Reference"] = 4096] = "Reference"; |
|
TypeFlags[TypeFlags["Tuple"] = 8192] = "Tuple"; |
|
TypeFlags[TypeFlags["Union"] = 16384] = "Union"; |
|
TypeFlags[TypeFlags["Intersection"] = 32768] = "Intersection"; |
|
TypeFlags[TypeFlags["Anonymous"] = 65536] = "Anonymous"; |
|
TypeFlags[TypeFlags["Instantiated"] = 131072] = "Instantiated"; |
|
/* @internal */ |
|
TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; |
|
TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; |
|
/* @internal */ |
|
TypeFlags[TypeFlags["FreshObjectLiteral"] = 1048576] = "FreshObjectLiteral"; |
|
/* @internal */ |
|
TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 2097152] = "ContainsUndefinedOrNull"; |
|
/* @internal */ |
|
TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; |
|
/* @internal */ |
|
TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; |
|
TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; |
|
TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType"; |
|
TypeFlags[TypeFlags["ObjectLiteralPatternWithComputedProperties"] = 67108864] = "ObjectLiteralPatternWithComputedProperties"; |
|
/* @internal */ |
|
TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; |
|
/* @internal */ |
|
TypeFlags[TypeFlags["Primitive"] = 16777726] = "Primitive"; |
|
TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; |
|
TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; |
|
TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; |
|
TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; |
|
TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; |
|
/* @internal */ |
|
TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; |
|
/* @internal */ |
|
TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; |
|
})(ts.TypeFlags || (ts.TypeFlags = {})); |
|
var TypeFlags = ts.TypeFlags; |
|
(function (SignatureKind) { |
|
SignatureKind[SignatureKind["Call"] = 0] = "Call"; |
|
SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; |
|
})(ts.SignatureKind || (ts.SignatureKind = {})); |
|
var SignatureKind = ts.SignatureKind; |
|
(function (IndexKind) { |
|
IndexKind[IndexKind["String"] = 0] = "String"; |
|
IndexKind[IndexKind["Number"] = 1] = "Number"; |
|
})(ts.IndexKind || (ts.IndexKind = {})); |
|
var IndexKind = ts.IndexKind; |
|
/* @internal */ |
|
(function (SpecialPropertyAssignmentKind) { |
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; |
|
/// exports.name = expr |
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; |
|
/// module.exports = expr |
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; |
|
/// className.prototype.name = expr |
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; |
|
/// this.name = expr |
|
SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; |
|
})(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); |
|
var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; |
|
(function (DiagnosticCategory) { |
|
DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; |
|
DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; |
|
DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; |
|
})(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); |
|
var DiagnosticCategory = ts.DiagnosticCategory; |
|
(function (ModuleResolutionKind) { |
|
ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; |
|
ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; |
|
})(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); |
|
var ModuleResolutionKind = ts.ModuleResolutionKind; |
|
(function (ModuleKind) { |
|
ModuleKind[ModuleKind["None"] = 0] = "None"; |
|
ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; |
|
ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; |
|
ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; |
|
ModuleKind[ModuleKind["System"] = 4] = "System"; |
|
ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; |
|
ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; |
|
})(ts.ModuleKind || (ts.ModuleKind = {})); |
|
var ModuleKind = ts.ModuleKind; |
|
(function (JsxEmit) { |
|
JsxEmit[JsxEmit["None"] = 0] = "None"; |
|
JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; |
|
JsxEmit[JsxEmit["React"] = 2] = "React"; |
|
})(ts.JsxEmit || (ts.JsxEmit = {})); |
|
var JsxEmit = ts.JsxEmit; |
|
(function (NewLineKind) { |
|
NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; |
|
NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; |
|
})(ts.NewLineKind || (ts.NewLineKind = {})); |
|
var NewLineKind = ts.NewLineKind; |
|
(function (ScriptKind) { |
|
ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; |
|
ScriptKind[ScriptKind["JS"] = 1] = "JS"; |
|
ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; |
|
ScriptKind[ScriptKind["TS"] = 3] = "TS"; |
|
ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; |
|
})(ts.ScriptKind || (ts.ScriptKind = {})); |
|
var ScriptKind = ts.ScriptKind; |
|
(function (ScriptTarget) { |
|
ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; |
|
ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; |
|
ScriptTarget[ScriptTarget["ES6"] = 2] = "ES6"; |
|
ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; |
|
ScriptTarget[ScriptTarget["Latest"] = 2] = "Latest"; |
|
})(ts.ScriptTarget || (ts.ScriptTarget = {})); |
|
var ScriptTarget = ts.ScriptTarget; |
|
(function (LanguageVariant) { |
|
LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; |
|
LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; |
|
})(ts.LanguageVariant || (ts.LanguageVariant = {})); |
|
var LanguageVariant = ts.LanguageVariant; |
|
/* @internal */ |
|
(function (DiagnosticStyle) { |
|
DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; |
|
DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; |
|
})(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); |
|
var DiagnosticStyle = ts.DiagnosticStyle; |
|
/* @internal */ |
|
(function (CharacterCodes) { |
|
CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; |
|
CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; |
|
CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; |
|
CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; |
|
CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; |
|
CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; |
|
CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; |
|
// Unicode 3.0 space characters |
|
CharacterCodes[CharacterCodes["space"] = 32] = "space"; |
|
CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; |
|
CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; |
|
CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; |
|
CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; |
|
CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; |
|
CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; |
|
CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; |
|
CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; |
|
CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; |
|
CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; |
|
CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; |
|
CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; |
|
CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; |
|
CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; |
|
CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; |
|
CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; |
|
CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; |
|
CharacterCodes[CharacterCodes["_"] = 95] = "_"; |
|
CharacterCodes[CharacterCodes["$"] = 36] = "$"; |
|
CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; |
|
CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; |
|
CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; |
|
CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; |
|
CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; |
|
CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; |
|
CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; |
|
CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; |
|
CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; |
|
CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; |
|
CharacterCodes[CharacterCodes["a"] = 97] = "a"; |
|
CharacterCodes[CharacterCodes["b"] = 98] = "b"; |
|
CharacterCodes[CharacterCodes["c"] = 99] = "c"; |
|
CharacterCodes[CharacterCodes["d"] = 100] = "d"; |
|
CharacterCodes[CharacterCodes["e"] = 101] = "e"; |
|
CharacterCodes[CharacterCodes["f"] = 102] = "f"; |
|
CharacterCodes[CharacterCodes["g"] = 103] = "g"; |
|
CharacterCodes[CharacterCodes["h"] = 104] = "h"; |
|
CharacterCodes[CharacterCodes["i"] = 105] = "i"; |
|
CharacterCodes[CharacterCodes["j"] = 106] = "j"; |
|
CharacterCodes[CharacterCodes["k"] = 107] = "k"; |
|
CharacterCodes[CharacterCodes["l"] = 108] = "l"; |
|
CharacterCodes[CharacterCodes["m"] = 109] = "m"; |
|
CharacterCodes[CharacterCodes["n"] = 110] = "n"; |
|
CharacterCodes[CharacterCodes["o"] = 111] = "o"; |
|
CharacterCodes[CharacterCodes["p"] = 112] = "p"; |
|
CharacterCodes[CharacterCodes["q"] = 113] = "q"; |
|
CharacterCodes[CharacterCodes["r"] = 114] = "r"; |
|
CharacterCodes[CharacterCodes["s"] = 115] = "s"; |
|
CharacterCodes[CharacterCodes["t"] = 116] = "t"; |
|
CharacterCodes[CharacterCodes["u"] = 117] = "u"; |
|
CharacterCodes[CharacterCodes["v"] = 118] = "v"; |
|
CharacterCodes[CharacterCodes["w"] = 119] = "w"; |
|
CharacterCodes[CharacterCodes["x"] = 120] = "x"; |
|
CharacterCodes[CharacterCodes["y"] = 121] = "y"; |
|
CharacterCodes[CharacterCodes["z"] = 122] = "z"; |
|
CharacterCodes[CharacterCodes["A"] = 65] = "A"; |
|
CharacterCodes[CharacterCodes["B"] = 66] = "B"; |
|
CharacterCodes[CharacterCodes["C"] = 67] = "C"; |
|
CharacterCodes[CharacterCodes["D"] = 68] = "D"; |
|
CharacterCodes[CharacterCodes["E"] = 69] = "E"; |
|
CharacterCodes[CharacterCodes["F"] = 70] = "F"; |
|
CharacterCodes[CharacterCodes["G"] = 71] = "G"; |
|
CharacterCodes[CharacterCodes["H"] = 72] = "H"; |
|
CharacterCodes[CharacterCodes["I"] = 73] = "I"; |
|
CharacterCodes[CharacterCodes["J"] = 74] = "J"; |
|
CharacterCodes[CharacterCodes["K"] = 75] = "K"; |
|
CharacterCodes[CharacterCodes["L"] = 76] = "L"; |
|
CharacterCodes[CharacterCodes["M"] = 77] = "M"; |
|
CharacterCodes[CharacterCodes["N"] = 78] = "N"; |
|
CharacterCodes[CharacterCodes["O"] = 79] = "O"; |
|
CharacterCodes[CharacterCodes["P"] = 80] = "P"; |
|
CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; |
|
CharacterCodes[CharacterCodes["R"] = 82] = "R"; |
|
CharacterCodes[CharacterCodes["S"] = 83] = "S"; |
|
CharacterCodes[CharacterCodes["T"] = 84] = "T"; |
|
CharacterCodes[CharacterCodes["U"] = 85] = "U"; |
|
CharacterCodes[CharacterCodes["V"] = 86] = "V"; |
|
CharacterCodes[CharacterCodes["W"] = 87] = "W"; |
|
CharacterCodes[CharacterCodes["X"] = 88] = "X"; |
|
CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; |
|
CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; |
|
CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; |
|
CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; |
|
CharacterCodes[CharacterCodes["at"] = 64] = "at"; |
|
CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; |
|
CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; |
|
CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; |
|
CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; |
|
CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; |
|
CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; |
|
CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; |
|
CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; |
|
CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; |
|
CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; |
|
CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; |
|
CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; |
|
CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; |
|
CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; |
|
CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; |
|
CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; |
|
CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; |
|
CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; |
|
CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; |
|
CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; |
|
CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; |
|
CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; |
|
CharacterCodes[CharacterCodes["question"] = 63] = "question"; |
|
CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; |
|
CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; |
|
CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; |
|
CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; |
|
CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; |
|
CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; |
|
CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; |
|
CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; |
|
CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; |
|
})(ts.CharacterCodes || (ts.CharacterCodes = {})); |
|
var CharacterCodes = ts.CharacterCodes; |
|
})(ts || (ts = {})); |
|
/// <reference path="types.ts"/> |
|
/* @internal */ |
|
var ts; |
|
(function (ts) { |
|
/** |
|
* Ternary values are defined such that |
|
* x & y is False if either x or y is False. |
|
* x & y is Maybe if either x or y is Maybe, but neither x or y is False. |
|
* x & y is True if both x and y are True. |
|
* x | y is False if both x and y are False. |
|
* x | y is Maybe if either x or y is Maybe, but neither x or y is True. |
|
* x | y is True if either x or y is True. |
|
*/ |
|
(function (Ternary) { |
|
Ternary[Ternary["False"] = 0] = "False"; |
|
Ternary[Ternary["Maybe"] = 1] = "Maybe"; |
|
Ternary[Ternary["True"] = -1] = "True"; |
|
})(ts.Ternary || (ts.Ternary = {})); |
|
var Ternary = ts.Ternary; |
|
function createFileMap(keyMapper) { |
|
var files = {}; |
|
return { |
|
get: get, |
|
set: set, |
|
contains: contains, |
|
remove: remove, |
|
forEachValue: forEachValueInMap, |
|
clear: clear |
|
}; |
|
function forEachValueInMap(f) { |
|
for (var key in files) { |
|
f(key, files[key]); |
|
} |
|
} |
|
// path should already be well-formed so it does not need to be normalized |
|
function get(path) { |
|
return files[toKey(path)]; |
|
} |
|
function set(path, value) { |
|
files[toKey(path)] = value; |
|
} |
|
function contains(path) { |
|
return hasProperty(files, toKey(path)); |
|
} |
|
function remove(path) { |
|
var key = toKey(path); |
|
delete files[key]; |
|
} |
|
function clear() { |
|
files = {}; |
|
} |
|
function toKey(path) { |
|
return keyMapper ? keyMapper(path) : path; |
|
} |
|
} |
|
ts.createFileMap = createFileMap; |
|
function toPath(fileName, basePath, getCanonicalFileName) { |
|
var nonCanonicalizedPath = isRootedDiskPath(fileName) |
|
? normalizePath(fileName) |
|
: getNormalizedAbsolutePath(fileName, basePath); |
|
return getCanonicalFileName(nonCanonicalizedPath); |
|
} |
|
ts.toPath = toPath; |
|
(function (Comparison) { |
|
Comparison[Comparison["LessThan"] = -1] = "LessThan"; |
|
Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; |
|
Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; |
|
})(ts.Comparison || (ts.Comparison = {})); |
|
var Comparison = ts.Comparison; |
|
/** |
|
* Iterates through 'array' by index and performs the callback on each element of array until the callback |
|
* returns a truthy value, then returns that value. |
|
* If no such value is found, the callback is applied to each element of array and undefined is returned. |
|
*/ |
|
function forEach(array, callback) { |
|
if (array) { |
|
for (var i = 0, len = array.length; i < len; i++) { |
|
var result = callback(array[i], i); |
|
if (result) { |
|
return result; |
|
} |
|
} |
|
} |
|
return undefined; |
|
} |
|
ts.forEach = forEach; |
|
function contains(array, value) { |
|
if (array) { |
|
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { |
|
var v = array_1[_i]; |
|
if (v === value) { |
|
return true; |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
ts.contains = contains; |
|
function indexOf(array, value) { |
|
if (array) { |
|
for (var i = 0, len = array.length; i < len; i++) { |
|
if (array[i] === value) { |
|
return i; |
|
} |
|
} |
|
} |
|
return -1; |
|
} |
|
ts.indexOf = indexOf; |
|
function countWhere(array, predicate) { |
|
var count = 0; |
|
if (array) { |
|
for (var _i = 0, array_2 = array; _i < array_2.length; _i++) { |
|
var v = array_2[_i]; |
|
if (predicate(v)) { |
|
count++; |
|
} |
|
} |
|
} |
|
return count; |
|
} |
|
ts.countWhere = countWhere; |
|
function filter(array, f) { |
|
var result; |
|
if (array) { |
|
result = []; |
|
for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { |
|
var item = array_3[_i]; |
|
if (f(item)) { |
|
result.push(item); |
|
} |
|
} |
|
} |
|
return result; |
|
} |
|
ts.filter = filter; |
|
function map(array, f) { |
|
var result; |
|
if (array) { |
|
result = []; |
|
for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { |
|
var v = array_4[_i]; |
|
result.push(f(v)); |
|
} |
|
} |
|
return result; |
|
} |
|
ts.map = map; |
|
function concatenate(array1, array2) { |
|
if (!array2 || !array2.length) |
|
return array1; |
|
if (!array1 || !array1.length) |
|
return array2; |
|
return array1.concat(array2); |
|
} |
|
ts.concatenate = concatenate; |
|
function deduplicate(array) { |
|
var result; |
|
if (array) { |
|
result = []; |
|
for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { |
|
var item = array_5[_i]; |
|
if (!contains(result, item)) { |
|
result.push(item); |
|
} |
|
} |
|
} |
|
return result; |
|
} |
|
ts.deduplicate = deduplicate; |
|
function sum(array, prop) { |
|
var result = 0; |
|
for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { |
|
var v = array_6[_i]; |
|
result += v[prop]; |
|
} |
|
return result; |
|
} |
|
ts.sum = sum; |
|
function addRange(to, from) { |
|
if (to && from) { |
|
for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { |
|
var v = from_1[_i]; |
|
to.push(v); |
|
} |
|
} |
|
} |
|
ts.addRange = addRange; |
|
function rangeEquals(array1, array2, pos, end) { |
|
while (pos < end) { |
|
if (array1[pos] !== array2[pos]) { |
|
return false; |
|
} |
|
pos++; |
|
} |
|
return true; |
|
} |
|
ts.rangeEquals = rangeEquals; |
|
/** |
|
* Returns the last element of an array if non-empty, undefined otherwise. |
|
*/ |
|
function lastOrUndefined(array) { |
|
if (array.length === 0) { |
|
return undefined; |
|
} |
|
return array[array.length - 1]; |
|
} |
|
ts.lastOrUndefined = lastOrUndefined; |
|
/** |
|
* Performs a binary search, finding the index at which 'value' occurs in 'array'. |
|
* If no such index is found, returns the 2's-complement of first index at which |
|
* number[index] exceeds number. |
|
* @param array A sorted array whose first element must be no larger than number |
|
* @param number The value to be searched for in the array. |
|
*/ |
|
function binarySearch(array, value) { |
|
var low = 0; |
|
var high = array.length - 1; |
|
while (low <= high) { |
|
var middle = low + ((high - low) >> 1); |
|
var midValue = array[middle]; |
|
if (midValue === value) { |
|
return middle; |
|
} |
|
else if (midValue > value) { |
|
high = middle - 1; |
|
} |
|
else { |
|
low = middle + 1; |
|
} |
|
} |
|
return ~low; |
|
} |
|
ts.binarySearch = binarySearch; |
|
function reduceLeft(array, f, initial) { |
|
if (array) { |
|
var count = array.length; |
|
if (count > 0) { |
|
var pos = 0; |
|
var result = arguments.length <= 2 ? array[pos] : initial; |
|
pos++; |
|
while (pos < count) { |
|
result = f(result, array[pos]); |
|
pos++; |
|
} |
|
return result; |
|
} |
|
} |
|
return initial; |
|
} |
|
ts.reduceLeft = reduceLeft; |
|
function reduceRight(array, f, initial) { |
|
if (array) { |
|
var pos = array.length - 1; |
|
if (pos >= 0) { |
|
var result = arguments.length <= 2 ? array[pos] : initial; |
|
pos--; |
|
while (pos >= 0) { |
|
result = f(result, array[pos]); |
|
pos--; |
|
} |
|
return result; |
|
} |
|
} |
|
return initial; |
|
} |
|
ts.reduceRight = reduceRight; |
|
var hasOwnProperty = Object.prototype.hasOwnProperty; |
|
function hasProperty(map, key) { |
|
return hasOwnProperty.call(map, key); |
|
} |
|
ts.hasProperty = hasProperty; |
|
function getKeys(map) { |
|
var keys = []; |
|
for (var key in map) { |
|
keys.push(key); |
|
} |
|
return keys; |
|
} |
|
ts.getKeys = getKeys; |
|
function getProperty(map, key) { |
|
return hasOwnProperty.call(map, key) ? map[key] : undefined; |
|
} |
|
ts.getProperty = getProperty; |
|
function isEmpty(map) { |
|
for (var id in map) { |
|
if (hasProperty(map, id)) { |
|
return false; |
|
} |
|
} |
|
return true; |
|
} |
|
ts.isEmpty = isEmpty; |
|
function clone(object) { |
|
var result = {}; |
|
for (var id in object) { |
|
result[id] = object[id]; |
|
} |
|
return result; |
|
} |
|
ts.clone = clone; |
|
function extend(first, second) { |
|
var result = {}; |
|
for (var id in first) { |
|
result[id] = first[id]; |
|
} |
|
for (var id in second) { |
|
if (!hasProperty(result, id)) { |
|
result[id] = second[id]; |
|
} |
|
} |
|
return result; |
|
} |
|
ts.extend = extend; |
|
function forEachValue(map, callback) { |
|
var result; |
|
for (var id in map) { |
|
if (result = callback(map[id])) |
|
break; |
|
} |
|
return result; |
|
} |
|
ts.forEachValue = forEachValue; |
|
function forEachKey(map, callback) { |
|
var result; |
|
for (var id in map) { |
|
if (result = callback(id)) |
|
break; |
|
} |
|
return result; |
|
} |
|
ts.forEachKey = forEachKey; |
|
function lookUp(map, key) { |
|
return hasProperty(map, key) ? map[key] : undefined; |
|
} |
|
ts.lookUp = lookUp; |
|
function copyMap(source, target) { |
|
for (var p in source) { |
|
target[p] = source[p]; |
|
} |
|
} |
|
ts.copyMap = copyMap; |
|
/** |
|
* Creates a map from the elements of an array. |
|
* |
|
* @param array the array of input elements. |
|
* @param makeKey a function that produces a key for a given element. |
|
* |
|
* This function makes no effort to avoid collisions; if any two elements produce |
|
* the same key with the given 'makeKey' function, then the element with the higher |
|
* index in the array will be the one associated with the produced key. |
|
*/ |
|
function arrayToMap(array, makeKey) { |
|
var result = {}; |
|
forEach(array, function (value) { |
|
result[makeKey(value)] = value; |
|
}); |
|
return result; |
|
} |
|
ts.arrayToMap = arrayToMap; |
|
/** |
|
* Reduce the properties of a map. |
|
* |
|
* @param map The map to reduce |
|
* @param callback An aggregation function that is called for each entry in the map |
|
* @param initial The initial value for the reduction. |
|
*/ |
|
function reduceProperties(map, callback, initial) { |
|
var result = initial; |
|
if (map) { |
|
for (var key in map) { |
|
if (hasProperty(map, key)) { |
|
result = callback(result, map[key], String(key)); |
|
} |
|
} |
|
} |
|
return result; |
|
} |
|
ts.reduceProperties = reduceProperties; |
|
/** |
|
* Tests whether a value is an array. |
|
*/ |
|
function isArray(value) { |
|
return Array.isArray ? Array.isArray(value) : value instanceof Array; |
|
} |
|
ts.isArray = isArray; |
|
function memoize(callback) { |
|
var value; |
|
return function () { |
|
if (callback) { |
|
value = callback(); |
|
callback = undefined; |
|
} |
|
return value; |
|
}; |
|
} |
|
ts.memoize = memoize; |
|
function formatStringFromArgs(text, args, baseIndex) { |
|
baseIndex = baseIndex || 0; |
|
return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); |
|
} |
|
ts.localizedDiagnosticMessages = undefined; |
|
function getLocaleSpecificMessage(message) { |
|
return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] |
|
? ts.localizedDiagnosticMessages[message.key] |
|
: message.message; |
|
} |
|
ts.getLocaleSpecificMessage = getLocaleSpecificMessage; |
|
function createFileDiagnostic(file, start, length, message) { |
|
var end = start + length; |
|
Debug.assert(start >= 0, "start must be non-negative, is " + start); |
|
Debug.assert(length >= 0, "length must be non-negative, is " + length); |
|
if (file) { |
|
Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length); |
|
Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length); |
|
} |
|
var text = getLocaleSpecificMessage(message); |
|
if (arguments.length > 4) { |
|
text = formatStringFromArgs(text, arguments, 4); |
|
} |
|
return { |
|
file: file, |
|
start: start, |
|
length: length, |
|
messageText: text, |
|
category: message.category, |
|
code: message.code |
|
}; |
|
} |
|
ts.createFileDiagnostic = createFileDiagnostic; |
|
function createCompilerDiagnostic(message) { |
|
var text = getLocaleSpecificMessage(message); |
|
if (arguments.length > 1) { |
|
text = formatStringFromArgs(text, arguments, 1); |
|
} |
|
return { |
|
file: undefined, |
|
start: undefined, |
|
length: undefined, |
|
messageText: text, |
|
category: message.category, |
|
code: message.code |
|
}; |
|
} |
|
ts.createCompilerDiagnostic = createCompilerDiagnostic; |
|
function chainDiagnosticMessages(details, message) { |
|
var text = getLocaleSpecificMessage(message); |
|
if (arguments.length > 2) { |
|
text = formatStringFromArgs(text, arguments, 2); |
|
} |
|
return { |
|
messageText: text, |
|
category: message.category, |
|
code: message.code, |
|
next: details |
|
}; |
|
} |
|
ts.chainDiagnosticMessages = chainDiagnosticMessages; |
|
function concatenateDiagnosticMessageChains(headChain, tailChain) { |
|
var lastChain = headChain; |
|
while (lastChain.next) { |
|
lastChain = lastChain.next; |
|
} |
|
lastChain.next = tailChain; |
|
return headChain; |
|
} |
|
ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; |
|
function compareValues(a, b) { |
|
if (a === b) |
|
return 0 /* EqualTo */; |
|
if (a === undefined) |
|
return -1 /* LessThan */; |
|
if (b === undefined) |
|
return 1 /* GreaterThan */; |
|
return a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; |
|
} |
|
ts.compareValues = compareValues; |
|
function getDiagnosticFileName(diagnostic) { |
|
return diagnostic.file ? diagnostic.file.fileName : undefined; |
|
} |
|
function compareDiagnostics(d1, d2) { |
|
return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) || |
|
compareValues(d1.start, d2.start) || |
|
compareValues(d1.length, d2.length) || |
|
compareValues(d1.code, d2.code) || |
|
compareMessageText(d1.messageText, d2.messageText) || |
|
0 /* EqualTo */; |
|
} |
|
ts.compareDiagnostics = compareDiagnostics; |
|
function compareMessageText(text1, text2) { |
|
while (text1 && text2) { |
|
// We still have both chains. |
|
var string1 = typeof text1 === "string" ? text1 : text1.messageText; |
|
var string2 = typeof text2 === "string" ? text2 : text2.messageText; |
|
var res = compareValues(string1, string2); |
|
if (res) { |
|
return res; |
|
} |
|
text1 = typeof text1 === "string" ? undefined : text1.next; |
|
text2 = typeof text2 === "string" ? undefined : text2.next; |
|
} |
|
if (!text1 && !text2) { |
|
// if the chains are done, then these messages are the same. |
|
return 0 /* EqualTo */; |
|
} |
|
// We still have one chain remaining. The shorter chain should come first. |
|
return text1 ? 1 /* GreaterThan */ : -1 /* LessThan */; |
|
} |
|
function sortAndDeduplicateDiagnostics(diagnostics) { |
|
return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics)); |
|
} |
|
ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; |
|
function deduplicateSortedDiagnostics(diagnostics) { |
|
if (diagnostics.length < 2) { |
|
return diagnostics; |
|
} |
|
var newDiagnostics = [diagnostics[0]]; |
|
var previousDiagnostic = diagnostics[0]; |
|
for (var i = 1; i < diagnostics.length; i++) { |
|
var currentDiagnostic = diagnostics[i]; |
|
var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0 /* EqualTo */; |
|
if (!isDupe) { |
|
newDiagnostics.push(currentDiagnostic); |
|
previousDiagnostic = currentDiagnostic; |
|
} |
|
} |
|
return newDiagnostics; |
|
} |
|
ts.deduplicateSortedDiagnostics = deduplicateSortedDiagnostics; |
|
function normalizeSlashes(path) { |
|
return path.replace(/\\/g, "/"); |
|
} |
|
ts.normalizeSlashes = normalizeSlashes; |
|
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files") |
|
function getRootLength(path) { |
|
if (path.charCodeAt(0) === 47 /* slash */) { |
|
if (path.charCodeAt(1) !== 47 /* slash */) |
|
return 1; |
|
var p1 = path.indexOf("/", 2); |
|
if (p1 < 0) |
|
return 2; |
|
var p2 = path.indexOf("/", p1 + 1); |
|
if (p2 < 0) |
|
return p1 + 1; |
|
return p2 + 1; |
|
} |
|
if (path.charCodeAt(1) === 58 /* colon */) { |
|
if (path.charCodeAt(2) === 47 /* slash */) |
|
return 3; |
|
return 2; |
|
} |
|
// Per RFC 1738 'file' URI schema has the shape file://<host>/<path> |
|
// if <host> is omitted then it is assumed that host value is 'localhost', |
|
// however slash after the omitted <host> is not removed. |
|
// file:///folder1/file1 - this is a correct URI |
|
// file://folder2/file2 - this is an incorrect URI |
|
if (path.lastIndexOf("file:///", 0) === 0) { |
|
return "file:///".length; |
|
} |
|
var idx = path.indexOf("://"); |
|
if (idx !== -1) { |
|
return idx + "://".length; |
|
} |
|
return 0; |
|
} |
|
ts.getRootLength = getRootLength; |
|
ts.directorySeparator = "/"; |
|
function getNormalizedParts(normalizedSlashedPath, rootLength) { |
|
var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); |
|
var normalized = []; |
|
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { |
|
var part = parts_1[_i]; |
|
if (part !== ".") { |
|
if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { |
|
normalized.pop(); |
|
} |
|
else { |
|
// A part may be an empty string (which is 'falsy') if the path had consecutive slashes, |
|
// e.g. "path//file.ts". Drop these before re-joining the parts. |
|
if (part) { |
|
normalized.push(part); |
|
} |
|
} |
|
} |
|
} |
|
return normalized; |
|
} |
|
function normalizePath(path) { |
|
path = normalizeSlashes(path); |
|
var rootLength = getRootLength(path); |
|
var normalized = getNormalizedParts(path, rootLength); |
|
return path.substr(0, rootLength) + normalized.join(ts.directorySeparator); |
|
} |
|
ts.normalizePath = normalizePath; |
|
function getDirectoryPath(path) { |
|
return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator))); |
|
} |
|
ts.getDirectoryPath = getDirectoryPath; |
|
function isUrl(path) { |
|
return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; |
|
} |
|
ts.isUrl = isUrl; |
|
function isRootedDiskPath(path) { |
|
return getRootLength(path) !== 0; |
|
} |
|
ts.isRootedDiskPath = isRootedDiskPath; |
|
function normalizedPathComponents(path, rootLength) { |
|
var normalizedParts = getNormalizedParts(path, rootLength); |
|
return [path.substr(0, rootLength)].concat(normalizedParts); |
|
} |
|
function getNormalizedPathComponents(path, currentDirectory) { |
|
path = normalizeSlashes(path); |
|
var rootLength = getRootLength(path); |
|
if (rootLength === 0) { |
|
// If the path is not rooted it is relative to current directory |
|
path = combinePaths(normalizeSlashes(currentDirectory), path); |
|
rootLength = getRootLength(path); |
|
} |
|
return normalizedPathComponents(path, rootLength); |
|
} |
|
ts.getNormalizedPathComponents = getNormalizedPathComponents; |
|
function getNormalizedAbsolutePath(fileName, currentDirectory) { |
|
return getNormalizedPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); |
|
} |
|
ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; |
|
function getNormalizedPathFromPathComponents(pathComponents) { |
|
if (pathComponents && pathComponents.length) { |
|
return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator); |
|
} |
|
} |
|
ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; |
|
function getNormalizedPathComponentsOfUrl(url) { |
|
// Get root length of http://www.website.com/folder1/foler2/ |
|
// In this example the root is: http://www.website.com/ |
|
// normalized path components should be ["http://www.website.com/", "folder1", "folder2"] |
|
var urlLength = url.length; |
|
// Initial root length is http:// part |
|
var rootLength = url.indexOf("://") + "://".length; |
|
while (rootLength < urlLength) { |
|
// Consume all immediate slashes in the protocol |
|
// eg.initial rootlength is just file:// but it needs to consume another "/" in file:/// |
|
if (url.charCodeAt(rootLength) === 47 /* slash */) { |
|
rootLength++; |
|
} |
|
else { |
|
// non slash character means we continue proceeding to next component of root search |
|
break; |
|
} |
|
} |
|
// there are no parts after http:// just return current string as the pathComponent |
|
if (rootLength === urlLength) { |
|
return [url]; |
|
} |
|
// Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://) |
|
var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); |
|
if (indexOfNextSlash !== -1) { |
|
// Found the "/" after the website.com so the root is length of http://www.website.com/ |
|
// and get components afetr the root normally like any other folder components |
|
rootLength = indexOfNextSlash + 1; |
|
return normalizedPathComponents(url, rootLength); |
|
} |
|
else { |
|
// Can't find the host assume the rest of the string as component |
|
// but make sure we append "/" to it as root is not joined using "/" |
|
// eg. if url passed in was http://website.com we want to use root as [http://website.com/] |
|
// so that other path manipulations will be correct and it can be merged with relative paths correctly |
|
return [url + ts.directorySeparator]; |
|
} |
|
} |
|
function getNormalizedPathOrUrlComponents(pathOrUrl, currentDirectory) { |
|
if (isUrl(pathOrUrl)) { |
|
return getNormalizedPathComponentsOfUrl(pathOrUrl); |
|
} |
|
else { |
|
return getNormalizedPathComponents(pathOrUrl, currentDirectory); |
|
} |
|
} |
|
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { |
|
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); |
|
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); |
|
if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { |
|
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name |
|
// that is ["test", "cases", ""] needs to be actually ["test", "cases"] |
|
directoryComponents.length--; |
|
} |
|
// Find the component that differs |
|
var joinStartIndex; |
|
for (joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { |
|
if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { |
|
break; |
|
} |
|
} |
|
// Get the relative path |
|
if (joinStartIndex) { |
|
var relativePath = ""; |
|
var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); |
|
for (; joinStartIndex < directoryComponents.length; joinStartIndex++) { |
|
if (directoryComponents[joinStartIndex] !== "") { |
|
relativePath = relativePath + ".." + ts.directorySeparator; |
|
} |
|
} |
|
return relativePath + relativePathComponents.join(ts.directorySeparator); |
|
} |
|
// Cant find the relative path, get the absolute path |
|
var absolutePath = getNormalizedPathFromPathComponents(pathComponents); |
|
if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) { |
|
absolutePath = "file:///" + absolutePath; |
|
} |
|
return absolutePath; |
|
} |
|
ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; |
|
function getBaseFileName(path) { |
|
if (path === undefined) { |
|
return undefined; |
|
} |
|
var i = path.lastIndexOf(ts.directorySeparator); |
|
return i < 0 ? path : path.substring(i + 1); |
|
} |
|
ts.getBaseFileName = getBaseFileName; |
|
function combinePaths(path1, path2) { |
|
if (!(path1 && path1.length)) |
|
return path2; |
|
if (!(path2 && path2.length)) |
|
return path1; |
|
if (getRootLength(path2) !== 0) |
|
return path2; |
|
if (path1.charAt(path1.length - 1) === ts.directorySeparator) |
|
return path1 + path2; |
|
return path1 + ts.directorySeparator + path2; |
|
} |
|
ts.combinePaths = combinePaths; |
|
function fileExtensionIs(path, extension) { |
|
var pathLen = path.length; |
|
var extLen = extension.length; |
|
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; |
|
} |
|
ts.fileExtensionIs = fileExtensionIs; |
|
function ensureScriptKind(fileName, scriptKind) { |
|
// Using scriptKind as a condition handles both: |
|
// - 'scriptKind' is unspecified and thus it is `undefined` |
|
// - 'scriptKind' is set and it is `Unknown` (0) |
|
// If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt |
|
// to get the ScriptKind from the file name. If it cannot be resolved |
|
// from the file name then the default 'TS' script kind is returned. |
|
return (scriptKind || getScriptKindFromFileName(fileName)) || 3 /* TS */; |
|
} |
|
ts.ensureScriptKind = ensureScriptKind; |
|
function getScriptKindFromFileName(fileName) { |
|
var ext = fileName.substr(fileName.lastIndexOf(".")); |
|
switch (ext.toLowerCase()) { |
|
case ".js": |
|
return 1 /* JS */; |
|
case ".jsx": |
|
return 2 /* JSX */; |
|
case ".ts": |
|
return 3 /* TS */; |
|
case ".tsx": |
|
return 4 /* TSX */; |
|
default: |
|
return 0 /* Unknown */; |
|
} |
|
} |
|
ts.getScriptKindFromFileName = getScriptKindFromFileName; |
|
/** |
|
* List of supported extensions in order of file resolution precedence. |
|
*/ |
|
ts.supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"]; |
|
ts.supportedJavascriptExtensions = [".js", ".jsx"]; |
|
var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); |
|
function getSupportedExtensions(options) { |
|
return options && options.allowJs ? allSupportedExtensions : ts.supportedTypeScriptExtensions; |
|
} |
|
ts.getSupportedExtensions = getSupportedExtensions; |
|
function isSupportedSourceFileName(fileName, compilerOptions) { |
|
if (!fileName) { |
|
return false; |
|
} |
|
for (var _i = 0, _a = getSupportedExtensions(compilerOptions); _i < _a.length; _i++) { |
|
var extension = _a[_i]; |
|
if (fileExtensionIs(fileName, extension)) { |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
ts.isSupportedSourceFileName = isSupportedSourceFileName; |
|
var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; |
|
function removeFileExtension(path) { |
|
for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { |
|
var ext = extensionsToRemove_1[_i]; |
|
if (fileExtensionIs(path, ext)) { |
|
return path.substr(0, path.length - ext.length); |
|
} |
|
} |
|
return path; |
|
} |
|
ts.removeFileExtension = removeFileExtension; |
|
function Symbol(flags, name) { |
|
this.flags = flags; |
|
this.name = name; |
|
this.declarations = undefined; |
|
} |
|
function Type(checker, flags) { |
|
this.flags = flags; |
|
} |
|
function Signature(checker) { |
|
} |
|
function Node(kind, pos, end) { |
|
this.kind = kind; |
|
this.pos = pos; |
|
this.end = end; |
|
this.flags = 0 /* None */; |
|
this.parent = undefined; |
|
} |
|
ts.objectAllocator = { |
|
getNodeConstructor: function () { return Node; }, |
|
getSourceFileConstructor: function () { return Node; }, |
|
getSymbolConstructor: function () { return Symbol; }, |
|
getTypeConstructor: function () { return Type; }, |
|
getSignatureConstructor: function () { return Signature; } |
|
}; |
|
(function (AssertionLevel) { |
|
AssertionLevel[AssertionLevel["None"] = 0] = "None"; |
|
AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; |
|
AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; |
|
AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; |
|
})(ts.AssertionLevel || (ts.AssertionLevel = {})); |
|
var AssertionLevel = ts.AssertionLevel; |
|
var Debug; |
|
(function (Debug) { |
|
var currentAssertionLevel = 0 /* None */; |
|
function shouldAssert(level) { |
|
return currentAssertionLevel >= level; |
|
} |
|
Debug.shouldAssert = shouldAssert; |
|
function assert(expression, message, verboseDebugInfo) { |
|
if (!expression) { |
|
var verboseDebugString = ""; |
|
if (verboseDebugInfo) { |
|
verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo(); |
|
} |
|
debugger; |
|
throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString); |
|
} |
|
} |
|
Debug.assert = assert; |
|
function fail(message) { |
|
Debug.assert(/*expression*/ false, message); |
|
} |
|
Debug.fail = fail; |
|
})(Debug = ts.Debug || (ts.Debug = {})); |
|
function copyListRemovingItem(item, list) { |
|
var copiedList = []; |
|
for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { |
|
var e = list_1[_i]; |
|
if (e !== item) { |
|
copiedList.push(e); |
|
} |
|
} |
|
return copiedList; |
|
} |
|
ts.copyListRemovingItem = copyListRemovingItem; |
|
function createGetCanonicalFileName(useCaseSensitivefileNames) { |
|
return useCaseSensitivefileNames |
|
? (function (fileName) { return fileName; }) |
|
: (function (fileName) { return fileName.toLowerCase(); }); |
|
} |
|
ts.createGetCanonicalFileName = createGetCanonicalFileName; |
|
})(ts || (ts = {})); |
|
/// <reference path="core.ts"/> |
|
var ts; |
|
(function (ts) { |
|
ts.sys = (function () { |
|
function getWScriptSystem() { |
|
var fso = new ActiveXObject("Scripting.FileSystemObject"); |
|
var fileStream = new ActiveXObject("ADODB.Stream"); |
|
fileStream.Type = 2 /*text*/; |
|
var binaryStream = new ActiveXObject("ADODB.Stream"); |
|
binaryStream.Type = 1 /*binary*/; |
|
var args = []; |
|
for (var i = 0; i < WScript.Arguments.length; i++) { |
|
args[i] = WScript.Arguments.Item(i); |
|
} |
|
function readFile(fileName, encoding) { |
|
if (!fso.FileExists(fileName)) { |
|
return undefined; |
|
} |
|
fileStream.Open(); |
|
try { |
|
if (encoding) { |
|
fileStream.Charset = encoding; |
|
fileStream.LoadFromFile(fileName); |
|
} |
|
else { |
|
// Load file and read the first two bytes into a string with no interpretation |
|
fileStream.Charset = "x-ansi"; |
|
fileStream.LoadFromFile(fileName); |
|
var bom = fileStream.ReadText(2) || ""; |
|
// Position must be at 0 before encoding can be changed |
|
fileStream.Position = 0; |
|
// [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 |
|
fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; |
|
} |
|
// ReadText method always strips byte order mark from resulting string |
|
return fileStream.ReadText(); |
|
} |
|
catch (e) { |
|
throw e; |
|
} |
|
finally { |
|
fileStream.Close(); |
|
} |
|
} |
|
function writeFile(fileName, data, writeByteOrderMark) { |
|
fileStream.Open(); |
|
binaryStream.Open(); |
|
try { |
|
// Write characters in UTF-8 encoding |
|
fileStream.Charset = "utf-8"; |
|
fileStream.WriteText(data); |
|
// If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM). |
|
// If not, start from position 0, as the BOM will be added automatically when charset==utf8. |
|
if (writeByteOrderMark) { |
|
fileStream.Position = 0; |
|
} |
|
else { |
|
fileStream.Position = 3; |
|
} |
|
fileStream.CopyTo(binaryStream); |
|
binaryStream.SaveToFile(fileName, 2 /*overwrite*/); |
|
} |
|
finally { |
|
binaryStream.Close(); |
|
fileStream.Close(); |
|
} |
|
} |
|
function getCanonicalPath(path) { |
|
return path.toLowerCase(); |
|
} |
|
function getNames(collection) { |
|
var result = []; |
|
for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { |
|
result.push(e.item().Name); |
|
} |
|
return result.sort(); |
|
} |
|
function readDirectory(path, extension, exclude) { |
|
var result = []; |
|
exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); |
|
visitDirectory(path); |
|
return result; |
|
function visitDirectory(path) { |
|
var folder = fso.GetFolder(path || "."); |
|
var files = getNames(folder.files); |
|
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { |
|
var current = files_1[_i]; |
|
var name_1 = ts.combinePaths(path, current); |
|
if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { |
|
result.push(name_1); |
|
} |
|
} |
|
var subfolders = getNames(folder.subfolders); |
|
for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) { |
|
var current = subfolders_1[_a]; |
|
var name_2 = ts.combinePaths(path, current); |
|
if (!ts.contains(exclude, getCanonicalPath(name_2))) { |
|
visitDirectory(name_2); |
|
} |
|
} |
|
} |
|
} |
|
return { |
|
args: args, |
|
newLine: "\r\n", |
|
useCaseSensitiveFileNames: false, |
|
write: function (s) { |
|
WScript.StdOut.Write(s); |
|
}, |
|
readFile: readFile, |
|
writeFile: writeFile, |
|
resolvePath: function (path) { |
|
return fso.GetAbsolutePathName(path); |
|
}, |
|
fileExists: function (path) { |
|
return fso.FileExists(path); |
|
}, |
|
directoryExists: function (path) { |
|
return fso.FolderExists(path); |
|
}, |
|
createDirectory: function (directoryName) { |
|
if (!this.directoryExists(directoryName)) { |
|
fso.CreateFolder(directoryName); |
|
} |
|
}, |
|
getExecutingFilePath: function () { |
|
return WScript.ScriptFullName; |
|
}, |
|
getCurrentDirectory: function () { |
|
return new ActiveXObject("WScript.Shell").CurrentDirectory; |
|
}, |
|
readDirectory: readDirectory, |
|
exit: function (exitCode) { |
|
try { |
|
WScript.Quit(exitCode); |
|
} |
|
catch (e) { |
|
} |
|
} |
|
}; |
|
} |
|
function getNodeSystem() { |
|
var _fs = require("fs"); |
|
var _path = require("path"); |
|
var _os = require("os"); |
|
// average async stat takes about 30 microseconds |
|
// set chunk size to do 30 files in < 1 millisecond |
|
function createPollingWatchedFileSet(interval, chunkSize) { |
|
if (interval === void 0) { interval = 2500; } |
|
if (chunkSize === void 0) { chunkSize = 30; } |
|
var watchedFiles = []; |
|
var nextFileToCheck = 0; |
|
var watchTimer; |
|
function getModifiedTime(fileName) { |
|
return _fs.statSync(fileName).mtime; |
|
} |
|
function poll(checkedIndex) { |
|
var watchedFile = watchedFiles[checkedIndex]; |
|
if (!watchedFile) { |
|
return; |
|
} |
|
_fs.stat(watchedFile.filePath, function (err, stats) { |
|
if (err) { |
|
watchedFile.callback(watchedFile.filePath); |
|
} |
|
else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { |
|
watchedFile.mtime = getModifiedTime(watchedFile.filePath); |
|
watchedFile.callback(watchedFile.filePath, watchedFile.mtime.getTime() === 0); |
|
} |
|
}); |
|
} |
|
// this implementation uses polling and |
|
// stat due to inconsistencies of fs.watch |
|
// and efficiency of stat on modern filesystems |
|
function startWatchTimer() { |
|
watchTimer = setInterval(function () { |
|
var count = 0; |
|
var nextToCheck = nextFileToCheck; |
|
var firstCheck = -1; |
|
while ((count < chunkSize) && (nextToCheck !== firstCheck)) { |
|
poll(nextToCheck); |
|
if (firstCheck < 0) { |
|
firstCheck = nextToCheck; |
|
} |
|
nextToCheck++; |
|
if (nextToCheck === watchedFiles.length) { |
|
nextToCheck = 0; |
|
} |
|
count++; |
|
} |
|
nextFileToCheck = nextToCheck; |
|
}, interval); |
|
} |
|
function addFile(filePath, callback) { |
|
var file = { |
|
filePath: filePath, |
|
callback: callback, |
|
mtime: getModifiedTime(filePath) |
|
}; |
|
watchedFiles.push(file); |
|
if (watchedFiles.length === 1) { |
|
startWatchTimer(); |
|
} |
|
return file; |
|
} |
|
function removeFile(file) { |
|
watchedFiles = ts.copyListRemovingItem(file, watchedFiles); |
|
} |
|
return { |
|
getModifiedTime: getModifiedTime, |
|
poll: poll, |
|
startWatchTimer: startWatchTimer, |
|
addFile: addFile, |
|
removeFile: removeFile |
|
}; |
|
} |
|
function createWatchedFileSet() { |
|
var dirWatchers = ts.createFileMap(); |
|
// One file can have multiple watchers |
|
var fileWatcherCallbacks = ts.createFileMap(); |
|
return { addFile: addFile, removeFile: removeFile }; |
|
function reduceDirWatcherRefCountForFile(filePath) { |
|
var dirPath = ts.getDirectoryPath(filePath); |
|
if (dirWatchers.contains(dirPath)) { |
|
var watcher = dirWatchers.get(dirPath); |
|
watcher.referenceCount -= 1; |
|
if (watcher.referenceCount <= 0) { |
|
watcher.close(); |
|
dirWatchers.remove(dirPath); |
|
} |
|
} |
|
} |
|
function addDirWatcher(dirPath) { |
|
if (dirWatchers.contains(dirPath)) { |
|
var watcher_1 = dirWatchers.get(dirPath); |
|
watcher_1.referenceCount += 1; |
|
return; |
|
} |
|
var watcher = _fs.watch(dirPath, { persistent: true }, function (eventName, relativeFileName) { return fileEventHandler(eventName, relativeFileName, dirPath); }); |
|
watcher.referenceCount = 1; |
|
dirWatchers.set(dirPath, watcher); |
|
return; |
|
} |
|
function addFileWatcherCallback(filePath, callback) { |
|
if (fileWatcherCallbacks.contains(filePath)) { |
|
fileWatcherCallbacks.get(filePath).push(callback); |
|
} |
|
else { |
|
fileWatcherCallbacks.set(filePath, [callback]); |
|
} |
|
} |
|
function addFile(filePath, callback) { |
|
addFileWatcherCallback(filePath, callback); |
|
addDirWatcher(ts.getDirectoryPath(filePath)); |
|
return { filePath: filePath, callback: callback }; |
|
} |
|
function removeFile(watchedFile) { |
|
removeFileWatcherCallback(watchedFile.filePath, watchedFile.callback); |
|
reduceDirWatcherRefCountForFile(watchedFile.filePath); |
|
} |
|
function removeFileWatcherCallback(filePath, callback) { |
|
if (fileWatcherCallbacks.contains(filePath)) { |
|
var newCallbacks = ts.copyListRemovingItem(callback, fileWatcherCallbacks.get(filePath)); |
|
if (newCallbacks.length === 0) { |
|
fileWatcherCallbacks.remove(filePath); |
|
} |
|
else { |
|
fileWatcherCallbacks.set(filePath, newCallbacks); |
|
} |
|
} |
|
} |
|
/** |
|
* @param watcherPath is the path from which the watcher is triggered. |
|
*/ |
|
function fileEventHandler(eventName, relativeFileName, baseDirPath) { |
|
// When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" |
|
var filePath = typeof relativeFileName !== "string" |
|
? undefined |
|
: ts.toPath(relativeFileName, baseDirPath, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); |
|
// Some applications save a working file via rename operations |
|
if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks.contains(filePath)) { |
|
for (var _i = 0, _a = fileWatcherCallbacks.get(filePath); _i < _a.length; _i++) { |
|
var fileCallback = _a[_i]; |
|
fileCallback(filePath); |
|
} |
|
} |
|
} |
|
} |
|
// REVIEW: for now this implementation uses polling. |
|
// The advantage of polling is that it works reliably |
|
// on all os and with network mounted files. |
|
// For 90 referenced files, the average time to detect |
|
// changes is 2*msInterval (by default 5 seconds). |
|
// The overhead of this is .04 percent (1/2500) with |
|
// average pause of < 1 millisecond (and max |
|
// pause less than 1.5 milliseconds); question is |
|
// do we anticipate reference sets in the 100s and |
|
// do we care about waiting 10-20 seconds to detect |
|
// changes for large reference sets? If so, do we want |
|
// to increase the chunk size or decrease the interval |
|
// time dynamically to match the large reference set? |
|
var pollingWatchedFileSet = createPollingWatchedFileSet(); |
|
var watchedFileSet = createWatchedFileSet(); |
|
function isNode4OrLater() { |
|
return parseInt(process.version.charAt(1)) >= 4; |
|
} |
|
var platform = _os.platform(); |
|
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive |
|
var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; |
|
function readFile(fileName, encoding) { |
|
if (!_fs.existsSync(fileName)) { |
|
return undefined; |
|
} |
|
var buffer = _fs.readFileSync(fileName); |
|
var len = buffer.length; |
|
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { |
|
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js, |
|
// flip all byte pairs and treat as little endian. |
|
len &= ~1; |
|
for (var i = 0; i < len; i += 2) { |
|
var temp = buffer[i]; |
|
buffer[i] = buffer[i + 1]; |
|
buffer[i + 1] = temp; |
|
} |
|
return buffer.toString("utf16le", 2); |
|
} |
|
if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { |
|
// Little endian UTF-16 byte order mark detected |
|
return buffer.toString("utf16le", 2); |
|
} |
|
if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { |
|
// UTF-8 byte order mark detected |
|
return buffer.toString("utf8", 3); |
|
} |
|
// Default is UTF-8 with no byte order mark |
|
return buffer.toString("utf8"); |
|
} |
|
function writeFile(fileName, data, writeByteOrderMark) { |
|
// If a BOM is required, emit one |
|
if (writeByteOrderMark) { |
|
data = "\uFEFF" + data; |
|
} |
|
var fd; |
|
try { |
|
fd = _fs.openSync(fileName, "w"); |
|
_fs.writeSync(fd, data, undefined, "utf8"); |
|
} |
|
finally { |
|
if (fd !== undefined) { |
|
_fs.closeSync(fd); |
|
} |
|
} |
|
} |
|
function getCanonicalPath(path) { |
|
return useCaseSensitiveFileNames ? path : path.toLowerCase(); |
|
} |
|
function readDirectory(path, extension, exclude) { |
|
var result = []; |
|
exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); |
|
visitDirectory(path); |
|
return result; |
|
function visitDirectory(path) { |
|
var files = _fs.readdirSync(path || ".").sort(); |
|
var directories = []; |
|
for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { |
|
var current = files_2[_i]; |
|
var name_3 = ts.combinePaths(path, current); |
|
if (!ts.contains(exclude, getCanonicalPath(name_3))) { |
|
// fs.statSync would throw an exception if the file is a symlink |
|
// whose linked file doesn't exist. |
|
try { |
|
var stat = _fs.statSync(name_3); |
|
if (stat.isFile()) { |
|
if (!extension || ts.fileExtensionIs(name_3, extension)) { |
|
result.push(name_3); |
|
} |
|
} |
|
else if (stat.isDirectory()) { |
|
directories.push(name_3); |
|
} |
|
} |
|
catch (e) { } |
|
} |
|
} |
|
for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { |
|
var current = directories_1[_a]; |
|
visitDirectory(current); |
|
} |
|
} |
|
} |
|
return { |
|
args: process.argv.slice(2), |
|
newLine: _os.EOL, |
|
useCaseSensitiveFileNames: useCaseSensitiveFileNames, |
|
write: function (s) { |
|
process.stdout.write(s); |
|
}, |
|
readFile: readFile, |
|
writeFile: writeFile, |
|
watchFile: function (filePath, callback) { |
|
// Node 4.0 stablized the `fs.watch` function on Windows which avoids polling |
|
// and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649 |
|
// and https://github.com/Microsoft/TypeScript/issues/4643), therefore |
|
// if the current node.js version is newer than 4, use `fs.watch` instead. |
|
var watchSet = isNode4OrLater() ? watchedFileSet : pollingWatchedFileSet; |
|
var watchedFile = watchSet.addFile(filePath, callback); |
|
return { |
|
close: function () { return watchSet.removeFile(watchedFile); } |
|
}; |
|
}, |
|
watchDirectory: function (path, callback, recursive) { |
|
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows |
|
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) |
|
var options; |
|
if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { |
|
options = { persistent: true, recursive: !!recursive }; |
|
} |
|
else { |
|
options = { persistent: true }; |
|
} |
|
return _fs.watch(path, options, function (eventName, relativeFileName) { |
|
// In watchDirectory we only care about adding and removing files (when event name is |
|
// "rename"); changes made within files are handled by corresponding fileWatchers (when |
|
// event name is "change") |
|
if (eventName === "rename") { |
|
// When deleting a file, the passed baseFileName is null |
|
callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName))); |
|
} |
|
; |
|
}); |
|
}, |
|
resolvePath: function (path) { |
|
return _path.resolve(path); |
|
}, |
|
fileExists: function (path) { |
|
return _fs.existsSync(path); |
|
}, |
|
directoryExists: function (path) { |
|
return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); |
|
}, |
|
createDirectory: function (directoryName) { |
|
if (!this.directoryExists(directoryName)) { |
|
_fs.mkdirSync(directoryName); |
|
} |
|
}, |
|
getExecutingFilePath: function () { |
|
return __filename; |
|
}, |
|
getCurrentDirectory: function () { |
|
return process.cwd(); |
|
}, |
|
readDirectory: readDirectory, |
|
getMemoryUsage: function () { |
|
if (global.gc) { |
|
global.gc(); |
|
} |
|
return process.memoryUsage().heapUsed; |
|
}, |
|
exit: function (exitCode) { |
|
process.exit(exitCode); |
|
} |
|
}; |
|
} |
|
function getChakraSystem() { |
|
return { |
|
newLine: ChakraHost.newLine || "\r\n", |
|
args: ChakraHost.args, |
|
useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, |
|
write: ChakraHost.echo, |
|
readFile: function (path, encoding) { |
|
// encoding is automatically handled by the implementation in ChakraHost |
|
return ChakraHost.readFile(path); |
|
}, |
|
writeFile: function (path, data, writeByteOrderMark) { |
|
// If a BOM is required, emit one |
|
if (writeByteOrderMark) { |
|
data = "\uFEFF" + data; |
|
} |
|
ChakraHost.writeFile(path, data); |
|
}, |
|
resolvePath: ChakraHost.resolvePath, |
|
fileExists: ChakraHost.fileExists, |
|
directoryExists: ChakraHost.directoryExists, |
|
createDirectory: ChakraHost.createDirectory, |
|
getExecutingFilePath: function () { return ChakraHost.executingFile; }, |
|
getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, |
|
readDirectory: ChakraHost.readDirectory, |
|
exit: ChakraHost.quit |
|
}; |
|
} |
|
if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { |
|
return getWScriptSystem(); |
|
} |
|
else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { |
|
// process and process.nextTick checks if current environment is node-like |
|
// process.browser check excludes webpack and browserify |
|
return getNodeSystem(); |
|
} |
|
else if (typeof ChakraHost !== "undefined") { |
|
return getChakraSystem(); |
|
} |
|
else { |
|
return undefined; // Unsupported host |
|
} |
|
})(); |
|
})(ts || (ts = {})); |
|
// <auto-generated /> |
|
/// <reference path="types.ts" /> |
|
/* @internal */ |
|
var ts; |
|
(function (ts) { |
|
ts.Diagnostics = { |
|
Unterminated_string_literal: { code: 1002, category: ts.DiagnosticCategory.Error, key: "Unterminated_string_literal_1002", message: "Unterminated string literal." }, |
|
Identifier_expected: { code: 1003, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_1003", message: "Identifier expected." }, |
|
_0_expected: { code: 1005, category: ts.DiagnosticCategory.Error, key: "_0_expected_1005", message: "'{0}' expected." }, |
|
A_file_cannot_have_a_reference_to_itself: { code: 1006, category: ts.DiagnosticCategory.Error, key: "A_file_cannot_have_a_reference_to_itself_1006", message: "A file cannot have a reference to itself." }, |
|
Trailing_comma_not_allowed: { code: 1009, category: ts.DiagnosticCategory.Error, key: "Trailing_comma_not_allowed_1009", message: "Trailing comma not allowed." }, |
|
Asterisk_Slash_expected: { code: 1010, category: ts.DiagnosticCategory.Error, key: "Asterisk_Slash_expected_1010", message: "'*/' expected." }, |
|
Unexpected_token: { code: 1012, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_1012", message: "Unexpected token." }, |
|
A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_last_in_a_parameter_list_1014", message: "A rest parameter must be last in a parameter list." }, |
|
Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: ts.DiagnosticCategory.Error, key: "Parameter_cannot_have_question_mark_and_initializer_1015", message: "Parameter cannot have question mark and initializer." }, |
|
A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: ts.DiagnosticCategory.Error, key: "A_required_parameter_cannot_follow_an_optional_parameter_1016", message: "A required parameter cannot follow an optional parameter." }, |
|
An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: ts.DiagnosticCategory.Error, key: "An_index_signature_cannot_have_a_rest_parameter_1017", message: "An index signature cannot have a rest parameter." }, |
|
An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", message: "An index signature parameter cannot have an accessibility modifier." }, |
|
An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_a_question_mark_1019", message: "An index signature parameter cannot have a question mark." }, |
|
An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_cannot_have_an_initializer_1020", message: "An index signature parameter cannot have an initializer." }, |
|
An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_a_type_annotation_1021", message: "An index signature must have a type annotation." }, |
|
An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_must_have_a_type_annotation_1022", message: "An index signature parameter must have a type annotation." }, |
|
An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_type_must_be_string_or_number_1023", message: "An index signature parameter type must be 'string' or 'number'." }, |
|
Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility_modifier_already_seen_1028", message: "Accessibility modifier already seen." }, |
|
_0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "_0_modifier_must_precede_1_modifier_1029", message: "'{0}' modifier must precede '{1}' modifier." }, |
|
_0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "_0_modifier_already_seen_1030", message: "'{0}' modifier already seen." }, |
|
_0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_class_element_1031", message: "'{0}' modifier cannot appear on a class element." }, |
|
super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "super_must_be_followed_by_an_argument_list_or_member_access_1034", message: "'super' must be followed by an argument list or member access." }, |
|
Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only_ambient_modules_can_use_quoted_names_1035", message: "Only ambient modules can use quoted names." }, |
|
Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements_are_not_allowed_in_ambient_contexts_1036", message: "Statements are not allowed in ambient contexts." }, |
|
A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", message: "A 'declare' modifier cannot be used in an already ambient context." }, |
|
Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers_are_not_allowed_in_ambient_contexts_1039", message: "Initializers are not allowed in ambient contexts." }, |
|
_0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_in_an_ambient_context_1040", message: "'{0}' modifier cannot be used in an ambient context." }, |
|
_0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_a_class_declaration_1041", message: "'{0}' modifier cannot be used with a class declaration." }, |
|
_0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_here_1042", message: "'{0}' modifier cannot be used here." }, |
|
_0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_data_property_1043", message: "'{0}' modifier cannot appear on a data property." }, |
|
_0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_element_1044", message: "'{0}' modifier cannot appear on a module element." }, |
|
A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", message: "A '{0}' modifier cannot be used with an interface declaration." }, |
|
A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046", message: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, |
|
A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_be_optional_1047", message: "A rest parameter cannot be optional." }, |
|
A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_have_an_initializer_1048", message: "A rest parameter cannot have an initializer." }, |
|
A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_must_have_exactly_one_parameter_1049", message: "A 'set' accessor must have exactly one parameter." }, |
|
A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_an_optional_parameter_1051", message: "A 'set' accessor cannot have an optional parameter." }, |
|
A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_parameter_cannot_have_an_initializer_1052", message: "A 'set' accessor parameter cannot have an initializer." }, |
|
A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_rest_parameter_1053", message: "A 'set' accessor cannot have rest parameter." }, |
|
A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_cannot_have_parameters_1054", message: "A 'get' accessor cannot have parameters." }, |
|
Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_1055", message: "Type '{0}' is not a valid async function return type." }, |
|
Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, |
|
An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, |
|
Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, |
|
Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return_expression_in_async_function_does_not_have_a_valid_callable_then_member_1059", message: "Return expression in async function does not have a valid callable 'then' member." }, |
|
Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member_1060", message: "Expression body for async arrow function does not have a valid callable 'then' member." }, |
|
Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum_member_must_have_initializer_1061", message: "Enum member must have initializer." }, |
|
_0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, |
|
An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_namespace_1063", message: "An export assignment cannot be used in a namespace." }, |
|
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: { code: 1064, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", message: "The return type of an async function or method must be the global Promise<T> type." }, |
|
In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", message: "In ambient enum declarations member initializer must be constant expression." }, |
|
Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", message: "Unexpected token. A constructor, method, accessor, or property was expected." }, |
|
A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, |
|
Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, |
|
Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, |
|
An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_be_declared_in_an_ambient_context_1086", message: "An accessor cannot be declared in an ambient context." }, |
|
_0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", message: "'{0}' modifier cannot appear on a constructor declaration." }, |
|
_0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_parameter_1090", message: "'{0}' modifier cannot appear on a parameter." }, |
|
Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: ts.DiagnosticCategory.Error, key: "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", message: "Only a single variable declaration is allowed in a 'for...in' statement." }, |
|
Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: ts.DiagnosticCategory.Error, key: "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", message: "Type parameters cannot appear on a constructor declaration." }, |
|
Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: ts.DiagnosticCategory.Error, key: "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", message: "Type annotation cannot appear on a constructor declaration." }, |
|
An_accessor_cannot_have_type_parameters: { code: 1094, category: ts.DiagnosticCategory.Error, key: "An_accessor_cannot_have_type_parameters_1094", message: "An accessor cannot have type parameters." }, |
|
A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_a_return_type_annotation_1095", message: "A 'set' accessor cannot have a return type annotation." }, |
|
An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_exactly_one_parameter_1096", message: "An index signature must have exactly one parameter." }, |
|
_0_list_cannot_be_empty: { code: 1097, category: ts.DiagnosticCategory.Error, key: "_0_list_cannot_be_empty_1097", message: "'{0}' list cannot be empty." }, |
|
Type_parameter_list_cannot_be_empty: { code: 1098, category: ts.DiagnosticCategory.Error, key: "Type_parameter_list_cannot_be_empty_1098", message: "Type parameter list cannot be empty." }, |
|
Type_argument_list_cannot_be_empty: { code: 1099, category: ts.DiagnosticCategory.Error, key: "Type_argument_list_cannot_be_empty_1099", message: "Type argument list cannot be empty." }, |
|
Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_in_strict_mode_1100", message: "Invalid use of '{0}' in strict mode." }, |
|
with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_strict_mode_1101", message: "'with' statements are not allowed in strict mode." }, |
|
delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", message: "'delete' cannot be called on an identifier in strict mode." }, |
|
A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", message: "A 'continue' statement can only be used within an enclosing iteration statement." }, |
|
A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", message: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, |
|
Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump_target_cannot_cross_function_boundary_1107", message: "Jump target cannot cross function boundary." }, |
|
A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: ts.DiagnosticCategory.Error, key: "A_return_statement_can_only_be_used_within_a_function_body_1108", message: "A 'return' statement can only be used within a function body." }, |
|
Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression_expected_1109", message: "Expression expected." }, |
|
Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type_expected_1110", message: "Type expected." }, |
|
A_class_member_cannot_be_declared_optional: { code: 1112, category: ts.DiagnosticCategory.Error, key: "A_class_member_cannot_be_declared_optional_1112", message: "A class member cannot be declared optional." }, |
|
A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", message: "A 'default' clause cannot appear more than once in a 'switch' statement." }, |
|
Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'" }, |
|
A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", message: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, |
|
A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", message: "A 'break' statement can only jump to a label of an enclosing statement." }, |
|
An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", message: "An object literal cannot have multiple properties with the same name in strict mode." }, |
|
An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", message: "An object literal cannot have multiple get/set accessors with the same name." }, |
|
An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", message: "An object literal cannot have property and accessor with the same name." }, |
|
An_export_assignment_cannot_have_modifiers: { code: 1120, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_have_modifiers_1120", message: "An export assignment cannot have modifiers." }, |
|
Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_strict_mode_1121", message: "Octal literals are not allowed in strict mode." }, |
|
A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: ts.DiagnosticCategory.Error, key: "A_tuple_type_element_list_cannot_be_empty_1122", message: "A tuple type element list cannot be empty." }, |
|
Variable_declaration_list_cannot_be_empty: { code: 1123, category: ts.DiagnosticCategory.Error, key: "Variable_declaration_list_cannot_be_empty_1123", message: "Variable declaration list cannot be empty." }, |
|
Digit_expected: { code: 1124, category: ts.DiagnosticCategory.Error, key: "Digit_expected_1124", message: "Digit expected." }, |
|
Hexadecimal_digit_expected: { code: 1125, category: ts.DiagnosticCategory.Error, key: "Hexadecimal_digit_expected_1125", message: "Hexadecimal digit expected." }, |
|
Unexpected_end_of_text: { code: 1126, category: ts.DiagnosticCategory.Error, key: "Unexpected_end_of_text_1126", message: "Unexpected end of text." }, |
|
Invalid_character: { code: 1127, category: ts.DiagnosticCategory.Error, key: "Invalid_character_1127", message: "Invalid character." }, |
|
Declaration_or_statement_expected: { code: 1128, category: ts.DiagnosticCategory.Error, key: "Declaration_or_statement_expected_1128", message: "Declaration or statement expected." }, |
|
Statement_expected: { code: 1129, category: ts.DiagnosticCategory.Error, key: "Statement_expected_1129", message: "Statement expected." }, |
|
case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "case_or_default_expected_1130", message: "'case' or 'default' expected." }, |
|
Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property_or_signature_expected_1131", message: "Property or signature expected." }, |
|
Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum_member_expected_1132", message: "Enum member expected." }, |
|
Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable_declaration_expected_1134", message: "Variable declaration expected." }, |
|
Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument_expression_expected_1135", message: "Argument expression expected." }, |
|
Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property_assignment_expected_1136", message: "Property assignment expected." }, |
|
Expression_or_comma_expected: { code: 1137, category: ts.DiagnosticCategory.Error, key: "Expression_or_comma_expected_1137", message: "Expression or comma expected." }, |
|
Parameter_declaration_expected: { code: 1138, category: ts.DiagnosticCategory.Error, key: "Parameter_declaration_expected_1138", message: "Parameter declaration expected." }, |
|
Type_parameter_declaration_expected: { code: 1139, category: ts.DiagnosticCategory.Error, key: "Type_parameter_declaration_expected_1139", message: "Type parameter declaration expected." }, |
|
Type_argument_expected: { code: 1140, category: ts.DiagnosticCategory.Error, key: "Type_argument_expected_1140", message: "Type argument expected." }, |
|
String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String_literal_expected_1141", message: "String literal expected." }, |
|
Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line_break_not_permitted_here_1142", message: "Line break not permitted here." }, |
|
or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." }, |
|
Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers_not_permitted_on_index_signature_members_1145", message: "Modifiers not permitted on index signature members." }, |
|
Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." }, |
|
Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." }, |
|
Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting__1148", message: "Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file." }, |
|
File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" }, |
|
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." }, |
|
const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" }, |
|
const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "const_declarations_can_only_be_declared_inside_a_block_1156", message: "'const' declarations can only be declared inside a block." }, |
|
let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "let_declarations_can_only_be_declared_inside_a_block_1157", message: "'let' declarations can only be declared inside a block." }, |
|
Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated_template_literal_1160", message: "Unterminated template literal." }, |
|
Unterminated_regular_expression_literal: { code: 1161, category: ts.DiagnosticCategory.Error, key: "Unterminated_regular_expression_literal_1161", message: "Unterminated regular expression literal." }, |
|
An_object_member_cannot_be_declared_optional: { code: 1162, category: ts.DiagnosticCategory.Error, key: "An_object_member_cannot_be_declared_optional_1162", message: "An object member cannot be declared optional." }, |
|
A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: ts.DiagnosticCategory.Error, key: "A_yield_expression_is_only_allowed_in_a_generator_body_1163", message: "A 'yield' expression is only allowed in a generator body." }, |
|
Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed_property_names_are_not_allowed_in_enums_1164", message: "Computed property names are not allowed in enums." }, |
|
A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol_1165", message: "A computed property name in an ambient context must directly refer to a built-in symbol." }, |
|
A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol_1166", message: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, |
|
A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol_1168", message: "A computed property name in a method overload must directly refer to a built-in symbol." }, |
|
A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol_1169", message: "A computed property name in an interface must directly refer to a built-in symbol." }, |
|
A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol_1170", message: "A computed property name in a type literal must directly refer to a built-in symbol." }, |
|
A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: ts.DiagnosticCategory.Error, key: "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", message: "A comma expression is not allowed in a computed property name." }, |
|
extends_clause_already_seen: { code: 1172, category: ts.DiagnosticCategory.Error, key: "extends_clause_already_seen_1172", message: "'extends' clause already seen." }, |
|
extends_clause_must_precede_implements_clause: { code: 1173, category: ts.DiagnosticCategory.Error, key: "extends_clause_must_precede_implements_clause_1173", message: "'extends' clause must precede 'implements' clause." }, |
|
Classes_can_only_extend_a_single_class: { code: 1174, category: ts.DiagnosticCategory.Error, key: "Classes_can_only_extend_a_single_class_1174", message: "Classes can only extend a single class." }, |
|
implements_clause_already_seen: { code: 1175, category: ts.DiagnosticCategory.Error, key: "implements_clause_already_seen_1175", message: "'implements' clause already seen." }, |
|
Interface_declaration_cannot_have_implements_clause: { code: 1176, category: ts.DiagnosticCategory.Error, key: "Interface_declaration_cannot_have_implements_clause_1176", message: "Interface declaration cannot have 'implements' clause." }, |
|
Binary_digit_expected: { code: 1177, category: ts.DiagnosticCategory.Error, key: "Binary_digit_expected_1177", message: "Binary digit expected." }, |
|
Octal_digit_expected: { code: 1178, category: ts.DiagnosticCategory.Error, key: "Octal_digit_expected_1178", message: "Octal digit expected." }, |
|
Unexpected_token_expected: { code: 1179, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_expected_1179", message: "Unexpected token. '{' expected." }, |
|
Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property_destructuring_pattern_expected_1180", message: "Property destructuring pattern expected." }, |
|
Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "Array_element_destructuring_pattern_expected_1181", message: "Array element destructuring pattern expected." }, |
|
A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: ts.DiagnosticCategory.Error, key: "A_destructuring_declaration_must_have_an_initializer_1182", message: "A destructuring declaration must have an initializer." }, |
|
An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An_implementation_cannot_be_declared_in_ambient_contexts_1183", message: "An implementation cannot be declared in ambient contexts." }, |
|
Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers_cannot_appear_here_1184", message: "Modifiers cannot appear here." }, |
|
Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "Merge_conflict_marker_encountered_1185", message: "Merge conflict marker encountered." }, |
|
A_rest_element_cannot_have_an_initializer: { code: 1186, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_have_an_initializer_1186", message: "A rest element cannot have an initializer." }, |
|
A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_may_not_be_a_binding_pattern_1187", message: "A parameter property may not be a binding pattern." }, |
|
Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: ts.DiagnosticCategory.Error, key: "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", message: "Only a single variable declaration is allowed in a 'for...of' statement." }, |
|
The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: ts.DiagnosticCategory.Error, key: "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", message: "The variable declaration of a 'for...in' statement cannot have an initializer." }, |
|
The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: ts.DiagnosticCategory.Error, key: "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", message: "The variable declaration of a 'for...of' statement cannot have an initializer." }, |
|
An_import_declaration_cannot_have_modifiers: { code: 1191, category: ts.DiagnosticCategory.Error, key: "An_import_declaration_cannot_have_modifiers_1191", message: "An import declaration cannot have modifiers." }, |
|
Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_default_export_1192", message: "Module '{0}' has no default export." }, |
|
An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_cannot_have_modifiers_1193", message: "An export declaration cannot have modifiers." }, |
|
Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export_declarations_are_not_permitted_in_a_namespace_1194", message: "Export declarations are not permitted in a namespace." }, |
|
Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_name_must_be_an_identifier_1195", message: "Catch clause variable name must be an identifier." }, |
|
Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_a_type_annotation_1196", message: "Catch clause variable cannot have a type annotation." }, |
|
Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_an_initializer_1197", message: "Catch clause variable cannot have an initializer." }, |
|
An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", message: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, |
|
Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated_Unicode_escape_sequence_1199", message: "Unterminated Unicode escape sequence." }, |
|
Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line_terminator_not_permitted_before_arrow_1200", message: "Line terminator not permitted before arrow." }, |
|
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk__1202", message: "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead." }, |
|
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_o_1203", message: "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead." }, |
|
Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower_1204", message: "Cannot compile modules into 'es2015' when targeting 'ES5' or lower." }, |
|
Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators_are_not_valid_here_1206", message: "Decorators are not valid here." }, |
|
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", message: "Decorators cannot be applied to multiple get/set accessors of the same name." }, |
|
Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, |
|
Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", message: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, |
|
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", message: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, |
|
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name" }, |
|
Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode" }, |
|
Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, |
|
Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, |
|
Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, |
|
Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, |
|
Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, |
|
Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_6_or_higher_1220", message: "Generators are only available when targeting ECMAScript 6 or higher." }, |
|
Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators_are_not_allowed_in_an_ambient_context_1221", message: "Generators are not allowed in an ambient context." }, |
|
An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An_overload_signature_cannot_be_declared_as_a_generator_1222", message: "An overload signature cannot be declared as a generator." }, |
|
_0_tag_already_specified: { code: 1223, category: ts.DiagnosticCategory.Error, key: "_0_tag_already_specified_1223", message: "'{0}' tag already specified." }, |
|
Signature_0_must_have_a_type_predicate: { code: 1224, category: ts.DiagnosticCategory.Error, key: "Signature_0_must_have_a_type_predicate_1224", message: "Signature '{0}' must have a type predicate." }, |
|
Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, |
|
Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, |
|
Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, |
|
A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, |
|
A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, |
|
A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, |
|
An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, |
|
An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: ts.DiagnosticCategory.Error, key: "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", message: "An import declaration can only be used in a namespace or module." }, |
|
An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_can_only_be_used_in_a_module_1233", message: "An export declaration can only be used in a module." }, |
|
An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: ts.DiagnosticCategory.Error, key: "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", message: "An ambient module declaration is only allowed at the top level in a file." }, |
|
A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", message: "A namespace declaration is only allowed in a namespace or module." }, |
|
The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", message: "The return type of a property decorator function must be either 'void' or 'any'." }, |
|
The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", message: "The return type of a parameter decorator function must be either 'void' or 'any'." }, |
|
Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", message: "Unable to resolve signature of class decorator when called as an expression." }, |
|
Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", message: "Unable to resolve signature of parameter decorator when called as an expression." }, |
|
Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", message: "Unable to resolve signature of property decorator when called as an expression." }, |
|
Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", message: "Unable to resolve signature of method decorator when called as an expression." }, |
|
abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_or_method_declaration_1242", message: "'abstract' modifier can only appear on a class or method declaration." }, |
|
_0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_1_modifier_1243", message: "'{0}' modifier cannot be used with '{1}' modifier." }, |
|
Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract_methods_can_only_appear_within_an_abstract_class_1244", message: "Abstract methods can only appear within an abstract class." }, |
|
Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", message: "Method '{0}' cannot have an implementation because it is marked abstract." }, |
|
An_interface_property_cannot_have_an_initializer: { code: 1246, category: ts.DiagnosticCategory.Error, key: "An_interface_property_cannot_have_an_initializer_1246", message: "An interface property cannot have an initializer." }, |
|
A_type_literal_property_cannot_have_an_initializer: { code: 1247, category: ts.DiagnosticCategory.Error, key: "A_type_literal_property_cannot_have_an_initializer_1247", message: "A type literal property cannot have an initializer." }, |
|
A_class_member_cannot_have_the_0_keyword: { code: 1248, category: ts.DiagnosticCategory.Error, key: "A_class_member_cannot_have_the_0_keyword_1248", message: "A class member cannot have the '{0}' keyword." }, |
|
A_decorator_can_only_decorate_a_method_implementation_not_an_overload: { code: 1249, category: ts.DiagnosticCategory.Error, key: "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", message: "A decorator can only decorate a method implementation, not an overload." }, |
|
with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_an_async_function_block_1300", message: "'with' statements are not allowed in an async function block." }, |
|
await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, |
|
Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, |
|
can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, |
|
The_body_of_an_if_statement_cannot_be_the_empty_statement: { code: 1313, category: ts.DiagnosticCategory.Error, key: "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", message: "The body of an 'if' statement cannot be the empty statement." }, |
|
Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, |
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, |
|
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, |
|
Circular_definition_of_import_alias_0: { code: 2303, category: ts.DiagnosticCategory.Error, key: "Circular_definition_of_import_alias_0_2303", message: "Circular definition of import alias '{0}'." }, |
|
Cannot_find_name_0: { code: 2304, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_2304", message: "Cannot find name '{0}'." }, |
|
Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_exported_member_1_2305", message: "Module '{0}' has no exported member '{1}'." }, |
|
File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File_0_is_not_a_module_2306", message: "File '{0}' is not a module." }, |
|
Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot_find_module_0_2307", message: "Cannot find module '{0}'." }, |
|
Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: { code: 2308, category: ts.DiagnosticCategory.Error, key: "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", message: "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity." }, |
|
An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", message: "An export assignment cannot be used in a module with other exported elements." }, |
|
Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type_0_recursively_references_itself_as_a_base_type_2310", message: "Type '{0}' recursively references itself as a base type." }, |
|
A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_extend_another_class_2311", message: "A class may only extend another class." }, |
|
An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: ts.DiagnosticCategory.Error, key: "An_interface_may_only_extend_a_class_or_another_interface_2312", message: "An interface may only extend a class or another interface." }, |
|
Type_parameter_0_has_a_circular_constraint: { code: 2313, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_has_a_circular_constraint_2313", message: "Type parameter '{0}' has a circular constraint." }, |
|
Generic_type_0_requires_1_type_argument_s: { code: 2314, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_1_type_argument_s_2314", message: "Generic type '{0}' requires {1} type argument(s)." }, |
|
Type_0_is_not_generic: { code: 2315, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_generic_2315", message: "Type '{0}' is not generic." }, |
|
Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: ts.DiagnosticCategory.Error, key: "Global_type_0_must_be_a_class_or_interface_type_2316", message: "Global type '{0}' must be a class or interface type." }, |
|
Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: ts.DiagnosticCategory.Error, key: "Global_type_0_must_have_1_type_parameter_s_2317", message: "Global type '{0}' must have {1} type parameter(s)." }, |
|
Cannot_find_global_type_0: { code: 2318, category: ts.DiagnosticCategory.Error, key: "Cannot_find_global_type_0_2318", message: "Cannot find global type '{0}'." }, |
|
Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: ts.DiagnosticCategory.Error, key: "Named_property_0_of_types_1_and_2_are_not_identical_2319", message: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, |
|
Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: ts.DiagnosticCategory.Error, key: "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", message: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, |
|
Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: ts.DiagnosticCategory.Error, key: "Excessive_stack_depth_comparing_types_0_and_1_2321", message: "Excessive stack depth comparing types '{0}' and '{1}'." }, |
|
Type_0_is_not_assignable_to_type_1: { code: 2322, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_2322", message: "Type '{0}' is not assignable to type '{1}'." }, |
|
Cannot_redeclare_exported_variable_0: { code: 2323, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_exported_variable_0_2323", message: "Cannot redeclare exported variable '{0}'." }, |
|
Property_0_is_missing_in_type_1: { code: 2324, category: ts.DiagnosticCategory.Error, key: "Property_0_is_missing_in_type_1_2324", message: "Property '{0}' is missing in type '{1}'." }, |
|
Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: ts.DiagnosticCategory.Error, key: "Property_0_is_private_in_type_1_but_not_in_type_2_2325", message: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, |
|
Types_of_property_0_are_incompatible: { code: 2326, category: ts.DiagnosticCategory.Error, key: "Types_of_property_0_are_incompatible_2326", message: "Types of property '{0}' are incompatible." }, |
|
Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: ts.DiagnosticCategory.Error, key: "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", message: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, |
|
Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: ts.DiagnosticCategory.Error, key: "Types_of_parameters_0_and_1_are_incompatible_2328", message: "Types of parameters '{0}' and '{1}' are incompatible." }, |
|
Index_signature_is_missing_in_type_0: { code: 2329, category: ts.DiagnosticCategory.Error, key: "Index_signature_is_missing_in_type_0_2329", message: "Index signature is missing in type '{0}'." }, |
|
Index_signatures_are_incompatible: { code: 2330, category: ts.DiagnosticCategory.Error, key: "Index_signatures_are_incompatible_2330", message: "Index signatures are incompatible." }, |
|
this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", message: "'this' cannot be referenced in a module or namespace body." }, |
|
this_cannot_be_referenced_in_current_location: { code: 2332, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_current_location_2332", message: "'this' cannot be referenced in current location." }, |
|
this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_constructor_arguments_2333", message: "'this' cannot be referenced in constructor arguments." }, |
|
this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_static_property_initializer_2334", message: "'this' cannot be referenced in a static property initializer." }, |
|
super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_a_derived_class_2335", message: "'super' can only be referenced in a derived class." }, |
|
super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "super_cannot_be_referenced_in_constructor_arguments_2336", message: "'super' cannot be referenced in constructor arguments." }, |
|
Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", message: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, |
|
super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", message: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, |
|
Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property_0_does_not_exist_on_type_1_2339", message: "Property '{0}' does not exist on type '{1}'." }, |
|
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", message: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, |
|
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property_0_is_private_and_only_accessible_within_class_1_2341", message: "Property '{0}' is private and only accessible within class '{1}'." }, |
|
An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", message: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, |
|
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type_0_does_not_satisfy_the_constraint_1_2344", message: "Type '{0}' does not satisfy the constraint '{1}'." }, |
|
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", message: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, |
|
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied_parameters_do_not_match_any_signature_of_call_target_2346", message: "Supplied parameters do not match any signature of call target." }, |
|
Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: ts.DiagnosticCategory.Error, key: "Untyped_function_calls_may_not_accept_type_arguments_2347", message: "Untyped function calls may not accept type arguments." }, |
|
Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: ts.DiagnosticCategory.Error, key: "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", message: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, |
|
Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: ts.DiagnosticCategory.Error, key: "Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_2349", message: "Cannot invoke an expression whose type lacks a call signature." }, |
|
Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only_a_void_function_can_be_called_with_the_new_keyword_2350", message: "Only a void function can be called with the 'new' keyword." }, |
|
Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", message: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, |
|
Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, |
|
Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, |
|
No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, |
|
A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, |
|
An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, |
|
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, |
|
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, |
|
The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, |
|
The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, |
|
The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, |
|
The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, |
|
The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, |
|
Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_of_assignment_expression_2364", message: "Invalid left-hand side of assignment expression." }, |
|
Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, |
|
Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, |
|
A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", message: "A parameter property is only allowed in a constructor implementation." }, |
|
A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_of_an_array_type_2370", message: "A rest parameter must be of an array type." }, |
|
A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", message: "A parameter initializer is only allowed in a function or constructor implementation." }, |
|
Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: ts.DiagnosticCategory.Error, key: "Parameter_0_cannot_be_referenced_in_its_initializer_2372", message: "Parameter '{0}' cannot be referenced in its initializer." }, |
|
Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: ts.DiagnosticCategory.Error, key: "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", message: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, |
|
Duplicate_string_index_signature: { code: 2374, category: ts.DiagnosticCategory.Error, key: "Duplicate_string_index_signature_2374", message: "Duplicate string index signature." }, |
|
Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, |
|
A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, |
|
Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, |
|
A_get_accessor_must_return_a_value: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_2378", message: "A 'get' accessor must return a value." }, |
|
Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, |
|
get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, |
|
A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, |
|
Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", message: "Specialized overload signature is not assignable to any non-specialized signature." }, |
|
Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_not_exported_2383", message: "Overload signatures must all be exported or not exported." }, |
|
Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", message: "Overload signatures must all be ambient or non-ambient." }, |
|
Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_public_private_or_protected_2385", message: "Overload signatures must all be public, private or protected." }, |
|
Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_optional_or_required_2386", message: "Overload signatures must all be optional or required." }, |
|
Function_overload_must_be_static: { code: 2387, category: ts.DiagnosticCategory.Error, key: "Function_overload_must_be_static_2387", message: "Function overload must be static." }, |
|
Function_overload_must_not_be_static: { code: 2388, category: ts.DiagnosticCategory.Error, key: "Function_overload_must_not_be_static_2388", message: "Function overload must not be static." }, |
|
Function_implementation_name_must_be_0: { code: 2389, category: ts.DiagnosticCategory.Error, key: "Function_implementation_name_must_be_0_2389", message: "Function implementation name must be '{0}'." }, |
|
Constructor_implementation_is_missing: { code: 2390, category: ts.DiagnosticCategory.Error, key: "Constructor_implementation_is_missing_2390", message: "Constructor implementation is missing." }, |
|
Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: ts.DiagnosticCategory.Error, key: "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", message: "Function implementation is missing or not immediately following the declaration." }, |
|
Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple_constructor_implementations_are_not_allowed_2392", message: "Multiple constructor implementations are not allowed." }, |
|
Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate_function_implementation_2393", message: "Duplicate function implementation." }, |
|
Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload_signature_is_not_compatible_with_function_implementation_2394", message: "Overload signature is not compatible with function implementation." }, |
|
Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", message: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, |
|
Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", message: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, |
|
Declaration_name_conflicts_with_built_in_global_identifier_0: { code: 2397, category: ts.DiagnosticCategory.Error, key: "Declaration_name_conflicts_with_built_in_global_identifier_0_2397", message: "Declaration name conflicts with built-in global identifier '{0}'." }, |
|
Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", message: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, |
|
Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", message: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, |
|
Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401", message: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, |
|
Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", message: "Expression resolves to '_super' that compiler uses to capture base class reference." }, |
|
Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, |
|
The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", message: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, |
|
The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", message: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, |
|
Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_in_statement_2406", message: "Invalid left-hand side in 'for...in' statement." }, |
|
The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, |
|
Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, |
|
Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, |
|
All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All_symbols_within_a_with_block_will_be_resolved_to_any_2410", message: "All symbols within a 'with' block will be resolved to 'any'." }, |
|
Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, |
|
Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, |
|
Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, |
|
Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class_name_cannot_be_0_2414", message: "Class name cannot be '{0}'" }, |
|
Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_extends_base_class_1_2415", message: "Class '{0}' incorrectly extends base class '{1}'." }, |
|
Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", message: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, |
|
Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0_2419", message: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, |
|
Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_implements_interface_1_2420", message: "Class '{0}' incorrectly implements interface '{1}'." }, |
|
A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_implement_another_class_or_interface_2422", message: "A class may only implement another class or interface." }, |
|
Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, |
|
Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, |
|
Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", message: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, |
|
Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", message: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, |
|
Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface_name_cannot_be_0_2427", message: "Interface name cannot be '{0}'" }, |
|
All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_interface_must_have_identical_type_parameters_2428", message: "All declarations of an interface must have identical type parameters." }, |
|
Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface_0_incorrectly_extends_interface_1_2430", message: "Interface '{0}' incorrectly extends interface '{1}'." }, |
|
Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum_name_cannot_be_0_2431", message: "Enum name cannot be '{0}'" }, |
|
In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", message: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, |
|
A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, |
|
A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, |
|
Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", message: "Ambient modules cannot be nested in other modules or namespaces." }, |
|
Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient_module_declaration_cannot_specify_relative_module_name_2436", message: "Ambient module declaration cannot specify relative module name." }, |
|
Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name" }, |
|
Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'" }, |
|
Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", message: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, |
|
Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'" }, |
|
Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, |
|
Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types_have_separate_declarations_of_a_private_property_0_2442", message: "Types have separate declarations of a private property '{0}'." }, |
|
Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", message: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, |
|
Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", message: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, |
|
Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", message: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, |
|
Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, |
|
The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, |
|
Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, |
|
The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_2449", message: "The operand of an increment or decrement operator cannot be a constant." }, |
|
Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_2450", message: "Left-hand side of assignment expression cannot be a constant." }, |
|
Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, |
|
An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, |
|
The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, |
|
Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", message: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, |
|
Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type_alias_0_circularly_references_itself_2456", message: "Type alias '{0}' circularly references itself." }, |
|
Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'" }, |
|
An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An_AMD_module_cannot_have_multiple_name_assignments_2458", message: "An AMD module cannot have multiple name assignments." }, |
|
Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, |
|
Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, |
|
Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, |
|
A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_an_array_destructuring_pattern_2462", message: "A rest element must be last in an array destructuring pattern" }, |
|
A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, |
|
A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, |
|
this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, |
|
super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: ts.DiagnosticCategory.Error, key: "super_cannot_be_referenced_in_a_computed_property_name_2466", message: "'super' cannot be referenced in a computed property name." }, |
|
A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type_2467", message: "A computed property name cannot reference a type parameter from its containing type." }, |
|
Cannot_find_global_value_0: { code: 2468, category: ts.DiagnosticCategory.Error, key: "Cannot_find_global_value_0_2468", message: "Cannot find global value '{0}'." }, |
|
The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: ts.DiagnosticCategory.Error, key: "The_0_operator_cannot_be_applied_to_type_symbol_2469", message: "The '{0}' operator cannot be applied to type 'symbol'." }, |
|
Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: ts.DiagnosticCategory.Error, key: "Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470", message: "'Symbol' reference does not refer to the global Symbol constructor object." }, |
|
A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_of_the_form_0_must_be_of_type_symbol_2471", message: "A computed property name of the form '{0}' must be of type 'symbol'." }, |
|
Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: ts.DiagnosticCategory.Error, key: "Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher_2472", message: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." }, |
|
Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: ts.DiagnosticCategory.Error, key: "Enum_declarations_must_all_be_const_or_non_const_2473", message: "Enum declarations must all be const or non-const." }, |
|
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: ts.DiagnosticCategory.Error, key: "In_const_enum_declarations_member_initializer_must_be_constant_expression_2474", message: "In 'const' enum declarations member initializer must be constant expression." }, |
|
const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: ts.DiagnosticCategory.Error, key: "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475", message: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, |
|
A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: ts.DiagnosticCategory.Error, key: "A_const_enum_member_can_only_be_accessed_using_a_string_literal_2476", message: "A const enum member can only be accessed using a string literal." }, |
|
const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: ts.DiagnosticCategory.Error, key: "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477", message: "'const' enum member initializer was evaluated to a non-finite value." }, |
|
const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: ts.DiagnosticCategory.Error, key: "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478", message: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, |
|
Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: ts.DiagnosticCategory.Error, key: "Property_0_does_not_exist_on_const_enum_1_2479", message: "Property '{0}' does not exist on 'const' enum '{1}'." }, |
|
let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, |
|
Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, |
|
The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, |
|
Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, |
|
The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant_2485", message: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, |
|
The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant_2486", message: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, |
|
Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, |
|
Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, |
|
An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, |
|
The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, |
|
The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", message: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, |
|
Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause" }, |
|
Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", message: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, |
|
Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", message: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, |
|
Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_2495", message: "Type '{0}' is not an array type or a string type." }, |
|
The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_stand_2496", message: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, |
|
Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: ts.DiagnosticCategory.Error, key: "Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct_2497", message: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, |
|
Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: ts.DiagnosticCategory.Error, key: "Module_0_uses_export_and_cannot_be_used_with_export_Asterisk_2498", message: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, |
|
An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: ts.DiagnosticCategory.Error, key: "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499", message: "An interface can only extend an identifier/qualified-name with optional type arguments." }, |
|
A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: ts.DiagnosticCategory.Error, key: "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500", message: "A class can only implement an identifier/qualified-name with optional type arguments." }, |
|
A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_contain_a_binding_pattern_2501", message: "A rest element cannot contain a binding pattern." }, |
|
_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", message: "'{0}' is referenced directly or indirectly in its own type annotation." }, |
|
Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot_find_namespace_0_2503", message: "Cannot find namespace '{0}'." }, |
|
No_best_common_type_exists_among_yield_expressions: { code: 2504, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_yield_expressions_2504", message: "No best common type exists among yield expressions." }, |
|
A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A_generator_cannot_have_a_void_type_annotation_2505", message: "A generator cannot have a 'void' type annotation." }, |
|
_0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", message: "'{0}' is referenced directly or indirectly in its own base expression." }, |
|
Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_constructor_function_type_2507", message: "Type '{0}' is not a constructor function type." }, |
|
No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No_base_constructor_has_the_specified_number_of_type_arguments_2508", message: "No base constructor has the specified number of type arguments." }, |
|
Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509", message: "Base constructor return type '{0}' is not a class or interface type." }, |
|
Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base_constructors_must_all_have_the_same_return_type_2510", message: "Base constructors must all have the same return type." }, |
|
Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot_create_an_instance_of_the_abstract_class_0_2511", message: "Cannot create an instance of the abstract class '{0}'." }, |
|
Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_not_abstract_2512", message: "Overload signatures must all be abstract or not abstract." }, |
|
Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", message: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, |
|
Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes_containing_abstract_methods_must_be_marked_abstract_2514", message: "Classes containing abstract methods must be marked abstract." }, |
|
Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", message: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, |
|
All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, |
|
Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, |
|
A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { code: 2518, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", message: "A 'this'-based type guard is not compatible with a parameter-based type guard." }, |
|
Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, |
|
Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, |
|
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_2522", message: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, |
|
yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523", message: "'yield' expressions cannot be used in a parameter initializer." }, |
|
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "await_expressions_cannot_be_used_in_a_parameter_initializer_2524", message: "'await' expressions cannot be used in a parameter initializer." }, |
|
Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525", message: "Initializer provides no value for this binding element and the binding element has no default value." }, |
|
A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", message: "A 'this' type is available only in a non-static member of a class or interface." }, |
|
The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary_2527", message: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, |
|
A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A_module_cannot_have_multiple_default_exports_2528", message: "A module cannot have multiple default exports." }, |
|
Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: { code: 2529, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_func_2529", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module containing async functions." }, |
|
JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, |
|
The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, |
|
JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, |
|
Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, |
|
JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", message: "JSX element type '{0}' does not have any construct or call signatures." }, |
|
JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", message: "JSX element type '{0}' is not a constructor function for JSX elements." }, |
|
Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, |
|
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, |
|
The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, |
|
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, |
|
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, |
|
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, |
|
Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", message: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, |
|
Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", message: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, |
|
Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", message: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, |
|
JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element" }, |
|
Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'" }, |
|
super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { code: 2659, category: ts.DiagnosticCategory.Error, key: "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", message: "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher." }, |
|
super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { code: 2660, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", message: "'super' can only be referenced in members of derived classes or object literal expressions." }, |
|
Cannot_re_export_name_that_is_not_defined_in_the_module: { code: 2661, category: ts.DiagnosticCategory.Error, key: "Cannot_re_export_name_that_is_not_defined_in_the_module_2661", message: "Cannot re-export name that is not defined in the module." }, |
|
Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { code: 2662, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662", message: "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?" }, |
|
Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { code: 2663, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663", message: "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?" }, |
|
Invalid_module_name_in_augmentation_module_0_cannot_be_found: { code: 2664, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664", message: "Invalid module name in augmentation, module '{0}' cannot be found." }, |
|
Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope: { code: 2665, category: ts.DiagnosticCategory.Error, key: "Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope_2665", message: "Module augmentation cannot introduce new names in the top level scope." }, |
|
Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { code: 2666, category: ts.DiagnosticCategory.Error, key: "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666", message: "Exports and export assignments are not permitted in module augmentations." }, |
|
Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { code: 2667, category: ts.DiagnosticCategory.Error, key: "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667", message: "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module." }, |
|
export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { code: 2668, category: ts.DiagnosticCategory.Error, key: "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible." }, |
|
Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { code: 2669, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", message: "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations." }, |
|
Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { code: 2670, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", message: "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context." }, |
|
Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: { code: 2671, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity_2671", message: "Cannot augment module '{0}' because it resolves to a non-module entity." }, |
|
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, |
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, |
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, |
|
Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4006", message: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, |
|
Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008", message: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, |
|
Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4010", message: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, |
|
Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4012", message: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, |
|
Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", message: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, |
|
Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", message: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, |
|
Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: ts.DiagnosticCategory.Error, key: "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", message: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, |
|
Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", message: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, |
|
Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: ts.DiagnosticCategory.Error, key: "Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", message: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, |
|
Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", message: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, |
|
Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", message: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, |
|
Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: ts.DiagnosticCategory.Error, key: "Exported_variable_0_has_or_is_using_private_name_1_4025", message: "Exported variable '{0}' has or is using private name '{1}'." }, |
|
Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot__4026", message: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, |
|
Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4027", message: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, |
|
Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: ts.DiagnosticCategory.Error, key: "Public_static_property_0_of_exported_class_has_or_is_using_private_name_1_4028", message: "Public static property '{0}' of exported class has or is using private name '{1}'." }, |
|
Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_name_4029", message: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, |
|
Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4030", message: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, |
|
Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: ts.DiagnosticCategory.Error, key: "Public_property_0_of_exported_class_has_or_is_using_private_name_1_4031", message: "Public property '{0}' of exported class has or is using private name '{1}'." }, |
|
Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: ts.DiagnosticCategory.Error, key: "Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4032", message: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, |
|
Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: ts.DiagnosticCategory.Error, key: "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033", message: "Property '{0}' of exported interface has or is using private name '{1}'." }, |
|
Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_4034", message: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, |
|
Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1_4035", message: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, |
|
Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_4036", message: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, |
|
Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1_4037", message: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, |
|
Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_externa_4038", message: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, |
|
Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_4039", message: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, |
|
Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0_4040", message: "Return type of public static property getter from exported class has or is using private name '{0}'." }, |
|
Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_modul_4041", message: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, |
|
Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_4042", message: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, |
|
Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0_4043", message: "Return type of public property getter from exported class has or is using private name '{0}'." }, |
|
Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_mod_4044", message: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, |
|
Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0_4045", message: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, |
|
Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: ts.DiagnosticCategory.Error, key: "Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4046", message: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, |
|
Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: ts.DiagnosticCategory.Error, key: "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0_4047", message: "Return type of call signature from exported interface has or is using private name '{0}'." }, |
|
Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: ts.DiagnosticCategory.Error, key: "Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4048", message: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, |
|
Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: ts.DiagnosticCategory.Error, key: "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0_4049", message: "Return type of index signature from exported interface has or is using private name '{0}'." }, |
|
Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module__4050", message: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, |
|
Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4051", message: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, |
|
Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0_4052", message: "Return type of public static method from exported class has or is using private name '{0}'." }, |
|
Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_c_4053", message: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, |
|
Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4054", message: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, |
|
Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: ts.DiagnosticCategory.Error, key: "Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0_4055", message: "Return type of public method from exported class has or is using private name '{0}'." }, |
|
Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: ts.DiagnosticCategory.Error, key: "Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4056", message: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, |
|
Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: ts.DiagnosticCategory.Error, key: "Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0_4057", message: "Return type of method from exported interface has or is using private name '{0}'." }, |
|
Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named_4058", message: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, |
|
Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1_4059", message: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, |
|
Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: ts.DiagnosticCategory.Error, key: "Return_type_of_exported_function_has_or_is_using_private_name_0_4060", message: "Return type of exported function has or is using private name '{0}'." }, |
|
Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_can_4061", message: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, |
|
Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2_4062", message: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, |
|
Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1_4063", message: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, |
|
Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_mod_4064", message: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, |
|
Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4065", message: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, |
|
Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4066", message: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, |
|
Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4067", message: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, |
|
Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module__4068", message: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, |
|
Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4069", message: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, |
|
Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4070", message: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, |
|
Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_c_4071", message: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, |
|
Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4072", message: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, |
|
Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4073", message: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, |
|
Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4074", message: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, |
|
Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4075", message: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, |
|
Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4076", message: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, |
|
Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2_4077", message: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, |
|
Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_private_name_1_4078", message: "Parameter '{0}' of exported function has or is using private name '{1}'." }, |
|
Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported_type_alias_0_has_or_is_using_private_name_1_4081", message: "Exported type alias '{0}' has or is using private name '{1}'." }, |
|
Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default_export_of_the_module_has_or_is_using_private_name_0_4082", message: "Default export of the module has or is using private name '{0}'." }, |
|
The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, |
|
Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, |
|
Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}" }, |
|
Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported_file_encoding_5013", message: "Unsupported file encoding." }, |
|
Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed_to_parse_file_0_Colon_1_5014", message: "Failed to parse file '{0}': {1}." }, |
|
Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown_compiler_option_0_5023", message: "Unknown compiler option '{0}'." }, |
|
Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_requires_a_value_of_type_1_5024", message: "Compiler option '{0}' requires a value of type {1}." }, |
|
Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}" }, |
|
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", message: "Option 'project' cannot be mixed with source files on a command line." }, |
|
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", message: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, |
|
Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_prov_5051", message: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, |
|
Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option_0_cannot_be_specified_without_specifying_option_1_5052", message: "Option '{0}' cannot be specified without specifying option '{1}'." }, |
|
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option_0_cannot_be_specified_with_option_1_5053", message: "Option '{0}' cannot be specified with option '{1}'." }, |
|
A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", message: "A 'tsconfig.json' file is already defined at: '{0}'." }, |
|
Cannot_write_file_0_because_it_would_overwrite_input_file: { code: 5055, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_overwrite_input_file_5055", message: "Cannot write file '{0}' because it would overwrite input file." }, |
|
Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: { code: 5056, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files_5056", message: "Cannot write file '{0}' because it would be overwritten by multiple input files." }, |
|
Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: { code: 5057, category: ts.DiagnosticCategory.Error, key: "Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0_5057", message: "Cannot find a tsconfig.json file at the specified directory: '{0}'" }, |
|
The_specified_path_does_not_exist_Colon_0: { code: 5058, category: ts.DiagnosticCategory.Error, key: "The_specified_path_does_not_exist_Colon_0_5058", message: "The specified path does not exist: '{0}'" }, |
|
Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier: { code: 5059, category: ts.DiagnosticCategory.Error, key: "Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", message: "Invalide value for '--reactNamespace'. '{0}' is not a valid identifier." }, |
|
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, |
|
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, |
|
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", message: "Specifies the location where debugger should locate map files instead of generated locations." }, |
|
Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: ts.DiagnosticCategory.Message, key: "Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations_6004", message: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, |
|
Watch_input_files: { code: 6005, category: ts.DiagnosticCategory.Message, key: "Watch_input_files_6005", message: "Watch input files." }, |
|
Redirect_output_structure_to_the_directory: { code: 6006, category: ts.DiagnosticCategory.Message, key: "Redirect_output_structure_to_the_directory_6006", message: "Redirect output structure to the directory." }, |
|
Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: ts.DiagnosticCategory.Message, key: "Do_not_erase_const_enum_declarations_in_generated_code_6007", message: "Do not erase const enum declarations in generated code." }, |
|
Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_if_any_errors_were_reported_6008", message: "Do not emit outputs if any errors were reported." }, |
|
Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_comments_to_output_6009", message: "Do not emit comments to output." }, |
|
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." }, |
|
Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." }, |
|
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_experimental_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)" }, |
|
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, |
|
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, |
|
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, |
|
Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_in_the_given_directory_6020", message: "Compile the project in the given directory." }, |
|
Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, |
|
options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, |
|
file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, |
|
Examples_Colon_0: { code: 6026, category: ts.DiagnosticCategory.Message, key: "Examples_Colon_0_6026", message: "Examples: {0}" }, |
|
Options_Colon: { code: 6027, category: ts.DiagnosticCategory.Message, key: "Options_Colon_6027", message: "Options:" }, |
|
Version_0: { code: 6029, category: ts.DiagnosticCategory.Message, key: "Version_0_6029", message: "Version {0}" }, |
|
Insert_command_line_options_and_files_from_a_file: { code: 6030, category: ts.DiagnosticCategory.Message, key: "Insert_command_line_options_and_files_from_a_file_6030", message: "Insert command line options and files from a file." }, |
|
File_change_detected_Starting_incremental_compilation: { code: 6032, category: ts.DiagnosticCategory.Message, key: "File_change_detected_Starting_incremental_compilation_6032", message: "File change detected. Starting incremental compilation..." }, |
|
KIND: { code: 6034, category: ts.DiagnosticCategory.Message, key: "KIND_6034", message: "KIND" }, |
|
FILE: { code: 6035, category: ts.DiagnosticCategory.Message, key: "FILE_6035", message: "FILE" }, |
|
VERSION: { code: 6036, category: ts.DiagnosticCategory.Message, key: "VERSION_6036", message: "VERSION" }, |
|
LOCATION: { code: 6037, category: ts.DiagnosticCategory.Message, key: "LOCATION_6037", message: "LOCATION" }, |
|
DIRECTORY: { code: 6038, category: ts.DiagnosticCategory.Message, key: "DIRECTORY_6038", message: "DIRECTORY" }, |
|
Compilation_complete_Watching_for_file_changes: { code: 6042, category: ts.DiagnosticCategory.Message, key: "Compilation_complete_Watching_for_file_changes_6042", message: "Compilation complete. Watching for file changes." }, |
|
Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, |
|
Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, |
|
Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated_quoted_string_in_response_file_0_6045", message: "Unterminated quoted string in response file '{0}'." }, |
|
Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'none'." }, |
|
Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument_for_target_option_must_be_ES3_ES5_or_ES2015_6047", message: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, |
|
Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", message: "Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'." }, |
|
Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported_locale_0_6049", message: "Unsupported locale '{0}'." }, |
|
Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable_to_open_file_0_6050", message: "Unable to open file '{0}'." }, |
|
Corrupted_locale_file_0: { code: 6051, category: ts.DiagnosticCategory.Error, key: "Corrupted_locale_file_0_6051", message: "Corrupted locale file {0}." }, |
|
Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: ts.DiagnosticCategory.Message, key: "Raise_error_on_expressions_and_declarations_with_an_implied_any_type_6052", message: "Raise error on expressions and declarations with an implied 'any' type." }, |
|
File_0_not_found: { code: 6053, category: ts.DiagnosticCategory.Error, key: "File_0_not_found_6053", message: "File '{0}' not found." }, |
|
File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File_0_has_unsupported_extension_The_only_supported_extensions_are_1_6054", message: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, |
|
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures_6055", message: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, |
|
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_declarations_for_code_that_has_an_internal_annotation_6056", message: "Do not emit declarations for code that has an '@internal' annotation." }, |
|
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDi_6058", message: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, |
|
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", message: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, |
|
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", message: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, |
|
NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, |
|
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, |
|
Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, |
|
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, |
|
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, |
|
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, |
|
Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6_6069", message: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, |
|
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, |
|
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, |
|
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, |
|
Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, |
|
Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, |
|
Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, |
|
Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, |
|
Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, |
|
Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, |
|
Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, |
|
Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, |
|
Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, |
|
Allow_javascript_files_to_be_compiled: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6083", message: "Allow javascript files to be compiled." }, |
|
Specifies_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specifies_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specifies the object invoked for createElement and __spread when targeting 'react' JSX emit" }, |
|
Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, |
|
Do_not_emit_use_strict_directives_in_module_output: { code: 6112, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_use_strict_directives_in_module_output_6112", message: "Do not emit 'use strict' directives in module output." }, |
|
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, |
|
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, |
|
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, |
|
new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: ts.DiagnosticCategory.Error, key: "new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type_7009", message: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, |
|
_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: ts.DiagnosticCategory.Error, key: "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", message: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, |
|
Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", message: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, |
|
Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", message: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, |
|
Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { code: 7015, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", message: "Element implicitly has an 'any' type because index expression is not of type 'number'." }, |
|
Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation_7016", message: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, |
|
Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index_signature_of_object_type_implicitly_has_an_any_type_7017", message: "Index signature of object type implicitly has an 'any' type." }, |
|
Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object_literal_s_property_0_implicitly_has_an_1_type_7018", message: "Object literal's property '{0}' implicitly has an '{1}' type." }, |
|
Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest_parameter_0_implicitly_has_an_any_type_7019", message: "Rest parameter '{0}' implicitly has an 'any[]' type." }, |
|
Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", message: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, |
|
_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or__7022", message: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." }, |
|
_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", message: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, |
|
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, |
|
Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, |
|
JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, |
|
Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, |
|
Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, |
|
Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, |
|
Not_all_code_paths_return_a_value: { code: 7030, category: ts.DiagnosticCategory.Error, key: "Not_all_code_paths_return_a_value_7030", message: "Not all code paths return a value." }, |
|
You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, |
|
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, |
|
import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, |
|
export_can_only_be_used_in_a_ts_file: { code: 8003, category: ts.DiagnosticCategory.Error, key: "export_can_only_be_used_in_a_ts_file_8003", message: "'export=' can only be used in a .ts file." }, |
|
type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: ts.DiagnosticCategory.Error, key: "type_parameter_declarations_can_only_be_used_in_a_ts_file_8004", message: "'type parameter declarations' can only be used in a .ts file." }, |
|
implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: ts.DiagnosticCategory.Error, key: "implements_clauses_can_only_be_used_in_a_ts_file_8005", message: "'implements clauses' can only be used in a .ts file." }, |
|
interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: ts.DiagnosticCategory.Error, key: "interface_declarations_can_only_be_used_in_a_ts_file_8006", message: "'interface declarations' can only be used in a .ts file." }, |
|
module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: ts.DiagnosticCategory.Error, key: "module_declarations_can_only_be_used_in_a_ts_file_8007", message: "'module declarations' can only be used in a .ts file." }, |
|
type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: ts.DiagnosticCategory.Error, key: "type_aliases_can_only_be_used_in_a_ts_file_8008", message: "'type aliases' can only be used in a .ts file." }, |
|
_0_can_only_be_used_in_a_ts_file: { code: 8009, category: ts.DiagnosticCategory.Error, key: "_0_can_only_be_used_in_a_ts_file_8009", message: "'{0}' can only be used in a .ts file." }, |
|
types_can_only_be_used_in_a_ts_file: { code: 8010, category: ts.DiagnosticCategory.Error, key: "types_can_only_be_used_in_a_ts_file_8010", message: "'types' can only be used in a .ts file." }, |
|
type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: ts.DiagnosticCategory.Error, key: "type_arguments_can_only_be_used_in_a_ts_file_8011", message: "'type arguments' can only be used in a .ts file." }, |
|
parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: ts.DiagnosticCategory.Error, key: "parameter_modifiers_can_only_be_used_in_a_ts_file_8012", message: "'parameter modifiers' can only be used in a .ts file." }, |
|
property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "property_declarations_can_only_be_used_in_a_ts_file_8014", message: "'property declarations' can only be used in a .ts file." }, |
|
enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "enum_declarations_can_only_be_used_in_a_ts_file_8015", message: "'enum declarations' can only be used in a .ts file." }, |
|
type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "type_assertion_expressions_can_only_be_used_in_a_ts_file_8016", message: "'type assertion expressions' can only be used in a .ts file." }, |
|
Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, |
|
class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, |
|
JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, |
|
JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", message: "JSX elements cannot have multiple attributes with the same name." }, |
|
Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected_corresponding_JSX_closing_tag_for_0_17002", message: "Expected corresponding JSX closing tag for '{0}'." }, |
|
JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX_attribute_expected_17003", message: "JSX attribute expected." }, |
|
Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", message: "Cannot use JSX unless the '--jsx' flag is provided." }, |
|
A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, |
|
An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", message: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, |
|
A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", message: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, |
|
JSX_element_0_has_no_corresponding_closing_tag: { code: 17008, category: ts.DiagnosticCategory.Error, key: "JSX_element_0_has_no_corresponding_closing_tag_17008", message: "JSX element '{0}' has no corresponding closing tag." }, |
|
super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, |
|
Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, |
|
Too_many_JavaScript_files_in_the_project_Consider_specifying_the_exclude_setting_in_project_configuration_to_limit_included_source_folders_The_likely_folder_to_exclude_is_0_To_disable_the_project_size_limit_set_the_disableSizeLimit_compiler_option_to_true: { code: 17012, category: ts.DiagnosticCategory.Error, key: "Too_many_JavaScript_files_in_the_project_Consider_specifying_the_exclude_setting_in_project_configur_17012", message: "Too many JavaScript files in the project. Consider specifying the 'exclude' setting in project configuration to limit included source folders. The likely folder to exclude is '{0}'. To disable the project size limit, set the 'disableSizeLimit' compiler option to 'true'." } |
|
}; |
|
})(ts || (ts = {})); |
|
/// <reference path="core.ts"/> |
|
/// <reference path="diagnosticInformationMap.generated.ts"/> |
|
var ts; |
|
(function (ts) { |
|
/* @internal */ |
|
function tokenIsIdentifierOrKeyword(token) { |
|
return token >= 69 /* Identifier */; |
|
} |
|
ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; |
|
var textToToken = { |
|
"abstract": 115 /* AbstractKeyword */, |
|
"any": 117 /* AnyKeyword */, |
|
"as": 116 /* AsKeyword */, |
|
"boolean": 120 /* BooleanKeyword */, |
|
"break": 70 /* BreakKeyword */, |
|
"case": 71 /* CaseKeyword */, |
|
"catch": 72 /* CatchKeyword */, |
|
"class": 73 /* ClassKeyword */, |
|
"continue": 75 /* ContinueKeyword */, |
|
"const": 74 /* ConstKeyword */, |
|
"constructor": 121 /* ConstructorKeyword */, |
|
"debugger": 76 /* DebuggerKeyword */, |
|
"declare": 122 /* DeclareKeyword */, |
|
"default": 77 /* DefaultKeyword */, |
|
"delete": 78 /* DeleteKeyword */, |
|
"do": 79 /* DoKeyword */, |
|
"else": 80 /* ElseKeyword */, |
|
"enum": 81 /* EnumKeyword */, |
|
"export": 82 /* ExportKeyword */, |
|
"extends": 83 /* ExtendsKeyword */, |
|
"false": 84 /* FalseKeyword */, |
|
"finally": 85 /* FinallyKeyword */, |
|
"for": 86 /* ForKeyword */, |
|
"from": 133 /* FromKeyword */, |
|
"function": 87 /* FunctionKeyword */, |
|
"get": 123 /* GetKeyword */, |
|
"if": 88 /* IfKeyword */, |
|
"implements": 106 /* ImplementsKeyword */, |
|
"import": 89 /* ImportKeyword */, |
|
"in": 90 /* InKeyword */, |
|
"instanceof": 91 /* InstanceOfKeyword */, |
|
"interface": 107 /* InterfaceKeyword */, |
|
"is": 124 /* IsKeyword */, |
|
"let": 108 /* LetKeyword */, |
|
"module": 125 /* ModuleKeyword */, |
|
"namespace": 126 /* NamespaceKeyword */, |
|
"new": 92 /* NewKeyword */, |
|
"null": 93 /* NullKeyword */, |
|
"number": 128 /* NumberKeyword */, |
|
"package": 109 /* PackageKeyword */, |
|
"private": 110 /* PrivateKeyword */, |
|
"protected": 111 /* ProtectedKeyword */, |
|
"public": 112 /* PublicKeyword */, |
|
"require": 127 /* RequireKeyword */, |
|
"global": 134 /* GlobalKeyword */, |
|
"return": 94 /* ReturnKeyword */, |
|
"set": 129 /* SetKeyword */, |
|
"static": 113 /* StaticKeyword */, |
|
"string": 130 /* StringKeyword */, |
|
"super": 95 /* SuperKeyword */, |
|
"switch": 96 /* SwitchKeyword */, |
|
"symbol": 131 /* SymbolKeyword */, |
|
"this": 97 /* ThisKeyword */, |
|
"throw": 98 /* ThrowKeyword */, |
|
"true": 99 /* TrueKeyword */, |
|
"try": 100 /* TryKeyword */, |
|
"type": 132 /* TypeKeyword */, |
|
"typeof": 101 /* TypeOfKeyword */, |
|
"var": 102 /* VarKeyword */, |
|
"void": 103 /* VoidKeyword */, |
|
"while": 104 /* WhileKeyword */, |
|
"with": 105 /* WithKeyword */, |
|
"yield": 114 /* YieldKeyword */, |
|
"async": 118 /* AsyncKeyword */, |
|
"await": 119 /* AwaitKeyword */, |
|
"of": 135 /* OfKeyword */, |
|
"{": 15 /* OpenBraceToken */, |
|
"}": 16 /* CloseBraceToken */, |
|
"(": 17 /* OpenParenToken */, |
|
")": 18 /* CloseParenToken */, |
|
"[": 19 /* OpenBracketToken */, |
|
"]": 20 /* CloseBracketToken */, |
|
".": 21 /* DotToken */, |
|
"...": 22 /* DotDotDotToken */, |
|
";": 23 /* SemicolonToken */, |
|
",": 24 /* CommaToken */, |
|
"<": 25 /* LessThanToken */, |
|
">": 27 /* GreaterThanToken */, |
|
"<=": 28 /* LessThanEqualsToken */, |
|
">=": 29 /* GreaterThanEqualsToken */, |
|
"==": 30 /* EqualsEqualsToken */, |
|
"!=": 31 /* ExclamationEqualsToken */, |
|
"===": 32 /* EqualsEqualsEqualsToken */, |
|
"!==": 33 /* ExclamationEqualsEqualsToken */, |
|
"=>": 34 /* EqualsGreaterThanToken */, |
|
"+": 35 /* PlusToken */, |
|
"-": 36 /* MinusToken */, |
|
"**": 38 /* AsteriskAsteriskToken */, |
|
"*": 37 /* AsteriskToken */, |
|
"/": 39 /* SlashToken */, |
|
"%": 40 /* PercentToken */, |
|
"++": 41 /* PlusPlusToken */, |
|
"--": 42 /* MinusMinusToken */, |
|
"<<": 43 /* LessThanLessThanToken */, |
|
"</": 26 /* LessThanSlashToken */, |
|
">>": 44 /* GreaterThanGreaterThanToken */, |
|
">>>": 45 /* GreaterThanGreaterThanGreaterThanToken */, |
|
"&": 46 /* AmpersandToken */, |
|
"|": 47 /* BarToken */, |
|
"^": 48 /* CaretToken */, |
|
"!": 49 /* ExclamationToken */, |
|
"~": 50 /* TildeToken */, |
|
"&&": 51 /* AmpersandAmpersandToken */, |
|
"||": 52 /* BarBarToken */, |
|
"?": 53 /* QuestionToken */, |
|
":": 54 /* ColonToken */, |
|
"=": 56 /* EqualsToken */, |
|
"+=": 57 /* PlusEqualsToken */, |
|
"-=": 58 /* MinusEqualsToken */, |
|
"*=": 59 /* AsteriskEqualsToken */, |
|
"**=": 60 /* AsteriskAsteriskEqualsToken */, |
|
"/=": 61 /* SlashEqualsToken */, |
|
"%=": 62 /* PercentEqualsToken */, |
|
"<<=": 63 /* LessThanLessThanEqualsToken */, |
|
">>=": 64 /* GreaterThanGreaterThanEqualsToken */, |
|
">>>=": 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */, |
|
"&=": 66 /* AmpersandEqualsToken */, |
|
"|=": 67 /* BarEqualsToken */, |
|
"^=": 68 /* CaretEqualsToken */, |
|
"@": 55 /* AtToken */ |
|
}; |
|
/* |
|
As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers |
|
IdentifierStart :: |
|
Can contain Unicode 3.0.0 categories: |
|
Uppercase letter (Lu), |
|
Lowercase letter (Ll), |
|
Titlecase letter (Lt), |
|
Modifier letter (Lm), |
|
Other letter (Lo), or |
|
Letter number (Nl). |
|
IdentifierPart :: = |
|
Can contain IdentifierStart + Unicode 3.0.0 categories: |
|
Non-spacing mark (Mn), |
|
Combining spacing mark (Mc), |
|
Decimal number (Nd), or |
|
Connector punctuation (Pc). |
|
|
|
Codepoint ranges for ES3 Identifiers are extracted from the Unicode 3.0.0 specification at: |
|
http://www.unicode.org/Public/3.0-Update/UnicodeData-3.0.0.txt |
|
*/ |
|
var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; |
|
var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; |
|
/* |
|
As per ECMAScript Language Specification 5th Edition, Section 7.6: ISyntaxToken Names and Identifiers |
|
IdentifierStart :: |
|
Can contain Unicode 6.2 categories: |
|
Uppercase letter (Lu), |
|
Lowercase letter (Ll), |
|
Titlecase letter (Lt), |
|
Modifier letter (Lm), |
|
Other letter (Lo), or |
|
Letter number (Nl). |
|
IdentifierPart :: |
|
Can contain IdentifierStart + Unicode 6.2 categories: |
|
Non-spacing mark (Mn), |
|
Combining spacing mark (Mc), |
|
Decimal number (Nd), |
|
Connector punctuation (Pc), |
|
<ZWNJ>, or |
|
<ZWJ>. |
|
|
|
Codepoint ranges for ES5 Identifiers are extracted from the Unicode 6.2 specification at: |
|
http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt |
|
*/ |
|
var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; |
|
var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; |
|
function lookupInUnicodeMap(code, map) { |
|
// Bail out quickly if it couldn't possibly be in the map. |
|
if (code < map[0]) { |
|
return false; |
|
} |
|
// Perform binary search in one of the Unicode range maps |
|
var lo = 0; |
|
var hi = map.length; |
|
var mid; |
|
while (lo + 1 < hi) { |
|
mid = lo + (hi - lo) / 2; |
|
// mid has to be even to catch a range's beginning |
|
mid -= mid % 2; |
|
if (map[mid] <= code && code <= map[mid + 1]) { |
|
return true; |
|
} |
|
if (code < map[mid]) { |
|
hi = mid; |
|
} |
|
else { |
|
lo = mid + 2; |
|
} |
|
} |
|
return false; |
|
} |
|
/* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { |
|
return languageVersion >= 1 /* ES5 */ ? |
|
lookupInUnicodeMap(code, unicodeES5IdentifierStart) : |
|
lookupInUnicodeMap(code, unicodeES3IdentifierStart); |
|
} |
|
ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; |
|
function isUnicodeIdentifierPart(code, languageVersion) { |
|
return languageVersion >= 1 /* ES5 */ ? |
|
lookupInUnicodeMap(code, unicodeES5IdentifierPart) : |
|
lookupInUnicodeMap(code, unicodeES3IdentifierPart); |
|
} |
|
function makeReverseMap(source) { |
|
var result = []; |
|
for (var name_4 in source) { |
|
if (source.hasOwnProperty(name_4)) { |
|
result[source[name_4]] = name_4; |
|
} |
|
} |
|
return result; |
|
} |
|
var tokenStrings = makeReverseMap(textToToken); |
|
function tokenToString(t) { |
|
return tokenStrings[t]; |
|
} |
|
ts.tokenToString = tokenToString; |
|
/* @internal */ |
|
function stringToToken(s) { |
|
return textToToken[s]; |
|
} |
|
ts.stringToToken = stringToToken; |
|
/* @internal */ |
|
function computeLineStarts(text) { |
|
var result = new Array(); |
|
var pos = 0; |
|
var lineStart = 0; |
|
while (pos < text.length) { |
|
var ch = text.charCodeAt(pos); |
|
pos++; |
|
switch (ch) { |
|
case 13 /* carriageReturn */: |
|
if (text.charCodeAt(pos) === 10 /* lineFeed */) { |
|
pos++; |
|
} |
|
case 10 /* lineFeed */: |
|
result.push(lineStart); |
|
lineStart = pos; |
|
break; |
|
default: |
|
if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { |
|
result.push(lineStart); |
|
lineStart = pos; |
|
} |
|
break; |
|
} |
|
} |
|
result.push(lineStart); |
|
return result; |
|
} |
|
ts.computeLineStarts = computeLineStarts; |
|
function getPositionOfLineAndCharacter(sourceFile, line, character) { |
|
return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); |
|
} |
|
ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter; |
|
/* @internal */ |
|
function computePositionOfLineAndCharacter(lineStarts, line, character) { |
|
ts.Debug.assert(line >= 0 && line < lineStarts.length); |
|
return lineStarts[line] + character; |
|
} |
|
ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; |
|
/* @internal */ |
|
function getLineStarts(sourceFile) { |
|
return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); |
|
} |
|
ts.getLineStarts = getLineStarts; |
|
/* @internal */ |
|
/** |
|
* We assume the first line starts at position 0 and 'position' is non-negative. |
|
*/ |
|
function computeLineAndCharacterOfPosition(lineStarts, position) { |
|
var lineNumber = ts.binarySearch(lineStarts, position); |
|
if (lineNumber < 0) { |
|
// If the actual position was not found, |
|
// the binary search returns the 2's-complement of the next line start |
|
// e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 |
|
// then the search will return -2. |
|
// |
|
// We want the index of the previous line start, so we subtract 1. |
|
// Review 2's-complement if this is confusing. |
|
lineNumber = ~lineNumber - 1; |
|
ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); |
|
} |
|
return { |
|
line: lineNumber, |
|
character: position - lineStarts[lineNumber] |
|
}; |
|
} |
|
ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition; |
|
function getLineAndCharacterOfPosition(sourceFile, position) { |
|
return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); |
|
} |
|
ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; |
|
var hasOwnProperty = Object.prototype.hasOwnProperty; |
|
function isWhiteSpace(ch) { |
|
// Note: nextLine is in the Zs space, and should be considered to be a whitespace. |
|
// It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. |
|
return ch === 32 /* space */ || |
|
ch === 9 /* tab */ || |
|
ch === 11 /* verticalTab */ || |
|
ch === 12 /* formFeed */ || |
|
ch === 160 /* nonBreakingSpace */ || |
|
ch === 133 /* nextLine */ || |
|
ch === 5760 /* ogham */ || |
|
ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || |
|
ch === 8239 /* narrowNoBreakSpace */ || |
|
ch === 8287 /* mathematicalSpace */ || |
|
ch === 12288 /* ideographicSpace */ || |
|
ch === 65279 /* byteOrderMark */; |
|
} |
|
ts.isWhiteSpace = isWhiteSpace; |
|
function isLineBreak(ch) { |
|
// ES5 7.3: |
|
// The ECMAScript line terminator characters are listed in Table 3. |
|
// Table 3: Line Terminator Characters |
|
// Code Unit Value Name Formal Name |
|
// \u000A Line Feed <LF> |
|
// \u000D Carriage Return <CR> |
|
// \u2028 Line separator <LS> |
|
// \u2029 Paragraph separator <PS> |
|
// Only the characters in Table 3 are treated as line terminators. Other new line or line |
|
// breaking characters are treated as white space but not as line terminators. |
|
return ch === 10 /* lineFeed */ || |
|
ch === 13 /* carriageReturn */ || |
|
ch === 8232 /* lineSeparator */ || |
|
ch === 8233 /* paragraphSeparator */; |
|
} |
|
ts.isLineBreak = isLineBreak; |
|
function isDigit(ch) { |
|
return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; |
|
} |
|
/* @internal */ |
|
function isOctalDigit(ch) { |
|
return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; |
|
} |
|
ts.isOctalDigit = isOctalDigit; |
|
function couldStartTrivia(text, pos) { |
|
// Keep in sync with skipTrivia |
|
var ch = text.charCodeAt(pos); |
|
switch (ch) { |
|
case 13 /* carriageReturn */: |
|
case 10 /* lineFeed */: |
|
case 9 /* tab */: |
|
case 11 /* verticalTab */: |
|
case 12 /* formFeed */: |
|
case 32 /* space */: |
|
case 47 /* slash */: |
|
// starts of normal trivia |
|
case 60 /* lessThan */: |
|
case 61 /* equals */: |
|
case 62 /* greaterThan */: |
|
// Starts of conflict marker trivia |
|
return true; |
|
case 35 /* hash */: |
|
// Only if its the beginning can we have #! trivia |
|
return pos === 0; |
|
default: |
|
return ch > 127 /* maxAsciiCharacter */; |
|
} |
|
} |
|
ts.couldStartTrivia = couldStartTrivia; |
|
/* @internal */ |
|
function skipTrivia(text, pos, stopAfterLineBreak) { |
|
// Using ! with a greater than test is a fast way of testing the following conditions: |
|
// pos === undefined || pos === null || isNaN(pos) || pos < 0; |
|
if (!(pos >= 0)) { |
|
return pos; |
|
} |
|
// Keep in sync with couldStartTrivia |
|
while (true) { |
|
var ch = text.charCodeAt(pos); |
|
switch (ch) { |
|
case 13 /* carriageReturn */: |
|
if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { |
|
pos++; |
|
} |
|
case 10 /* lineFeed */: |
|
pos++; |
|
if (stopAfterLineBreak) { |
|
return pos; |
|
} |
|
continue; |
|
case 9 /* tab */: |
|
case 11 /* verticalTab */: |
|
case 12 /* formFeed */: |
|
case 32 /* space */: |
|
pos++; |
|
continue; |
|
case 47 /* slash */: |
|
if (text.charCodeAt(pos + 1) === 47 /* slash */) { |
|
pos += 2; |
|
while (pos < text.length) { |
|
if (isLineBreak(text.charCodeAt(pos))) { |
|
break; |
|
} |
|
pos++; |
|
} |
|
continue; |
|
} |
|
if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { |
|
pos += 2; |
|
while (pos < text.length) { |
|
if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { |
|
pos += 2; |
|
break; |
|
} |
|
pos++; |
|
} |
|
continue; |
|
} |
|
break; |
|
case 60 /* lessThan */: |
|
case 61 /* equals */: |
|
case 62 /* greaterThan */: |
|
if (isConflictMarkerTrivia(text, pos)) { |
|
pos = scanConflictMarkerTrivia(text, pos); |
|
continue; |
|
} |
|
break; |
|
case 35 /* hash */: |
|
if (pos === 0 && isShebangTrivia(text, pos)) { |
|
pos = scanShebangTrivia(text, pos); |
|
continue; |
|
} |
|
break; |
|
default: |
|
if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { |
|
pos++; |
|
continue; |
|
} |
|
break; |
|
} |
|
return pos; |
|
} |
|
} |
|
ts.skipTrivia = skipTrivia; |
|
// All conflict markers consist of the same character repeated seven times. If it is |
|
// a <<<<<<< or >>>>>>> marker then it is also followd by a space. |
|
var mergeConflictMarkerLength = "<<<<<<<".length; |
|
function isConflictMarkerTrivia(text, pos) { |
|
ts.Debug.assert(pos >= 0); |
|
// Conflict markers must be at the start of a line. |
|
if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { |
|
var ch = text.charCodeAt(pos); |
|
if ((pos + mergeConflictMarkerLength) < text.length) { |
|
for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { |
|
if (text.charCodeAt(pos + i) !== ch) { |
|
return false; |
|
} |
|
} |
|
return ch === 61 /* equals */ || |
|
text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; |
|
} |
|
} |
|
return false; |
|
} |
|
function scanConflictMarkerTrivia(text, pos, error) { |
|
if (error) { |
|
error(ts.Diagnostics.Merge_conflict_marker_encountered, mergeConflictMarkerLength); |
|
} |
|
var ch = text.charCodeAt(pos); |
|
var len = text.length; |
|
if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { |
|
while (pos < len && !isLineBreak(text.charCodeAt(pos))) { |
|
pos++; |
|
} |
|
} |
|
else { |
|
ts.Debug.assert(ch === 61 /* equals */); |
|
// Consume everything from the start of the mid-conlict marker to the start of the next |
|
// end-conflict marker. |
|
while (pos < len) { |
|
var ch_1 = text.charCodeAt(pos); |
|
if (ch_1 === 62 /* greaterThan */ && isConflictMarkerTrivia(text, pos)) { |
|
break; |
|
} |
|
pos++; |
|
} |
|
} |
|
return pos; |
|
} |
|
var shebangTriviaRegex = /^#!.*/; |
|
function isShebangTrivia(text, pos) { |
|
// Shebangs check must only be done at the start of the file |
|
ts.Debug.assert(pos === 0); |
|
return shebangTriviaRegex.test(text); |
|
} |
|
function scanShebangTrivia(text, pos) { |
|
var shebang = shebangTriviaRegex.exec(text)[0]; |
|
pos = pos + shebang.length; |
|
return pos; |
|
} |
|
/** |
|
* Extract comments from text prefixing the token closest following `pos`. |
|
* The return value is an array containing a TextRange for each comment. |
|
* Single-line comment ranges include the beginning '//' characters but not the ending line break. |
|
* Multi - line comment ranges include the beginning '/* and ending '<asterisk>/' characters. |
|
* The return value is undefined if no comments were found. |
|
* @param trailing |
|
* If false, whitespace is skipped until the first line break and comments between that location |
|
* and the next token are returned. |
|
* If true, comments occurring between the given position and the next line break are returned. |
|
*/ |
|
function getCommentRanges(text, pos, trailing) { |
|
var result; |
|
var collecting = trailing || pos === 0; |
|
while (pos < text.length) { |
|
var ch = text.charCodeAt(pos); |
|
switch (ch) { |
|
case 13 /* carriageReturn */: |
|
if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { |
|
pos++; |
|
} |
|
case 10 /* lineFeed */: |
|
pos++; |
|
if (trailing) { |
|
return result; |
|
} |
|
collecting = true; |
|
if (result && result.length) { |
|
ts.lastOrUndefined(result).hasTrailingNewLine = true; |
|
} |
|
continue; |
|
case 9 /* tab */: |
|
case 11 /* verticalTab */: |
|
case 12 /* formFeed */: |
|
case 32 /* space */: |
|
pos++; |
|
continue; |
|
case 47 /* slash */: |
|
var nextChar = text.charCodeAt(pos + 1); |
|
var hasTrailingNewLine = false; |
|
if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { |
|
var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; |
|
var startPos = pos; |
|
pos += 2; |
|
if (nextChar === 47 /* slash */) { |
|
while (pos < text.length) { |
|
if (isLineBreak(text.charCodeAt(pos))) { |
|
hasTrailingNewLine = true; |
|
break; |
|
} |
|
pos++; |
|
} |
|
} |
|
else { |
|
while (pos < text.length) { |
|
if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { |
|
pos += 2; |
|
break; |
|
} |
|
pos++; |
|
} |
|
} |
|
if (collecting) { |
|
if (!result) { |
|
result = []; |
|
} |
|
result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); |
|
} |
|
continue; |
|
} |
|
break; |
|
default: |
|
if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { |
|
if (result && result.length && isLineBreak(ch)) { |
|
ts.lastOrUndefined(result).hasTrailingNewLine = true; |
|
} |
|
pos++; |
|
continue; |
|
} |
|
break; |
|
} |
|
return result; |
|
} |
|
return result; |
|
} |
|
function getLeadingCommentRanges(text, pos) { |
|
return getCommentRanges(text, pos, /*trailing*/ false); |
|
} |
|
ts.getLeadingCommentRanges = getLeadingCommentRanges; |
|
function getTrailingCommentRanges(text, pos) { |
|
return getCommentRanges(text, pos, /*trailing*/ true); |
|
} |
|
ts.getTrailingCommentRanges = getTrailingCommentRanges; |
|
/** Optionally, get the shebang */ |
|
function getShebang(text) { |
|
return shebangTriviaRegex.test(text) |
|
? shebangTriviaRegex.exec(text)[0] |
|
: undefined; |
|
} |
|
ts.getShebang = getShebang; |
|
function isIdentifierStart(ch, languageVersion) { |
|
return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || |
|
ch === 36 /* $ */ || ch === 95 /* _ */ || |
|
ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); |
|
} |
|
ts.isIdentifierStart = isIdentifierStart; |
|
function isIdentifierPart(ch, languageVersion) { |
|
return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || |
|
ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || |
|
ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); |
|
} |
|
ts.isIdentifierPart = isIdentifierPart; |
|
/* @internal */ |
|
function isIdentifier(name, languageVersion) { |
|
if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { |
|
return false; |
|
} |
|
for (var i = 1, n = name.length; i < n; i++) { |
|
if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { |
|
return false; |
|
} |
|
} |
|
return true; |
|
} |
|
ts.isIdentifier = isIdentifier; |
|
// Creates a scanner over a (possibly unspecified) range of a piece of text. |
|
function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { |
|
if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } |
|
// Current position (end position of text of current token) |
|
var pos; |
|
// end of text |
|
var end; |
|
// Start position of whitespace before current token |
|
var startPos; |
|
// Start position of text of current token |
|
var tokenPos; |
|
var token; |
|
var tokenValue; |
|
var precedingLineBreak; |
|
var hasExtendedUnicodeEscape; |
|
var tokenIsUnterminated; |
|
setText(text, start, length); |
|
return { |
|
getStartPos: function () { return startPos; }, |
|
getTextPos: function () { return pos; }, |
|
getToken: function () { return token; }, |
|
getTokenPos: function () { return tokenPos; }, |
|
getTokenText: function () { return text.substring(tokenPos, pos); }, |
|
getTokenValue: function () { return tokenValue; }, |
|
hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, |
|
hasPrecedingLineBreak: function () { return precedingLineBreak; }, |
|
isIdentifier: function () { return token === 69 /* Identifier */ || token > 105 /* LastReservedWord */; }, |
|
isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, |
|
isUnterminated: function () { return tokenIsUnterminated; }, |
|
reScanGreaterToken: reScanGreaterToken, |
|
reScanSlashToken: reScanSlashToken, |
|
reScanTemplateToken: reScanTemplateToken, |
|
scanJsxIdentifier: scanJsxIdentifier, |
|
reScanJsxToken: reScanJsxToken, |
|
scanJsxToken: scanJsxToken, |
|
scanJSDocToken: scanJSDocToken, |
|
scan: scan, |
|
setText: setText, |
|
setScriptTarget: setScriptTarget, |
|
setLanguageVariant: setLanguageVariant, |
|
setOnError: setOnError, |
|
setTextPos: setTextPos, |
|
tryScan: tryScan, |
|
lookAhead: lookAhead, |
|
scanRange: scanRange |
|
}; |
|
function error(message, length) { |
|
if (onError) { |
|
onError(message, length || 0); |
|
} |
|
} |
|
function scanNumber() { |
|
var start = pos; |
|
while (isDigit(text.charCodeAt(pos))) |
|
pos++; |
|
if (text.charCodeAt(pos) === 46 /* dot */) { |
|
pos++; |
|
while (isDigit(text.charCodeAt(pos))) |
|
pos++; |
|
} |
|
var end = pos; |
|
if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { |
|
pos++; |
|
if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) |
|
pos++; |
|
if (isDigit(text.charCodeAt(pos))) { |
|
pos++; |
|
while (isDigit(text.charCodeAt(pos))) |
|
pos++; |
|
end = pos; |
|
} |
|
else { |
|
error(ts.Diagnostics.Digit_expected); |
|
} |
|
} |
|
return "" + +(text.substring(start, end)); |
|
} |
|
function scanOctalDigits() { |
|
var start = pos; |
|
while (isOctalDigit(text.charCodeAt(pos))) { |
|
pos++; |
|
} |
|
return +(text.substring(start, pos)); |
|
} |
|
/** |
|
* Scans the given number of hexadecimal digits in the text, |
|
* returning -1 if the given number is unavailable. |
|
*/ |
|
function scanExactNumberOfHexDigits(count) { |
|
return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); |
|
} |
|
/** |
|
* Scans as many hexadecimal digits as are available in the text, |
|
* returning -1 if the given number of digits was unavailable. |
|
*/ |
|
function scanMinimumNumberOfHexDigits(count) { |
|
return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true); |
|
} |
|
function scanHexDigits(minCount, scanAsManyAsPossible) { |
|
var digits = 0; |
|
var value = 0; |
|
while (digits < minCount || scanAsManyAsPossible) { |
|
var ch = text.charCodeAt(pos); |
|
if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { |
|
value = value * 16 + ch - 48 /* _0 */; |
|
} |
|
else if (ch >= 65 /* A */ && ch <= 70 /* F */) { |
|
value = value * 16 + ch - 65 /* A */ + 10; |
|
} |
|
else if (ch >= 97 /* a */ && ch <= 102 /* f */) { |
|
value = value * 16 + ch - 97 /* a */ + 10; |
|
} |
|
else { |
|
break; |
|
} |
|
pos++; |
|
digits++; |
|
} |
|
if (digits < minCount) { |
|
value = -1; |
|
} |
|
return value; |
|
} |
|
function scanString() { |
|
var quote = text.charCodeAt(pos); |
|
pos++; |
|
var result = ""; |
|
var start = pos; |
|
while (true) { |
|
if (pos >= end) { |
|
result += text.substring(start, pos); |
|
tokenIsUnterminated = true; |
|
error(ts.Diagnostics.Unterminated_string_literal); |
|
break; |
|
} |
|
var ch = text.charCodeAt(pos); |
|
if (ch === quote) { |
|
result += text.substring(start, pos); |
|
pos++; |
|
break; |
|
} |
|
if (ch === 92 /* backslash */) { |
|
result += text.substring(start, pos); |
|
result += scanEscapeSequence(); |
|
start = pos; |
|
continue; |
|
} |
|
if (isLineBreak(ch)) { |
|
result += text.substring(start, pos); |
|
tokenIsUnterminated = true; |
|
error(ts.Diagnostics.Unterminated_string_literal); |
|
break; |
|
} |
|
pos++; |
|
} |
|
return result; |
|
} |
|
/** |
|
* Sets the current 'tokenValue' and returns a NoSubstitutionTemplateLiteral or |
|
* a literal component of a TemplateExpression. |
|
*/ |
|
function scanTemplateAndSetTokenValue() { |
|
var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; |
|
pos++; |
|
var start = pos; |
|
var contents = ""; |
|
var resultingToken; |
|
while (true) { |
|
if (pos >= end) { |
|
contents += text.substring(start, pos); |
|
tokenIsUnterminated = true; |
|
error(ts.Diagnostics.Unterminated_template_literal); |
|
resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; |
|
break; |
|
} |
|
var currChar = text.charCodeAt(pos); |
|
// '`' |
|
if (currChar === 96 /* backtick */) { |
|
contents += text.substring(start, pos); |
|
pos++; |
|
resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; |
|
break; |
|
} |
|
// '${' |
|
if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { |
|
contents += text.substring(start, pos); |
|
pos += 2; |
|
resultingToken = startedWithBacktick ? 12 /* TemplateHead */ : 13 /* TemplateMiddle */; |
|
break; |
|
} |
|
// Escape character |
|
if (currChar === 92 /* backslash */) { |
|
contents += text.substring(start, pos); |
|
contents += scanEscapeSequence(); |
|
start = pos; |
|
continue; |
|
} |
|
// Speculated ECMAScript 6 Spec 11.8.6.1: |
|
// <CR><LF> and <CR> LineTerminatorSequences are normalized to <LF> for Template Values |
|
if (currChar === 13 /* carriageReturn */) { |
|
contents += text.substring(start, pos); |
|
pos++; |
|
if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { |
|
pos++; |
|
} |
|
contents += "\n"; |
|
start = pos; |
|
continue; |
|
} |
|
pos++; |
|
} |
|
ts.Debug.assert(resultingToken !== undefined); |
|
tokenValue = contents; |
|
return resultingToken; |
|
} |
|
function scanEscapeSequence() { |
|
pos++; |
|
if (pos >= end) { |
|
error(ts.Diagnostics.Unexpected_end_of_text); |
|
return ""; |
|
} |
|
var ch = text.charCodeAt(pos); |
|
pos++; |
|
switch (ch) { |
|
case 48 /* _0 */: |
|
return "\0"; |
|
case 98 /* b */: |
|
return "\b"; |
|
case 116 /* t */: |
|
return "\t"; |
|
case 110 /* n */: |
|
return "\n"; |
|
case 118 /* v */: |
|
return "\v"; |
|
case 102 /* f */: |
|
return "\f"; |
|
case 114 /* r */: |
|
return "\r"; |
|
case 39 /* singleQuote */: |
|
return "\'"; |
|
case 34 /* doubleQuote */: |
|
return "\""; |
|
case 117 /* u */: |
|
// '\u{DDDDDDDD}' |
|
if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { |
|
hasExtendedUnicodeEscape = true; |
|
pos++; |
|
return scanExtendedUnicodeEscape(); |
|
} |
|
// '\uDDDD' |
|
return scanHexadecimalEscape(/*numDigits*/ 4); |
|
case 120 /* x */: |
|
// '\xDD' |
|
return scanHexadecimalEscape(/*numDigits*/ 2); |
|
// when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), |
|
// the line terminator is interpreted to be "the empty code unit sequence". |
|
case 13 /* carriageReturn */: |
|
if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { |
|
pos++; |
|
} |
|
// fall through |
|
case 10 /* lineFeed */: |
|
case 8232 /* lineSeparator */: |
|
case 8233 /* paragraphSeparator */: |
|
return ""; |
|
default: |
|
return String.fromCharCode(ch); |
|
} |
|
} |
|
function scanHexadecimalEscape(numDigits) { |
|
var escapedValue = scanExactNumberOfHexDigits(numDigits); |
|
if (escapedValue >= 0) { |
|
return String.fromCharCode(escapedValue); |
|
} |
|
else { |
|
error(ts.Diagnostics.Hexadecimal_digit_expected); |
|
return ""; |
|
} |
|
} |
|
function scanExtendedUnicodeEscape() { |
|
var escapedValue = scanMinimumNumberOfHexDigits(1); |
|
var isInvalidExtendedEscape = false; |
|
// Validate the value of the digit |
|
if (escapedValue < 0) { |
|
error(ts.Diagnostics.Hexadecimal_digit_expected); |
|
isInvalidExtendedEscape = true; |
|
} |
|
else if (escapedValue > 0x10FFFF) { |
|
error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive); |
|
isInvalidExtendedEscape = true; |
|
} |
|
if (pos >= end) { |
|
error(ts.Diagnostics.Unexpected_end_of_text); |
|
isInvalidExtendedEscape = true; |
|
} |
|
else if (text.charCodeAt(pos) === 125 /* closeBrace */) { |
|
// Only swallow the following character up if it's a '}'. |
|
pos++; |
|
} |
|
else { |
|
error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); |
|
isInvalidExtendedEscape = true; |
|
} |
|
if (isInvalidExtendedEscape) { |
|
return ""; |
|
} |
|
return utf16EncodeAsString(escapedValue); |
|
} |
|
// Derived from the 10.1.1 UTF16Encoding of the ES6 Spec. |
|
function utf16EncodeAsString(codePoint) { |
|
ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF); |
|
if (codePoint <= 65535) { |
|
return String.fromCharCode(codePoint); |
|
} |
|
var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; |
|
var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; |
|
return String.fromCharCode(codeUnit1, codeUnit2); |
|
} |
|
// Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' |
|
// and return code point value if valid Unicode escape is found. Otherwise return -1. |
|
function peekUnicodeEscape() { |
|
if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { |
|
var start_1 = pos; |
|
pos += 2; |
|
var value = scanExactNumberOfHexDigits(4); |
|
pos = start_1; |
|
return value; |
|
} |
|
return -1; |
|
} |
|
function scanIdentifierParts() { |
|
var result = ""; |
|
var start = pos; |
|
while (pos < end) { |
|
var ch = text.charCodeAt(pos); |
|
if (isIdentifierPart(ch, languageVersion)) { |
|
pos++; |
|
} |
|
else if (ch === 92 /* backslash */) { |
|
ch = peekUnicodeEscape(); |
|
if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { |
|
break; |
|
} |
|
result += text.substring(start, pos); |
|
result += String.fromCharCode(ch); |
|
// Valid Unicode escape is always six characters |
|
pos += 6; |
|
start = pos; |
|
} |
|
else { |
|
break; |
|
} |
|
} |
|
result += text.substring(start, pos); |
|
return result; |
|
} |
|
function getIdentifierToken() { |
|
// Reserved words are between 2 and 11 characters long and start with a lowercase letter |
|
var len = tokenValue.length; |
|
if (len >= 2 && len <= 11) { |
|
var ch = tokenValue.charCodeAt(0); |
|
if (ch >= 97 /* a */ && ch <= 122 /* z */ && hasOwnProperty.call(textToToken, tokenValue)) { |
|
return token = textToToken[tokenValue]; |
|
} |
|
} |
|
return token = 69 /* Identifier */; |
|
} |
|
function scanBinaryOrOctalDigits(base) { |
|
ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); |
|
var value = 0; |
|
// For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b. |
|
// Similarly valid octalIntegerLiteral must have at least one octal digit following o or O. |
|
var numberOfDigits = 0; |
|
while (true) { |
|
var ch = text.charCodeAt(pos); |
|
var valueOfCh = ch - 48 /* _0 */; |
|
if (!isDigit(ch) || valueOfCh >= base) { |
|
break; |
|
} |
|
value = value * base + valueOfCh; |
|
pos++; |
|
numberOfDigits++; |
|
} |
|
// Invalid binaryIntegerLiteral or octalIntegerLiteral |
|
if (numberOfDigits === 0) { |
|
return -1; |
|
} |
|
return value; |
|
} |
|
function scan() { |
|
startPos = pos; |
|
hasExtendedUnicodeEscape = false; |
|
precedingLineBreak = false; |
|
tokenIsUnterminated = false; |
|
while (true) { |
|
tokenPos = pos; |
|
if (pos >= end) { |
|
return token = 1 /* EndOfFileToken */; |
|
} |
|
var ch = text.charCodeAt(pos); |
|
// Special handling for shebang |
|
if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { |
|
pos = scanShebangTrivia(text, pos); |
|
if (skipTrivia) { |
|
continue; |
|
} |
|
else { |
|
return token = 6 /* ShebangTrivia */; |
|
} |
|
} |
|
switch (ch) { |
|
case 10 /* lineFeed */: |
|
case 13 /* carriageReturn */: |
|
precedingLineBreak = true; |
|
if (skipTrivia) { |
|
pos++; |
|
continue; |
|
} |
|
else { |
|
if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { |
|
// consume both CR and LF |
|
pos += 2; |
|
} |
|
else { |
|
pos++; |
|
} |
|
return token = 4 /* NewLineTrivia */; |
|
} |
|
case 9 /* tab */: |
|
case 11 /* verticalTab */: |
|
case 12 /* formFeed */: |
|
case 32 /* space */: |
|
if (skipTrivia) { |
|
pos++; |
|
continue; |
|
} |
|
else { |
|
while (pos < end && isWhiteSpace(text.charCodeAt(pos))) { |
|
pos++; |
|
} |
|
return token = 5 /* WhitespaceTrivia */; |
|
} |
|
case 33 /* exclamation */: |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
if (text.charCodeAt(pos + 2) === 61 /* equals */) { |
|
return pos += 3, token = 33 /* ExclamationEqualsEqualsToken */; |
|
} |
|
return pos += 2, token = 31 /* ExclamationEqualsToken */; |
|
} |
|
pos++; |
|
return token = 49 /* ExclamationToken */; |
|
case 34 /* doubleQuote */: |
|
case 39 /* singleQuote */: |
|
tokenValue = scanString(); |
|
return token = 9 /* StringLiteral */; |
|
case 96 /* backtick */: |
|
return token = scanTemplateAndSetTokenValue(); |
|
case 37 /* percent */: |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
return pos += 2, token = 62 /* PercentEqualsToken */; |
|
} |
|
pos++; |
|
return token = 40 /* PercentToken */; |
|
case 38 /* ampersand */: |
|
if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { |
|
return pos += 2, token = 51 /* AmpersandAmpersandToken */; |
|
} |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
return pos += 2, token = 66 /* AmpersandEqualsToken */; |
|
} |
|
pos++; |
|
return token = 46 /* AmpersandToken */; |
|
case 40 /* openParen */: |
|
pos++; |
|
return token = 17 /* OpenParenToken */; |
|
case 41 /* closeParen */: |
|
pos++; |
|
return token = 18 /* CloseParenToken */; |
|
case 42 /* asterisk */: |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
return pos += 2, token = 59 /* AsteriskEqualsToken */; |
|
} |
|
if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { |
|
if (text.charCodeAt(pos + 2) === 61 /* equals */) { |
|
return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; |
|
} |
|
return pos += 2, token = 38 /* AsteriskAsteriskToken */; |
|
} |
|
pos++; |
|
return token = 37 /* AsteriskToken */; |
|
case 43 /* plus */: |
|
if (text.charCodeAt(pos + 1) === 43 /* plus */) { |
|
return pos += 2, token = 41 /* PlusPlusToken */; |
|
} |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
return pos += 2, token = 57 /* PlusEqualsToken */; |
|
} |
|
pos++; |
|
return token = 35 /* PlusToken */; |
|
case 44 /* comma */: |
|
pos++; |
|
return token = 24 /* CommaToken */; |
|
case 45 /* minus */: |
|
if (text.charCodeAt(pos + 1) === 45 /* minus */) { |
|
return pos += 2, token = 42 /* MinusMinusToken */; |
|
} |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
return pos += 2, token = 58 /* MinusEqualsToken */; |
|
} |
|
pos++; |
|
return token = 36 /* MinusToken */; |
|
case 46 /* dot */: |
|
if (isDigit(text.charCodeAt(pos + 1))) { |
|
tokenValue = scanNumber(); |
|
return token = 8 /* NumericLiteral */; |
|
} |
|
if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { |
|
return pos += 3, token = 22 /* DotDotDotToken */; |
|
} |
|
pos++; |
|
return token = 21 /* DotToken */; |
|
case 47 /* slash */: |
|
// Single-line comment |
|
if (text.charCodeAt(pos + 1) === 47 /* slash */) { |
|
pos += 2; |
|
while (pos < end) { |
|
if (isLineBreak(text.charCodeAt(pos))) { |
|
break; |
|
} |
|
pos++; |
|
} |
|
if (skipTrivia) { |
|
continue; |
|
} |
|
else { |
|
return token = 2 /* SingleLineCommentTrivia */; |
|
} |
|
} |
|
// Multi-line comment |
|
if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { |
|
pos += 2; |
|
var commentClosed = false; |
|
while (pos < end) { |
|
var ch_2 = text.charCodeAt(pos); |
|
if (ch_2 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { |
|
pos += 2; |
|
commentClosed = true; |
|
break; |
|
} |
|
if (isLineBreak(ch_2)) { |
|
precedingLineBreak = true; |
|
} |
|
pos++; |
|
} |
|
if (!commentClosed) { |
|
error(ts.Diagnostics.Asterisk_Slash_expected); |
|
} |
|
if (skipTrivia) { |
|
continue; |
|
} |
|
else { |
|
tokenIsUnterminated = !commentClosed; |
|
return token = 3 /* MultiLineCommentTrivia */; |
|
} |
|
} |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
return pos += 2, token = 61 /* SlashEqualsToken */; |
|
} |
|
pos++; |
|
return token = 39 /* SlashToken */; |
|
case 48 /* _0 */: |
|
if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { |
|
pos += 2; |
|
var value = scanMinimumNumberOfHexDigits(1); |
|
if (value < 0) { |
|
error(ts.Diagnostics.Hexadecimal_digit_expected); |
|
value = 0; |
|
} |
|
tokenValue = "" + value; |
|
return token = 8 /* NumericLiteral */; |
|
} |
|
else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { |
|
pos += 2; |
|
var value = scanBinaryOrOctalDigits(/* base */ 2); |
|
if (value < 0) { |
|
error(ts.Diagnostics.Binary_digit_expected); |
|
value = 0; |
|
} |
|
tokenValue = "" + value; |
|
return token = 8 /* NumericLiteral */; |
|
} |
|
else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { |
|
pos += 2; |
|
var value = scanBinaryOrOctalDigits(/* base */ 8); |
|
if (value < 0) { |
|
error(ts.Diagnostics.Octal_digit_expected); |
|
value = 0; |
|
} |
|
tokenValue = "" + value; |
|
return token = 8 /* NumericLiteral */; |
|
} |
|
// Try to parse as an octal |
|
if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { |
|
tokenValue = "" + scanOctalDigits(); |
|
return token = 8 /* NumericLiteral */; |
|
} |
|
// This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero |
|
// can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being |
|
// permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). |
|
case 49 /* _1 */: |
|
case 50 /* _2 */: |
|
case 51 /* _3 */: |
|
case 52 /* _4 */: |
|
case 53 /* _5 */: |
|
case 54 /* _6 */: |
|
case 55 /* _7 */: |
|
case 56 /* _8 */: |
|
case 57 /* _9 */: |
|
tokenValue = scanNumber(); |
|
return token = 8 /* NumericLiteral */; |
|
case 58 /* colon */: |
|
pos++; |
|
return token = 54 /* ColonToken */; |
|
case 59 /* semicolon */: |
|
pos++; |
|
return token = 23 /* SemicolonToken */; |
|
case 60 /* lessThan */: |
|
if (isConflictMarkerTrivia(text, pos)) { |
|
pos = scanConflictMarkerTrivia(text, pos, error); |
|
if (skipTrivia) { |
|
continue; |
|
} |
|
else { |
|
return token = 7 /* ConflictMarkerTrivia */; |
|
} |
|
} |
|
if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { |
|
if (text.charCodeAt(pos + 2) === 61 /* equals */) { |
|
return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; |
|
} |
|
return pos += 2, token = 43 /* LessThanLessThanToken */; |
|
} |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
return pos += 2, token = 28 /* LessThanEqualsToken */; |
|
} |
|
if (languageVariant === 1 /* JSX */ && |
|
text.charCodeAt(pos + 1) === 47 /* slash */ && |
|
text.charCodeAt(pos + 2) !== 42 /* asterisk */) { |
|
return pos += 2, token = 26 /* LessThanSlashToken */; |
|
} |
|
pos++; |
|
return token = 25 /* LessThanToken */; |
|
case 61 /* equals */: |
|
if (isConflictMarkerTrivia(text, pos)) { |
|
pos = scanConflictMarkerTrivia(text, pos, error); |
|
if (skipTrivia) { |
|
continue; |
|
} |
|
else { |
|
return token = 7 /* ConflictMarkerTrivia */; |
|
} |
|
} |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
if (text.charCodeAt(pos + 2) === 61 /* equals */) { |
|
return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; |
|
} |
|
return pos += 2, token = 30 /* EqualsEqualsToken */; |
|
} |
|
if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { |
|
return pos += 2, token = 34 /* EqualsGreaterThanToken */; |
|
} |
|
pos++; |
|
return token = 56 /* EqualsToken */; |
|
case 62 /* greaterThan */: |
|
if (isConflictMarkerTrivia(text, pos)) { |
|
pos = scanConflictMarkerTrivia(text, pos, error); |
|
if (skipTrivia) { |
|
continue; |
|
} |
|
else { |
|
return token = 7 /* ConflictMarkerTrivia */; |
|
} |
|
} |
|
pos++; |
|
return token = 27 /* GreaterThanToken */; |
|
case 63 /* question */: |
|
pos++; |
|
return token = 53 /* QuestionToken */; |
|
case 91 /* openBracket */: |
|
pos++; |
|
return token = 19 /* OpenBracketToken */; |
|
case 93 /* closeBracket */: |
|
pos++; |
|
return token = 20 /* CloseBracketToken */; |
|
case 94 /* caret */: |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
return pos += 2, token = 68 /* CaretEqualsToken */; |
|
} |
|
pos++; |
|
return token = 48 /* CaretToken */; |
|
case 123 /* openBrace */: |
|
pos++; |
|
return token = 15 /* OpenBraceToken */; |
|
case 124 /* bar */: |
|
if (text.charCodeAt(pos + 1) === 124 /* bar */) { |
|
return pos += 2, token = 52 /* BarBarToken */; |
|
} |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
return pos += 2, token = 67 /* BarEqualsToken */; |
|
} |
|
pos++; |
|
return token = 47 /* BarToken */; |
|
case 125 /* closeBrace */: |
|
pos++; |
|
return token = 16 /* CloseBraceToken */; |
|
case 126 /* tilde */: |
|
pos++; |
|
return token = 50 /* TildeToken */; |
|
case 64 /* at */: |
|
pos++; |
|
return token = 55 /* AtToken */; |
|
case 92 /* backslash */: |
|
var cookedChar = peekUnicodeEscape(); |
|
if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { |
|
pos += 6; |
|
tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); |
|
return token = getIdentifierToken(); |
|
} |
|
error(ts.Diagnostics.Invalid_character); |
|
pos++; |
|
return token = 0 /* Unknown */; |
|
default: |
|
if (isIdentifierStart(ch, languageVersion)) { |
|
pos++; |
|
while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) |
|
pos++; |
|
tokenValue = text.substring(tokenPos, pos); |
|
if (ch === 92 /* backslash */) { |
|
tokenValue += scanIdentifierParts(); |
|
} |
|
return token = getIdentifierToken(); |
|
} |
|
else if (isWhiteSpace(ch)) { |
|
pos++; |
|
continue; |
|
} |
|
else if (isLineBreak(ch)) { |
|
precedingLineBreak = true; |
|
pos++; |
|
continue; |
|
} |
|
error(ts.Diagnostics.Invalid_character); |
|
pos++; |
|
return token = 0 /* Unknown */; |
|
} |
|
} |
|
} |
|
function reScanGreaterToken() { |
|
if (token === 27 /* GreaterThanToken */) { |
|
if (text.charCodeAt(pos) === 62 /* greaterThan */) { |
|
if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { |
|
if (text.charCodeAt(pos + 2) === 61 /* equals */) { |
|
return pos += 3, token = 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */; |
|
} |
|
return pos += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; |
|
} |
|
if (text.charCodeAt(pos + 1) === 61 /* equals */) { |
|
return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; |
|
} |
|
pos++; |
|
return token = 44 /* GreaterThanGreaterThanToken */; |
|
} |
|
if (text.charCodeAt(pos) === 61 /* equals */) { |
|
pos++; |
|
return token = 29 /* GreaterThanEqualsToken */; |
|
} |
|
} |
|
return token; |
|
} |
|
function reScanSlashToken() { |
|
if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { |
|
var p = tokenPos + 1; |
|
var inEscape = false; |
|
var inCharacterClass = false; |
|
while (true) { |
|
// If we reach the end of a file, or hit a newline, then this is an unterminated |
|
// regex. Report error and return what we have so far. |
|
if (p >= end) { |
|
tokenIsUnterminated = true; |
|
error(ts.Diagnostics.Unterminated_regular_expression_literal); |
|
break; |
|
} |
|
var ch = text.charCodeAt(p); |
|
if (isLineBreak(ch)) { |
|
tokenIsUnterminated = true; |
|
error(ts.Diagnostics.Unterminated_regular_expression_literal); |
|
break; |
|
} |
|
if (inEscape) { |
|
// Parsing an escape character; |
|
// reset the flag and just advance to the next char. |
|
inEscape = false; |
|
} |
|
else if (ch === 47 /* slash */ && !inCharacterClass) { |
|
// A slash within a character class is permissible, |
|
// but in general it signals the end of the regexp literal. |
|
p++; |
|
break; |
|
} |
|
else if (ch === 91 /* openBracket */) { |
|
inCharacterClass = true; |
|
} |
|
else if (ch === 92 /* backslash */) { |
|
inEscape = true; |
|
} |
|
else if (ch === 93 /* closeBracket */) { |
|
inCharacterClass = false; |
|
} |
|
p++; |
|
} |
|
while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { |
|
p++; |
|
} |
|
pos = p; |
|
tokenValue = text.substring(tokenPos, pos); |
|
token = 10 /* RegularExpressionLiteral */; |
|
} |
|
return token; |
|
} |
|
/** |
|
* Unconditionally back up and scan a template expression portion. |
|
*/ |
|
function reScanTemplateToken() { |
|
ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); |
|
pos = tokenPos; |
|
return token = scanTemplateAndSetTokenValue(); |
|
} |
|
function reScanJsxToken() { |
|
pos = tokenPos = startPos; |
|
return token = scanJsxToken(); |
|
} |
|
function scanJsxToken() { |
|
startPos = tokenPos = pos; |
|
if (pos >= end) { |
|
return token = 1 /* EndOfFileToken */; |
|
} |
|
var char = text.charCodeAt(pos); |
|
if (char === 60 /* lessThan */) { |
|
if (text.charCodeAt(pos + 1) === 47 /* slash */) { |
|
pos += 2; |
|
return token = 26 /* LessThanSlashToken */; |
|
} |
|
pos++; |
|
return token = 25 /* LessThanToken */; |
|
} |
|
if (char === 123 /* openBrace */) { |
|
pos++; |
|
return token = 15 /* OpenBraceToken */; |
|
} |
|
while (pos < end) { |
|
pos++; |
|
char = text.charCodeAt(pos); |
|
if ((char === 123 /* openBrace */) || (char === 60 /* lessThan */)) { |
|
break; |
|
} |
|
} |
|
return token = 239 /* JsxText */; |
|
} |
|
// Scans a JSX identifier; these differ from normal identifiers in that |
|
// they allow dashes |
|
function scanJsxIdentifier() { |
|
if (tokenIsIdentifierOrKeyword(token)) { |
|
var firstCharPosition = pos; |
|
while (pos < end) { |
|
var ch = text.charCodeAt(pos); |
|
if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { |
|
pos++; |
|
} |
|
else { |
|
break; |
|
} |
|
} |
|
tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); |
|
} |
|
return token; |
|
} |
|
function scanJSDocToken() { |
|
if (pos >= end) { |
|
return token = 1 /* EndOfFileToken */; |
|
} |
|
startPos = pos; |
|
// Eat leading whitespace |
|
var ch = text.charCodeAt(pos); |
|
while (pos < end) { |
|
ch = text.charCodeAt(pos); |
|
if (isWhiteSpace(ch)) { |
|
pos++; |
|
} |
|
else { |
|
break; |
|
} |
|
} |
|
tokenPos = pos; |
|
switch (ch) { |
|
case 64 /* at */: |
|
return pos += 1, token = 55 /* AtToken */; |
|
case 10 /* lineFeed */: |
|
case 13 /* carriageReturn */: |
|
return pos += 1, token = 4 /* NewLineTrivia */; |
|
case 42 /* asterisk */: |
|
return pos += 1, token = 37 /* AsteriskToken */; |
|
case 123 /* openBrace */: |
|
return pos += 1, token = 15 /* OpenBraceToken */; |
|
case 125 /* closeBrace */: |
|
return pos += 1, token = 16 /* CloseBraceToken */; |
|
case 91 /* openBracket */: |
|
return pos += 1, token = 19 /* OpenBracketToken */; |
|
case 93 /* closeBracket */: |
|
return pos += 1, token = 20 /* CloseBracketToken */; |
|
case 61 /* equals */: |
|
return pos += 1, token = 56 /* EqualsToken */; |
|
case 44 /* comma */: |
|
return pos += 1, token = 24 /* CommaToken */; |
|
} |
|
if (isIdentifierStart(ch, 2 /* Latest */)) { |
|
pos++; |
|
while (isIdentifierPart(text.charCodeAt(pos), 2 /* Latest */) && pos < end) { |
|
pos++; |
|
} |
|
return token = 69 /* Identifier */; |
|
} |
|
else { |
|
return pos += 1, token = 0 /* Unknown */; |
|
} |
|
} |
|
function speculationHelper(callback, isLookahead) { |
|
var savePos = pos; |
|
var saveStartPos = startPos; |
|
var saveTokenPos = tokenPos; |
|
var saveToken = token; |
|
var saveTokenValue = tokenValue; |
|
var savePrecedingLineBreak = precedingLineBreak; |
|
var result = callback(); |
|
// If our callback returned something 'falsy' or we're just looking ahead, |
|
// then unconditionally restore us to where we were. |
|
if (!result || isLookahead) { |
|
pos = savePos; |
|
startPos = saveStartPos; |
|
tokenPos = saveTokenPos; |
|
token = saveToken; |
|
tokenValue = saveTokenValue; |
|
precedingLineBreak = savePrecedingLineBreak; |
|
} |
|
return result; |
|
} |
|
function scanRange(start, length, callback) { |
|
var saveEnd = end; |
|
var savePos = pos; |
|
var saveStartPos = startPos; |
|
var saveTokenPos = tokenPos; |
|
var saveToken = token; |
|
var savePrecedingLineBreak = precedingLineBreak; |
|
var saveTokenValue = tokenValue; |
|
var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; |
|
var saveTokenIsUnterminated = tokenIsUnterminated; |
|
setText(text, start, length); |
|
var result = callback(); |
|
end = saveEnd; |
|
pos = savePos; |
|
startPos = saveStartPos; |
|
tokenPos = saveTokenPos; |
|
token = saveToken; |
|
precedingLineBreak = savePrecedingLineBreak; |
|
tokenValue = saveTokenValue; |
|
hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; |
|
tokenIsUnterminated = saveTokenIsUnterminated; |
|
return result; |
|
} |
|
function lookAhead(callback) { |
|
return speculationHelper(callback, /*isLookahead*/ true); |
|
} |
|
function tryScan(callback) { |
|
return speculationHelper(callback, /*isLookahead*/ false); |
|
} |
|
function setText(newText, start, length) { |
|
text = newText || ""; |
|
end = length === undefined ? text.length : start + length; |
|
setTextPos(start || 0); |
|
} |
|
function setOnError(errorCallback) { |
|
onError = errorCallback; |
|
} |
|
function setScriptTarget(scriptTarget) { |
|
languageVersion = scriptTarget; |
|
} |
|
function setLanguageVariant(variant) { |
|
languageVariant = variant; |
|
} |
|
function setTextPos(textPos) { |
|
ts.Debug.assert(textPos >= 0); |
|
pos = textPos; |
|
startPos = textPos; |
|
tokenPos = textPos; |
|
token = 0 /* Unknown */; |
|
precedingLineBreak = false; |
|
tokenValue = undefined; |
|
hasExtendedUnicodeEscape = false; |
|
tokenIsUnterminated = false; |
|
} |
|
} |
|
ts.createScanner = createScanner; |
|
})(ts || (ts = {})); |
|
/// <reference path="sys.ts" /> |
|
/* @internal */ |
|
var ts; |
|
(function (ts) { |
|
function getDeclarationOfKind(symbol, kind) { |
|
var declarations = symbol.declarations; |
|
if (declarations) { |
|
for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { |
|
var declaration = declarations_1[_i]; |
|
if (declaration.kind === kind) { |
|
return declaration; |
|
} |
|
} |
|
} |
|
return undefined; |
|
} |
|
ts.getDeclarationOfKind = getDeclarationOfKind; |
|
// Pool writers to avoid needing to allocate them for every symbol we write. |
|
var stringWriters = []; |
|
function getSingleLineStringWriter() { |
|
if (stringWriters.length === 0) { |
|
var str_1 = ""; |
|
var writeText = function (text) { return str_1 += text; }; |
|
return { |
|
string: function () { return str_1; }, |
|
writeKeyword: writeText, |
|
writeOperator: writeText, |
|
writePunctuation: writeText, |
|
writeSpace: writeText, |
|
writeStringLiteral: writeText, |
|
writeParameter: writeText, |
|
writeSymbol: writeText, |
|
// Completely ignore indentation for string writers. And map newlines to |
|
// a single space. |
|
writeLine: function () { return str_1 += " "; }, |
|
increaseIndent: function () { }, |
|
decreaseIndent: function () { }, |
|
clear: function () { return str_1 = ""; }, |
|
trackSymbol: function () { }, |
|
reportInaccessibleThisError: function () { } |
|
}; |
|
} |
|
return stringWriters.pop(); |
|
} |
|
ts.getSingleLineStringWriter = getSingleLineStringWriter; |
|
function releaseStringWriter(writer) { |
|
writer.clear(); |
|
stringWriters.push(writer); |
|
} |
|
ts.releaseStringWriter = releaseStringWriter; |
|
function getFullWidth(node) { |
|
return node.end - node.pos; |
|
} |
|
ts.getFullWidth = getFullWidth; |
|
function arrayIsEqualTo(array1, array2, equaler) { |
|
if (!array1 || !array2) { |
|
return array1 === array2; |
|
} |
|
if (array1.length !== array2.length) { |
|
return false; |
|
} |
|
for (var i = 0; i < array1.length; i++) { |
|
var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; |
|
if (!equals) { |
|
return false; |
|
} |
|
} |
|
return true; |
|
} |
|
ts.arrayIsEqualTo = arrayIsEqualTo; |
|
function hasResolvedModule(sourceFile, moduleNameText) { |
|
return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); |
|
} |
|
ts.hasResolvedModule = hasResolvedModule; |
|
function getResolvedModule(sourceFile, moduleNameText) { |
|
return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; |
|
} |
|
ts.getResolvedModule = getResolvedModule; |
|
function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { |
|
if (!sourceFile.resolvedModules) { |
|
sourceFile.resolvedModules = {}; |
|
} |
|
sourceFile.resolvedModules[moduleNameText] = resolvedModule; |
|
} |
|
ts.setResolvedModule = setResolvedModule; |
|
// Returns true if this node contains a parse error anywhere underneath it. |
|
function containsParseError(node) { |
|
aggregateChildData(node); |
|
return (node.parserContextFlags & 64 /* ThisNodeOrAnySubNodesHasError */) !== 0; |
|
} |
|
ts.containsParseError = containsParseError; |
|
function aggregateChildData(node) { |
|
if (!(node.parserContextFlags & 128 /* HasAggregatedChildData */)) { |
|
// A node is considered to contain a parse error if: |
|
// a) the parser explicitly marked that it had an error |
|
// b) any of it's children reported that it had an error. |
|
var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16 /* ThisNodeHasError */) !== 0) || |
|
ts.forEachChild(node, containsParseError); |
|
// If so, mark ourselves accordingly. |
|
if (thisNodeOrAnySubNodesHasError) { |
|
node.parserContextFlags |= 64 /* ThisNodeOrAnySubNodesHasError */; |
|
} |
|
// Also mark that we've propogated the child information to this node. This way we can |
|
// always consult the bit directly on this node without needing to check its children |
|
// again. |
|
node.parserContextFlags |= 128 /* HasAggregatedChildData */; |
|
} |
|
} |
|
function getSourceFileOfNode(node) { |
|
while (node && node.kind !== 251 /* SourceFile */) { |
|
node = node.parent; |
|
} |
|
return node; |
|
} |
|
ts.getSourceFileOfNode = getSourceFileOfNode; |
|
function isStatementWithLocals(node) { |
|
switch (node.kind) { |
|
case 195 /* Block */: |
|
case 223 /* CaseBlock */: |
|
case 202 /* ForStatement */: |
|
case 203 /* ForInStatement */: |
|
case 204 /* ForOfStatement */: |
|
return true; |
|
} |
|
return false; |
|
} |
|
ts.isStatementWithLocals = isStatementWithLocals; |
|
function getStartPositionOfLine(line, sourceFile) { |
|
ts.Debug.assert(line >= 0); |
|
return ts.getLineStarts(sourceFile)[line]; |
|
} |
|
ts.getStartPositionOfLine = getStartPositionOfLine; |
|
// This is a useful function for debugging purposes. |
|
function nodePosToString(node) { |
|
var file = getSourceFileOfNode(node); |
|
var loc = ts.getLineAndCharacterOfPosition(file, node.pos); |
|
return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; |
|
} |
|
ts.nodePosToString = nodePosToString; |
|
function getStartPosOfNode(node) { |
|
return node.pos; |
|
} |
|
ts.getStartPosOfNode = getStartPosOfNode; |
|
// Returns true if this node is missing from the actual source code. A 'missing' node is different |
|
// from 'undefined/defined'. When a node is undefined (which can happen for optional nodes |
|
// in the tree), it is definitely missing. However, a node may be defined, but still be |
|
// missing. This happens whenever the parser knows it needs to parse something, but can't |
|
// get anything in the source code that it expects at that location. For example: |
|
// |
|
// let a: ; |
|
// |
|
// Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source |
|
// code). So the parser will attempt to parse out a type, and will create an actual node. |
|
// However, this node will be 'missing' in the sense that no actual source-code/tokens are |
|
// contained within it. |
|
function nodeIsMissing(node) { |
|
if (!node) { |
|
return true; |
|
} |
|
return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; |
|
} |
|
ts.nodeIsMissing = nodeIsMissing; |
|
function nodeIsPresent(node) { |
|
return !nodeIsMissing(node); |
|
} |
|
ts.nodeIsPresent = nodeIsPresent; |
|
function getTokenPosOfNode(node, sourceFile) { |
|
// With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* |
|
// want to skip trivia because this will launch us forward to the next token. |
|
if (nodeIsMissing(node)) { |
|
return node.pos; |
|
} |
|
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); |
|
} |
|
ts.getTokenPosOfNode = getTokenPosOfNode; |
|
function getNonDecoratorTokenPosOfNode(node, sourceFile) { |
|
if (nodeIsMissing(node) || !node.decorators) { |
|
return getTokenPosOfNode(node, sourceFile); |
|
} |
|
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); |
|
} |
|
ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; |
|
function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { |
|
if (includeTrivia === void 0) { includeTrivia = false; } |
|
if (nodeIsMissing(node)) { |
|
return ""; |
|
} |
|
var text = sourceFile.text; |
|
return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); |
|
} |
|
ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; |
|
function getTextOfNodeFromSourceText(sourceText, node) { |
|
if (nodeIsMissing(node)) { |
|
return ""; |
|
} |
|
return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); |
|
} |
|
ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; |
|
function getTextOfNode(node, includeTrivia) { |
|
if (includeTrivia === void 0) { includeTrivia = false; } |
|
return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); |
|
} |
|
ts.getTextOfNode = getTextOfNode; |
|
// Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' |
|
function escapeIdentifier(identifier) { |
|
return identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier; |
|
} |
|
ts.escapeIdentifier = escapeIdentifier; |
|
// Remove extra underscore from escaped identifier |
|
function unescapeIdentifier(identifier) { |
|
return identifier.length >= 3 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ && identifier.charCodeAt(2) === 95 /* _ */ ? identifier.substr(1) : identifier; |
|
} |
|
ts.unescapeIdentifier = unescapeIdentifier; |
|
// Make an identifier from an external module name by extracting the string after the last "/" and replacing |
|
// all non-alphanumeric characters with underscores |
|
function makeIdentifierFromModuleName(moduleName) { |
|
return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); |
|
} |
|
ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; |
|
function isBlockOrCatchScoped(declaration) { |
|
return (getCombinedNodeFlags(declaration) & 24576 /* BlockScoped */) !== 0 || |
|
isCatchClauseVariableDeclaration(declaration); |
|
} |
|
ts.isBlockOrCatchScoped = isBlockOrCatchScoped; |
|
function isAmbientModule(node) { |
|
return node && node.kind === 221 /* ModuleDeclaration */ && |
|
(node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); |
|
} |
|
ts.isAmbientModule = isAmbientModule; |
|
function isBlockScopedContainerTopLevel(node) { |
|
return node.kind === 251 /* SourceFile */ || |
|
node.kind === 221 /* ModuleDeclaration */ || |
|
isFunctionLike(node) || |
|
isFunctionBlock(node); |
|
} |
|
ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; |
|
function isGlobalScopeAugmentation(module) { |
|
return !!(module.flags & 2097152 /* GlobalAugmentation */); |
|
} |
|
ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; |
|
function isExternalModuleAugmentation(node) { |
|
// external module augmentation is a ambient module declaration that is either: |
|
// - defined in the top level scope and source file is an external module |
|
// - defined inside ambient module declaration located in the top level scope and source file not an external module |
|
if (!node || !isAmbientModule(node)) { |
|
return false; |
|
} |
|
switch (node.parent.kind) { |
|
case 251 /* SourceFile */: |
|
return isExternalModule(node.parent); |
|
case 222 /* ModuleBlock */: |
|
return isAmbientModule(node.parent.parent) && !isExternalModule(node.parent.parent.parent); |
|
} |
|
return false; |
|
} |
|
ts.isExternalModuleAugmentation = isExternalModuleAugmentation; |
|
// Gets the nearest enclosing block scope container that has the provided node |
|
// as a descendant, that is not the provided node. |
|
function getEnclosingBlockScopeContainer(node) { |
|
var current = node.parent; |
|
while (current) { |
|
if (isFunctionLike(current)) { |
|
return current; |
|
} |
|
switch (current.kind) { |
|
case 251 /* SourceFile */: |
|
case 223 /* CaseBlock */: |
|
case 247 /* CatchClause */: |
|
case 221 /* ModuleDeclaration */: |
|
case 202 /* ForStatement */: |
|
case 203 /* ForInStatement */: |
|
case 204 /* ForOfStatement */: |
|
return current; |
|
case 195 /* Block */: |
|
// function block is not considered block-scope container |
|
// see comment in binder.ts: bind(...), case for SyntaxKind.Block |
|
if (!isFunctionLike(current.parent)) { |
|
return current; |
|
} |
|
} |
|
current = current.parent; |
|
} |
|
} |
|
ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; |
|
function isCatchClauseVariableDeclaration(declaration) { |
|
return declaration && |
|
declaration.kind === 214 /* VariableDeclaration */ && |
|
declaration.parent && |
|
declaration.parent.kind === 247 /* CatchClause */; |
|
} |
|
ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; |
|
// Return display name of an identifier |
|
// Computed property names will just be emitted as "[<expr>]", where <expr> is the source |
|
// text of the expression in the computed property. |
|
function declarationNameToString(name) { |
|
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); |
|
} |
|
ts.declarationNameToString = declarationNameToString; |
|
function createDiagnosticForNode(node, message, arg0, arg1, arg2) { |
|
var sourceFile = getSourceFileOfNode(node); |
|
var span = getErrorSpanForNode(sourceFile, node); |
|
return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); |
|
} |
|
ts.createDiagnosticForNode = createDiagnosticForNode; |
|
function createDiagnosticForNodeFromMessageChain(node, messageChain) { |
|
var sourceFile = getSourceFileOfNode(node); |
|
var span = getErrorSpanForNode(sourceFile, node); |
|
return { |
|
file: sourceFile, |
|
start: span.start, |
|
length: span.length, |
|
code: messageChain.code, |
|
category: messageChain.category, |
|
messageText: messageChain.next ? messageChain : messageChain.messageText |
|
}; |
|
} |
|
ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; |
|
function getSpanOfTokenAtPosition(sourceFile, pos) { |
|
var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); |
|
scanner.scan(); |
|
var start = scanner.getTokenPos(); |
|
return ts.createTextSpanFromBounds(start, scanner.getTextPos()); |
|
} |
|
ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; |
|
function getErrorSpanForNode(sourceFile, node) { |
|
var errorNode = node; |
|
switch (node.kind) { |
|
case 251 /* SourceFile */: |
|
var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); |
|
if (pos_1 === sourceFile.text.length) { |
|
// file is empty - return span for the beginning of the file |
|
return ts.createTextSpan(0, 0); |
|
} |
|
return getSpanOfTokenAtPosition(sourceFile, pos_1); |
|
// This list is a work in progress. Add missing node kinds to improve their error |
|
// spans. |
|
case 214 /* VariableDeclaration */: |
|
case 166 /* BindingElement */: |
|
case 217 /* ClassDeclaration */: |
|
case 189 /* ClassExpression */: |
|
case 218 /* InterfaceDeclaration */: |
|
case 221 /* ModuleDeclaration */: |
|
case 220 /* EnumDeclaration */: |
|
case 250 /* EnumMember */: |
|
case 216 /* FunctionDeclaration */: |
|
case 176 /* FunctionExpression */: |
|
case 144 /* MethodDeclaration */: |
|
case 219 /* TypeAliasDeclaration */: |
|
errorNode = node.name; |
|
break; |
|
} |
|
if (errorNode === undefined) { |
|
// If we don't have a better node, then just set the error on the first token of |
|
// construct. |
|
return getSpanOfTokenAtPosition(sourceFile, node.pos); |
|
} |
|
var pos = nodeIsMissing(errorNode) |
|
? errorNode.pos |
|
: ts.skipTrivia(sourceFile.text, errorNode.pos); |
|
return ts.createTextSpanFromBounds(pos, errorNode.end); |
|
} |
|
ts.getErrorSpanForNode = getErrorSpanForNode; |
|
function isExternalModule(file) { |
|
return file.externalModuleIndicator !== undefined; |
|
} |
|
ts.isExternalModule = isExternalModule; |
|
function isExternalOrCommonJsModule(file) { |
|
return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; |
|
} |
|
ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; |
|
function isDeclarationFile(file) { |
|
return (file.flags & 4096 /* DeclarationFile */) !== 0; |
|
} |
|
ts.isDeclarationFile = isDeclarationFile; |
|
function isConstEnumDeclaration(node) { |
|
return node.kind === 220 /* EnumDeclaration */ && isConst(node); |
|
} |
|
ts.isConstEnumDeclaration = isConstEnumDeclaration; |
|
function walkUpBindingElementsAndPatterns(node) { |
|
while (node && (node.kind === 166 /* BindingElement */ || isBindingPattern(node))) { |
|
node = node.parent; |
|
} |
|
return node; |
|
} |
|
// Returns the node flags for this node and all relevant parent nodes. This is done so that |
|
// nodes like variable declarations and binding elements can returned a view of their flags |
|
// that includes the modifiers from their container. i.e. flags like export/declare aren't |
|
// stored on the variable declaration directly, but on the containing variable statement |
|
// (if it has one). Similarly, flags for let/const are store on the variable declaration |
|
// list. By calling this function, all those flags are combined so that the client can treat |
|
// the node as if it actually had those flags. |
|
function getCombinedNodeFlags(node) { |
|
node = walkUpBindingElementsAndPatterns(node); |
|
var flags = node.flags; |
|
if (node.kind === 214 /* VariableDeclaration */) { |
|
node = node.parent; |
|
} |
|
if (node && node.kind === 215 /* VariableDeclarationList */) { |
|
flags |= node.flags; |
|
node = node.parent; |
|
} |
|
if (node && node.kind === 196 /* VariableStatement */) { |
|
flags |= node.flags; |
|
} |
|
return flags; |
|
} |
|
ts.getCombinedNodeFlags = getCombinedNodeFlags; |
|
function isConst(node) { |
|
return !!(getCombinedNodeFlags(node) & 16384 /* Const */); |
|
} |
|
ts.isConst = isConst; |
|
function isLet(node) { |
|
return !!(getCombinedNodeFlags(node) & 8192 /* Let */); |
|
} |
|
ts.isLet = isLet; |
|
function isSuperCallExpression(n) { |
|
return n.kind === 171 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; |
|
} |
|
ts.isSuperCallExpression = isSuperCallExpression; |
|
function isPrologueDirective(node) { |
|
return node.kind === 198 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; |
|
} |
|
ts.isPrologueDirective = isPrologueDirective; |
|
function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { |
|
return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); |
|
} |
|
ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; |
|
function getLeadingCommentRangesOfNodeFromText(node, text) { |
|
return ts.getLeadingCommentRanges(text, node.pos); |
|
} |
|
ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; |
|
function getJsDocComments(node, sourceFileOfNode) { |
|
return getJsDocCommentsFromText(node, sourceFileOfNode.text); |
|
} |
|
ts.getJsDocComments = getJsDocComments; |
|
function getJsDocCommentsFromText(node, text) { |
|
var commentRanges = (node.kind === 139 /* Parameter */ || node.kind === 138 /* TypeParameter */) ? |
|
ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : |
|
getLeadingCommentRangesOfNodeFromText(node, text); |
|
return ts.filter(commentRanges, isJsDocComment); |
|
function isJsDocComment(comment) { |
|
// True if the comment starts with '/**' but not if it is '/**/' |
|
return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && |
|
text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && |
|
text.charCodeAt(comment.pos + 3) !== 47 /* slash */; |
|
} |
|
} |
|
ts.getJsDocCommentsFromText = getJsDocCommentsFromText; |
|
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/; |
|
ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/; |
|
function isTypeNode(node) { |
|
if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 163 /* LastTypeNode */) { |
|
return true; |
|
} |
|
switch (node.kind) { |
|
case 117 /* AnyKeyword */: |
|
case 128 /* NumberKeyword */: |
|
case 130 /* StringKeyword */: |
|
case 120 /* BooleanKeyword */: |
|
case 131 /* SymbolKeyword */: |
|
return true; |
|
case 103 /* VoidKeyword */: |
|
return node.parent.kind !== 180 /* VoidExpression */; |
|
case 191 /* ExpressionWithTypeArguments */: |
|
return !isExpressionWithTypeArgumentsInClassExtendsClause(node); |
|
// Identifiers and qualified names may be type nodes, depending on their context. Climb |
|
// above them to find the lowest container |
|
case 69 /* Identifier */: |
|
// If the identifier is the RHS of a qualified name, then it's a type iff its parent is. |
|
if (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node) { |
|
node = node.parent; |
|
} |
|
else if (node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node) { |
|
node = node.parent; |
|
} |
|
// At this point, node is either a qualified name or an identifier |
|
ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */ || node.kind === 169 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); |
|
case 136 /* QualifiedName */: |
|
case 169 /* PropertyAccessExpression */: |
|
case 97 /* ThisKeyword */: |
|
var parent_1 = node.parent; |
|
if (parent_1.kind === 155 /* TypeQuery */) { |
|
return false; |
|
} |
|
// Do not recursively call isTypeNode on the parent. In the example: |
|
// |
|
// let a: A.B.C; |
|
// |
|
// Calling isTypeNode would consider the qualified name A.B a type node. Only C or |
|
// A.B.C is a type node. |
|
if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 163 /* LastTypeNode */) { |
|
return true; |
|
} |
|
switch (parent_1.kind) { |
|
case 191 /* ExpressionWithTypeArguments */: |
|
return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); |
|
case 138 /* TypeParameter */: |
|
return node === parent_1.constraint; |
|
case 142 /* PropertyDeclaration */: |
|
case 141 /* PropertySignature */: |
|
case 139 /* Parameter */: |
|
case 214 /* VariableDeclaration */: |
|
return node === parent_1.type; |
|
case 216 /* FunctionDeclaration */: |
|
case 176 /* FunctionExpression */: |
|
case 177 /* ArrowFunction */: |
|
case 145 /* Constructor */: |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
return node === parent_1.type; |
|
case 148 /* CallSignature */: |
|
case 149 /* ConstructSignature */: |
|
case 150 /* IndexSignature */: |
|
return node === parent_1.type; |
|
case 174 /* TypeAssertionExpression */: |
|
return node === parent_1.type; |
|
case 171 /* CallExpression */: |
|
case 172 /* NewExpression */: |
|
return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; |
|
case 173 /* TaggedTemplateExpression */: |
|
// TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. |
|
return false; |
|
} |
|
} |
|
return false; |
|
} |
|
ts.isTypeNode = isTypeNode; |
|
// Warning: This has the same semantics as the forEach family of functions, |
|
// in that traversal terminates in the event that 'visitor' supplies a truthy value. |
|
function forEachReturnStatement(body, visitor) { |
|
return traverse(body); |
|
function traverse(node) { |
|
switch (node.kind) { |
|
case 207 /* ReturnStatement */: |
|
return visitor(node); |
|
case 223 /* CaseBlock */: |
|
case 195 /* Block */: |
|
case 199 /* IfStatement */: |
|
case 200 /* DoStatement */: |
|
case 201 /* WhileStatement */: |
|
case 202 /* ForStatement */: |
|
case 203 /* ForInStatement */: |
|
case 204 /* ForOfStatement */: |
|
case 208 /* WithStatement */: |
|
case 209 /* SwitchStatement */: |
|
case 244 /* CaseClause */: |
|
case 245 /* DefaultClause */: |
|
case 210 /* LabeledStatement */: |
|
case 212 /* TryStatement */: |
|
case 247 /* CatchClause */: |
|
return ts.forEachChild(node, traverse); |
|
} |
|
} |
|
} |
|
ts.forEachReturnStatement = forEachReturnStatement; |
|
function forEachYieldExpression(body, visitor) { |
|
return traverse(body); |
|
function traverse(node) { |
|
switch (node.kind) { |
|
case 187 /* YieldExpression */: |
|
visitor(node); |
|
var operand = node.expression; |
|
if (operand) { |
|
traverse(operand); |
|
} |
|
case 220 /* EnumDeclaration */: |
|
case 218 /* InterfaceDeclaration */: |
|
case 221 /* ModuleDeclaration */: |
|
case 219 /* TypeAliasDeclaration */: |
|
case 217 /* ClassDeclaration */: |
|
case 189 /* ClassExpression */: |
|
// These are not allowed inside a generator now, but eventually they may be allowed |
|
// as local types. Regardless, any yield statements contained within them should be |
|
// skipped in this traversal. |
|
return; |
|
default: |
|
if (isFunctionLike(node)) { |
|
var name_5 = node.name; |
|
if (name_5 && name_5.kind === 137 /* ComputedPropertyName */) { |
|
// Note that we will not include methods/accessors of a class because they would require |
|
// first descending into the class. This is by design. |
|
traverse(name_5.expression); |
|
return; |
|
} |
|
} |
|
else if (!isTypeNode(node)) { |
|
// This is the general case, which should include mostly expressions and statements. |
|
// Also includes NodeArrays. |
|
ts.forEachChild(node, traverse); |
|
} |
|
} |
|
} |
|
} |
|
ts.forEachYieldExpression = forEachYieldExpression; |
|
function isVariableLike(node) { |
|
if (node) { |
|
switch (node.kind) { |
|
case 166 /* BindingElement */: |
|
case 250 /* EnumMember */: |
|
case 139 /* Parameter */: |
|
case 248 /* PropertyAssignment */: |
|
case 142 /* PropertyDeclaration */: |
|
case 141 /* PropertySignature */: |
|
case 249 /* ShorthandPropertyAssignment */: |
|
case 214 /* VariableDeclaration */: |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
ts.isVariableLike = isVariableLike; |
|
function isAccessor(node) { |
|
return node && (node.kind === 146 /* GetAccessor */ || node.kind === 147 /* SetAccessor */); |
|
} |
|
ts.isAccessor = isAccessor; |
|
function isClassLike(node) { |
|
return node && (node.kind === 217 /* ClassDeclaration */ || node.kind === 189 /* ClassExpression */); |
|
} |
|
ts.isClassLike = isClassLike; |
|
function isFunctionLike(node) { |
|
return node && isFunctionLikeKind(node.kind); |
|
} |
|
ts.isFunctionLike = isFunctionLike; |
|
function isFunctionLikeKind(kind) { |
|
switch (kind) { |
|
case 145 /* Constructor */: |
|
case 176 /* FunctionExpression */: |
|
case 216 /* FunctionDeclaration */: |
|
case 177 /* ArrowFunction */: |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
case 148 /* CallSignature */: |
|
case 149 /* ConstructSignature */: |
|
case 150 /* IndexSignature */: |
|
case 153 /* FunctionType */: |
|
case 154 /* ConstructorType */: |
|
return true; |
|
} |
|
} |
|
ts.isFunctionLikeKind = isFunctionLikeKind; |
|
function introducesArgumentsExoticObject(node) { |
|
switch (node.kind) { |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
case 145 /* Constructor */: |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
case 216 /* FunctionDeclaration */: |
|
case 176 /* FunctionExpression */: |
|
return true; |
|
} |
|
return false; |
|
} |
|
ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; |
|
function isIterationStatement(node, lookInLabeledStatements) { |
|
switch (node.kind) { |
|
case 202 /* ForStatement */: |
|
case 203 /* ForInStatement */: |
|
case 204 /* ForOfStatement */: |
|
case 200 /* DoStatement */: |
|
case 201 /* WhileStatement */: |
|
return true; |
|
case 210 /* LabeledStatement */: |
|
return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); |
|
} |
|
return false; |
|
} |
|
ts.isIterationStatement = isIterationStatement; |
|
function isFunctionBlock(node) { |
|
return node && node.kind === 195 /* Block */ && isFunctionLike(node.parent); |
|
} |
|
ts.isFunctionBlock = isFunctionBlock; |
|
function isObjectLiteralMethod(node) { |
|
return node && node.kind === 144 /* MethodDeclaration */ && node.parent.kind === 168 /* ObjectLiteralExpression */; |
|
} |
|
ts.isObjectLiteralMethod = isObjectLiteralMethod; |
|
function isIdentifierTypePredicate(predicate) { |
|
return predicate && predicate.kind === 1 /* Identifier */; |
|
} |
|
ts.isIdentifierTypePredicate = isIdentifierTypePredicate; |
|
function isThisTypePredicate(predicate) { |
|
return predicate && predicate.kind === 0 /* This */; |
|
} |
|
ts.isThisTypePredicate = isThisTypePredicate; |
|
function getContainingFunction(node) { |
|
while (true) { |
|
node = node.parent; |
|
if (!node || isFunctionLike(node)) { |
|
return node; |
|
} |
|
} |
|
} |
|
ts.getContainingFunction = getContainingFunction; |
|
function getContainingClass(node) { |
|
while (true) { |
|
node = node.parent; |
|
if (!node || isClassLike(node)) { |
|
return node; |
|
} |
|
} |
|
} |
|
ts.getContainingClass = getContainingClass; |
|
function getThisContainer(node, includeArrowFunctions) { |
|
while (true) { |
|
node = node.parent; |
|
if (!node) { |
|
return undefined; |
|
} |
|
switch (node.kind) { |
|
case 137 /* ComputedPropertyName */: |
|
// If the grandparent node is an object literal (as opposed to a class), |
|
// then the computed property is not a 'this' container. |
|
// A computed property name in a class needs to be a this container |
|
// so that we can error on it. |
|
if (isClassLike(node.parent.parent)) { |
|
return node; |
|
} |
|
// If this is a computed property, then the parent should not |
|
// make it a this container. The parent might be a property |
|
// in an object literal, like a method or accessor. But in order for |
|
// such a parent to be a this container, the reference must be in |
|
// the *body* of the container. |
|
node = node.parent; |
|
break; |
|
case 140 /* Decorator */: |
|
// Decorators are always applied outside of the body of a class or method. |
|
if (node.parent.kind === 139 /* Parameter */ && isClassElement(node.parent.parent)) { |
|
// If the decorator's parent is a Parameter, we resolve the this container from |
|
// the grandparent class declaration. |
|
node = node.parent.parent; |
|
} |
|
else if (isClassElement(node.parent)) { |
|
// If the decorator's parent is a class element, we resolve the 'this' container |
|
// from the parent class declaration. |
|
node = node.parent; |
|
} |
|
break; |
|
case 177 /* ArrowFunction */: |
|
if (!includeArrowFunctions) { |
|
continue; |
|
} |
|
// Fall through |
|
case 216 /* FunctionDeclaration */: |
|
case 176 /* FunctionExpression */: |
|
case 221 /* ModuleDeclaration */: |
|
case 142 /* PropertyDeclaration */: |
|
case 141 /* PropertySignature */: |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
case 145 /* Constructor */: |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
case 148 /* CallSignature */: |
|
case 149 /* ConstructSignature */: |
|
case 150 /* IndexSignature */: |
|
case 220 /* EnumDeclaration */: |
|
case 251 /* SourceFile */: |
|
return node; |
|
} |
|
} |
|
} |
|
ts.getThisContainer = getThisContainer; |
|
/** |
|
* Given an super call\property node returns a closest node where either |
|
* - super call\property is legal in the node and not legal in the parent node the node. |
|
* i.e. super call is legal in constructor but not legal in the class body. |
|
* - node is arrow function (so caller might need to call getSuperContainer in case it needs to climb higher) |
|
* - super call\property is definitely illegal in the node (but might be legal in some subnode) |
|
* i.e. super property access is illegal in function declaration but can be legal in the statement list |
|
*/ |
|
function getSuperContainer(node, stopOnFunctions) { |
|
while (true) { |
|
node = node.parent; |
|
if (!node) { |
|
return node; |
|
} |
|
switch (node.kind) { |
|
case 137 /* ComputedPropertyName */: |
|
node = node.parent; |
|
break; |
|
case 216 /* FunctionDeclaration */: |
|
case 176 /* FunctionExpression */: |
|
case 177 /* ArrowFunction */: |
|
if (!stopOnFunctions) { |
|
continue; |
|
} |
|
case 142 /* PropertyDeclaration */: |
|
case 141 /* PropertySignature */: |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
case 145 /* Constructor */: |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
return node; |
|
case 140 /* Decorator */: |
|
// Decorators are always applied outside of the body of a class or method. |
|
if (node.parent.kind === 139 /* Parameter */ && isClassElement(node.parent.parent)) { |
|
// If the decorator's parent is a Parameter, we resolve the this container from |
|
// the grandparent class declaration. |
|
node = node.parent.parent; |
|
} |
|
else if (isClassElement(node.parent)) { |
|
// If the decorator's parent is a class element, we resolve the 'this' container |
|
// from the parent class declaration. |
|
node = node.parent; |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
ts.getSuperContainer = getSuperContainer; |
|
/** |
|
* Determines whether a node is a property or element access expression for super. |
|
*/ |
|
function isSuperPropertyOrElementAccess(node) { |
|
return (node.kind === 169 /* PropertyAccessExpression */ |
|
|| node.kind === 170 /* ElementAccessExpression */) |
|
&& node.expression.kind === 95 /* SuperKeyword */; |
|
} |
|
ts.isSuperPropertyOrElementAccess = isSuperPropertyOrElementAccess; |
|
function getEntityNameFromTypeNode(node) { |
|
if (node) { |
|
switch (node.kind) { |
|
case 152 /* TypeReference */: |
|
return node.typeName; |
|
case 191 /* ExpressionWithTypeArguments */: |
|
return node.expression; |
|
case 69 /* Identifier */: |
|
case 136 /* QualifiedName */: |
|
return node; |
|
} |
|
} |
|
return undefined; |
|
} |
|
ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; |
|
function getInvokedExpression(node) { |
|
if (node.kind === 173 /* TaggedTemplateExpression */) { |
|
return node.tag; |
|
} |
|
// Will either be a CallExpression, NewExpression, or Decorator. |
|
return node.expression; |
|
} |
|
ts.getInvokedExpression = getInvokedExpression; |
|
function nodeCanBeDecorated(node) { |
|
switch (node.kind) { |
|
case 217 /* ClassDeclaration */: |
|
// classes are valid targets |
|
return true; |
|
case 142 /* PropertyDeclaration */: |
|
// property declarations are valid if their parent is a class declaration. |
|
return node.parent.kind === 217 /* ClassDeclaration */; |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
case 144 /* MethodDeclaration */: |
|
// if this method has a body and its parent is a class declaration, this is a valid target. |
|
return node.body !== undefined |
|
&& node.parent.kind === 217 /* ClassDeclaration */; |
|
case 139 /* Parameter */: |
|
// if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; |
|
return node.parent.body !== undefined |
|
&& (node.parent.kind === 145 /* Constructor */ |
|
|| node.parent.kind === 144 /* MethodDeclaration */ |
|
|| node.parent.kind === 147 /* SetAccessor */) |
|
&& node.parent.parent.kind === 217 /* ClassDeclaration */; |
|
} |
|
return false; |
|
} |
|
ts.nodeCanBeDecorated = nodeCanBeDecorated; |
|
function nodeIsDecorated(node) { |
|
return node.decorators !== undefined |
|
&& nodeCanBeDecorated(node); |
|
} |
|
ts.nodeIsDecorated = nodeIsDecorated; |
|
function isPropertyAccessExpression(node) { |
|
return node.kind === 169 /* PropertyAccessExpression */; |
|
} |
|
ts.isPropertyAccessExpression = isPropertyAccessExpression; |
|
function isElementAccessExpression(node) { |
|
return node.kind === 170 /* ElementAccessExpression */; |
|
} |
|
ts.isElementAccessExpression = isElementAccessExpression; |
|
function isExpression(node) { |
|
switch (node.kind) { |
|
case 95 /* SuperKeyword */: |
|
case 93 /* NullKeyword */: |
|
case 99 /* TrueKeyword */: |
|
case 84 /* FalseKeyword */: |
|
case 10 /* RegularExpressionLiteral */: |
|
case 167 /* ArrayLiteralExpression */: |
|
case 168 /* ObjectLiteralExpression */: |
|
case 169 /* PropertyAccessExpression */: |
|
case 170 /* ElementAccessExpression */: |
|
case 171 /* CallExpression */: |
|
case 172 /* NewExpression */: |
|
case 173 /* TaggedTemplateExpression */: |
|
case 192 /* AsExpression */: |
|
case 174 /* TypeAssertionExpression */: |
|
case 175 /* ParenthesizedExpression */: |
|
case 176 /* FunctionExpression */: |
|
case 189 /* ClassExpression */: |
|
case 177 /* ArrowFunction */: |
|
case 180 /* VoidExpression */: |
|
case 178 /* DeleteExpression */: |
|
case 179 /* TypeOfExpression */: |
|
case 182 /* PrefixUnaryExpression */: |
|
case 183 /* PostfixUnaryExpression */: |
|
case 184 /* BinaryExpression */: |
|
case 185 /* ConditionalExpression */: |
|
case 188 /* SpreadElementExpression */: |
|
case 186 /* TemplateExpression */: |
|
case 11 /* NoSubstitutionTemplateLiteral */: |
|
case 190 /* OmittedExpression */: |
|
case 236 /* JsxElement */: |
|
case 237 /* JsxSelfClosingElement */: |
|
case 187 /* YieldExpression */: |
|
case 181 /* AwaitExpression */: |
|
return true; |
|
case 136 /* QualifiedName */: |
|
while (node.parent.kind === 136 /* QualifiedName */) { |
|
node = node.parent; |
|
} |
|
return node.parent.kind === 155 /* TypeQuery */; |
|
case 69 /* Identifier */: |
|
if (node.parent.kind === 155 /* TypeQuery */) { |
|
return true; |
|
} |
|
// fall through |
|
case 8 /* NumericLiteral */: |
|
case 9 /* StringLiteral */: |
|
case 97 /* ThisKeyword */: |
|
var parent_2 = node.parent; |
|
switch (parent_2.kind) { |
|
case 214 /* VariableDeclaration */: |
|
case 139 /* Parameter */: |
|
case 142 /* PropertyDeclaration */: |
|
case 141 /* PropertySignature */: |
|
case 250 /* EnumMember */: |
|
case 248 /* PropertyAssignment */: |
|
case 166 /* BindingElement */: |
|
return parent_2.initializer === node; |
|
case 198 /* ExpressionStatement */: |
|
case 199 /* IfStatement */: |
|
case 200 /* DoStatement */: |
|
case 201 /* WhileStatement */: |
|
case 207 /* ReturnStatement */: |
|
case 208 /* WithStatement */: |
|
case 209 /* SwitchStatement */: |
|
case 244 /* CaseClause */: |
|
case 211 /* ThrowStatement */: |
|
case 209 /* SwitchStatement */: |
|
return parent_2.expression === node; |
|
case 202 /* ForStatement */: |
|
var forStatement = parent_2; |
|
return (forStatement.initializer === node && forStatement.initializer.kind !== 215 /* VariableDeclarationList */) || |
|
forStatement.condition === node || |
|
forStatement.incrementor === node; |
|
case 203 /* ForInStatement */: |
|
case 204 /* ForOfStatement */: |
|
var forInStatement = parent_2; |
|
return (forInStatement.initializer === node && forInStatement.initializer.kind !== 215 /* VariableDeclarationList */) || |
|
forInStatement.expression === node; |
|
case 174 /* TypeAssertionExpression */: |
|
case 192 /* AsExpression */: |
|
return node === parent_2.expression; |
|
case 193 /* TemplateSpan */: |
|
return node === parent_2.expression; |
|
case 137 /* ComputedPropertyName */: |
|
return node === parent_2.expression; |
|
case 140 /* Decorator */: |
|
case 243 /* JsxExpression */: |
|
case 242 /* JsxSpreadAttribute */: |
|
return true; |
|
case 191 /* ExpressionWithTypeArguments */: |
|
return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); |
|
default: |
|
if (isExpression(parent_2)) { |
|
return true; |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
ts.isExpression = isExpression; |
|
function isExternalModuleNameRelative(moduleName) { |
|
// TypeScript 1.0 spec (April 2014): 11.2.1 |
|
// An external module name is "relative" if the first term is "." or "..". |
|
return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; |
|
} |
|
ts.isExternalModuleNameRelative = isExternalModuleNameRelative; |
|
function isInstantiatedModule(node, preserveConstEnums) { |
|
var moduleState = ts.getModuleInstanceState(node); |
|
return moduleState === 1 /* Instantiated */ || |
|
(preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); |
|
} |
|
ts.isInstantiatedModule = isInstantiatedModule; |
|
function isExternalModuleImportEqualsDeclaration(node) { |
|
return node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 235 /* ExternalModuleReference */; |
|
} |
|
ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; |
|
function getExternalModuleImportEqualsDeclarationExpression(node) { |
|
ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); |
|
return node.moduleReference.expression; |
|
} |
|
ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; |
|
function isInternalModuleImportEqualsDeclaration(node) { |
|
return node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 235 /* ExternalModuleReference */; |
|
} |
|
ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; |
|
function isSourceFileJavaScript(file) { |
|
return isInJavaScriptFile(file); |
|
} |
|
ts.isSourceFileJavaScript = isSourceFileJavaScript; |
|
function isInJavaScriptFile(node) { |
|
return node && !!(node.parserContextFlags & 32 /* JavaScriptFile */); |
|
} |
|
ts.isInJavaScriptFile = isInJavaScriptFile; |
|
/** |
|
* Returns true if the node is a CallExpression to the identifier 'require' with |
|
* exactly one argument. |
|
* This function does not test if the node is in a JavaScript file or not. |
|
*/ |
|
function isRequireCall(expression, checkArgumentIsStringLiteral) { |
|
// of the form 'require("name")' |
|
var isRequire = expression.kind === 171 /* CallExpression */ && |
|
expression.expression.kind === 69 /* Identifier */ && |
|
expression.expression.text === "require" && |
|
expression.arguments.length === 1; |
|
return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9 /* StringLiteral */); |
|
} |
|
ts.isRequireCall = isRequireCall; |
|
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property |
|
/// assignments we treat as special in the binder |
|
function getSpecialPropertyAssignmentKind(expression) { |
|
if (!isInJavaScriptFile(expression)) { |
|
return 0 /* None */; |
|
} |
|
if (expression.kind !== 184 /* BinaryExpression */) { |
|
return 0 /* None */; |
|
} |
|
var expr = expression; |
|
if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 169 /* PropertyAccessExpression */) { |
|
return 0 /* None */; |
|
} |
|
var lhs = expr.left; |
|
if (lhs.expression.kind === 69 /* Identifier */) { |
|
var lhsId = lhs.expression; |
|
if (lhsId.text === "exports") { |
|
// exports.name = expr |
|
return 1 /* ExportsProperty */; |
|
} |
|
else if (lhsId.text === "module" && lhs.name.text === "exports") { |
|
// module.exports = expr |
|
return 2 /* ModuleExports */; |
|
} |
|
} |
|
else if (lhs.expression.kind === 97 /* ThisKeyword */) { |
|
return 4 /* ThisProperty */; |
|
} |
|
else if (lhs.expression.kind === 169 /* PropertyAccessExpression */) { |
|
// chained dot, e.g. x.y.z = expr; this var is the 'x.y' part |
|
var innerPropertyAccess = lhs.expression; |
|
if (innerPropertyAccess.expression.kind === 69 /* Identifier */ && innerPropertyAccess.name.text === "prototype") { |
|
return 3 /* PrototypeProperty */; |
|
} |
|
} |
|
return 0 /* None */; |
|
} |
|
ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; |
|
function getExternalModuleName(node) { |
|
if (node.kind === 225 /* ImportDeclaration */) { |
|
return node.moduleSpecifier; |
|
} |
|
if (node.kind === 224 /* ImportEqualsDeclaration */) { |
|
var reference = node.moduleReference; |
|
if (reference.kind === 235 /* ExternalModuleReference */) { |
|
return reference.expression; |
|
} |
|
} |
|
if (node.kind === 231 /* ExportDeclaration */) { |
|
return node.moduleSpecifier; |
|
} |
|
if (node.kind === 221 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { |
|
return node.name; |
|
} |
|
} |
|
ts.getExternalModuleName = getExternalModuleName; |
|
function hasQuestionToken(node) { |
|
if (node) { |
|
switch (node.kind) { |
|
case 139 /* Parameter */: |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
case 249 /* ShorthandPropertyAssignment */: |
|
case 248 /* PropertyAssignment */: |
|
case 142 /* PropertyDeclaration */: |
|
case 141 /* PropertySignature */: |
|
return node.questionToken !== undefined; |
|
} |
|
} |
|
return false; |
|
} |
|
ts.hasQuestionToken = hasQuestionToken; |
|
function isJSDocConstructSignature(node) { |
|
return node.kind === 264 /* JSDocFunctionType */ && |
|
node.parameters.length > 0 && |
|
node.parameters[0].type.kind === 266 /* JSDocConstructorType */; |
|
} |
|
ts.isJSDocConstructSignature = isJSDocConstructSignature; |
|
function getJSDocTag(node, kind, checkParentVariableStatement) { |
|
if (!node) { |
|
return undefined; |
|
} |
|
var jsDocComment = getJSDocComment(node, checkParentVariableStatement); |
|
if (!jsDocComment) { |
|
return undefined; |
|
} |
|
for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { |
|
var tag = _a[_i]; |
|
if (tag.kind === kind) { |
|
return tag; |
|
} |
|
} |
|
} |
|
function getJSDocComment(node, checkParentVariableStatement) { |
|
if (node.jsDocComment) { |
|
return node.jsDocComment; |
|
} |
|
// Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. |
|
// /** |
|
// * @param {number} name |
|
// * @returns {number} |
|
// */ |
|
// var x = function(name) { return name.length; } |
|
if (checkParentVariableStatement) { |
|
var isInitializerOfVariableDeclarationInStatement = node.parent.kind === 214 /* VariableDeclaration */ && |
|
node.parent.initializer === node && |
|
node.parent.parent.parent.kind === 196 /* VariableStatement */; |
|
var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : undefined; |
|
if (variableStatementNode) { |
|
return variableStatementNode.jsDocComment; |
|
} |
|
// Also recognize when the node is the RHS of an assignment expression |
|
var parent_3 = node.parent; |
|
var isSourceOfAssignmentExpressionStatement = parent_3 && parent_3.parent && |
|
parent_3.kind === 184 /* BinaryExpression */ && |
|
parent_3.operatorToken.kind === 56 /* EqualsToken */ && |
|
parent_3.parent.kind === 198 /* ExpressionStatement */; |
|
if (isSourceOfAssignmentExpressionStatement) { |
|
return parent_3.parent.jsDocComment; |
|
} |
|
var isPropertyAssignmentExpression = parent_3 && parent_3.kind === 248 /* PropertyAssignment */; |
|
if (isPropertyAssignmentExpression) { |
|
return parent_3.jsDocComment; |
|
} |
|
} |
|
return undefined; |
|
} |
|
function getJSDocTypeTag(node) { |
|
return getJSDocTag(node, 272 /* JSDocTypeTag */, /*checkParentVariableStatement*/ false); |
|
} |
|
ts.getJSDocTypeTag = getJSDocTypeTag; |
|
function getJSDocReturnTag(node) { |
|
return getJSDocTag(node, 271 /* JSDocReturnTag */, /*checkParentVariableStatement*/ true); |
|
} |
|
ts.getJSDocReturnTag = getJSDocReturnTag; |
|
function getJSDocTemplateTag(node) { |
|
return getJSDocTag(node, 273 /* JSDocTemplateTag */, /*checkParentVariableStatement*/ false); |
|
} |
|
ts.getJSDocTemplateTag = getJSDocTemplateTag; |
|
function getCorrespondingJSDocParameterTag(parameter) { |
|
if (parameter.name && parameter.name.kind === 69 /* Identifier */) { |
|
// If it's a parameter, see if the parent has a jsdoc comment with an @param |
|
// annotation. |
|
var parameterName = parameter.name.text; |
|
var jsDocComment = getJSDocComment(parameter.parent, /*checkParentVariableStatement*/ true); |
|
if (jsDocComment) { |
|
for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { |
|
var tag = _a[_i]; |
|
if (tag.kind === 270 /* JSDocParameterTag */) { |
|
var parameterTag = tag; |
|
var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; |
|
if (name_6.text === parameterName) { |
|
return parameterTag; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return undefined; |
|
} |
|
ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; |
|
function hasRestParameter(s) { |
|
return isRestParameter(ts.lastOrUndefined(s.parameters)); |
|
} |
|
ts.hasRestParameter = hasRestParameter; |
|
function isRestParameter(node) { |
|
if (node) { |
|
if (node.parserContextFlags & 32 /* JavaScriptFile */) { |
|
if (node.type && node.type.kind === 265 /* JSDocVariadicType */) { |
|
return true; |
|
} |
|
var paramTag = getCorrespondingJSDocParameterTag(node); |
|
if (paramTag && paramTag.typeExpression) { |
|
return paramTag.typeExpression.type.kind === 265 /* JSDocVariadicType */; |
|
} |
|
} |
|
return node.dotDotDotToken !== undefined; |
|
} |
|
return false; |
|
} |
|
ts.isRestParameter = isRestParameter; |
|
function isLiteralKind(kind) { |
|
return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; |
|
} |
|
ts.isLiteralKind = isLiteralKind; |
|
function isTextualLiteralKind(kind) { |
|
return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; |
|
} |
|
ts.isTextualLiteralKind = isTextualLiteralKind; |
|
function isTemplateLiteralKind(kind) { |
|
return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; |
|
} |
|
ts.isTemplateLiteralKind = isTemplateLiteralKind; |
|
function isBindingPattern(node) { |
|
return !!node && (node.kind === 165 /* ArrayBindingPattern */ || node.kind === 164 /* ObjectBindingPattern */); |
|
} |
|
ts.isBindingPattern = isBindingPattern; |
|
function isNodeDescendentOf(node, ancestor) { |
|
while (node) { |
|
if (node === ancestor) |
|
return true; |
|
node = node.parent; |
|
} |
|
return false; |
|
} |
|
ts.isNodeDescendentOf = isNodeDescendentOf; |
|
function isInAmbientContext(node) { |
|
while (node) { |
|
if (node.flags & (4 /* Ambient */ | 4096 /* DeclarationFile */)) { |
|
return true; |
|
} |
|
node = node.parent; |
|
} |
|
return false; |
|
} |
|
ts.isInAmbientContext = isInAmbientContext; |
|
function isDeclaration(node) { |
|
switch (node.kind) { |
|
case 177 /* ArrowFunction */: |
|
case 166 /* BindingElement */: |
|
case 217 /* ClassDeclaration */: |
|
case 189 /* ClassExpression */: |
|
case 145 /* Constructor */: |
|
case 220 /* EnumDeclaration */: |
|
case 250 /* EnumMember */: |
|
case 233 /* ExportSpecifier */: |
|
case 216 /* FunctionDeclaration */: |
|
case 176 /* FunctionExpression */: |
|
case 146 /* GetAccessor */: |
|
case 226 /* ImportClause */: |
|
case 224 /* ImportEqualsDeclaration */: |
|
case 229 /* ImportSpecifier */: |
|
case 218 /* InterfaceDeclaration */: |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
case 221 /* ModuleDeclaration */: |
|
case 227 /* NamespaceImport */: |
|
case 139 /* Parameter */: |
|
case 248 /* PropertyAssignment */: |
|
case 142 /* PropertyDeclaration */: |
|
case 141 /* PropertySignature */: |
|
case 147 /* SetAccessor */: |
|
case 249 /* ShorthandPropertyAssignment */: |
|
case 219 /* TypeAliasDeclaration */: |
|
case 138 /* TypeParameter */: |
|
case 214 /* VariableDeclaration */: |
|
return true; |
|
} |
|
return false; |
|
} |
|
ts.isDeclaration = isDeclaration; |
|
function isStatement(n) { |
|
switch (n.kind) { |
|
case 206 /* BreakStatement */: |
|
case 205 /* ContinueStatement */: |
|
case 213 /* DebuggerStatement */: |
|
case 200 /* DoStatement */: |
|
case 198 /* ExpressionStatement */: |
|
case 197 /* EmptyStatement */: |
|
case 203 /* ForInStatement */: |
|
case 204 /* ForOfStatement */: |
|
case 202 /* ForStatement */: |
|
case 199 /* IfStatement */: |
|
case 210 /* LabeledStatement */: |
|
case 207 /* ReturnStatement */: |
|
case 209 /* SwitchStatement */: |
|
case 211 /* ThrowStatement */: |
|
case 212 /* TryStatement */: |
|
case 196 /* VariableStatement */: |
|
case 201 /* WhileStatement */: |
|
case 208 /* WithStatement */: |
|
case 230 /* ExportAssignment */: |
|
return true; |
|
default: |
|
return false; |
|
} |
|
} |
|
ts.isStatement = isStatement; |
|
function isClassElement(n) { |
|
switch (n.kind) { |
|
case 145 /* Constructor */: |
|
case 142 /* PropertyDeclaration */: |
|
case 144 /* MethodDeclaration */: |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
case 143 /* MethodSignature */: |
|
case 150 /* IndexSignature */: |
|
return true; |
|
default: |
|
return false; |
|
} |
|
} |
|
ts.isClassElement = isClassElement; |
|
// True if the given identifier, string literal, or number literal is the name of a declaration node |
|
function isDeclarationName(name) { |
|
if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { |
|
return false; |
|
} |
|
var parent = name.parent; |
|
if (parent.kind === 229 /* ImportSpecifier */ || parent.kind === 233 /* ExportSpecifier */) { |
|
if (parent.propertyName) { |
|
return true; |
|
} |
|
} |
|
if (isDeclaration(parent)) { |
|
return parent.name === name; |
|
} |
|
return false; |
|
} |
|
ts.isDeclarationName = isDeclarationName; |
|
// Return true if the given identifier is classified as an IdentifierName |
|
function isIdentifierName(node) { |
|
var parent = node.parent; |
|
switch (parent.kind) { |
|
case 142 /* PropertyDeclaration */: |
|
case 141 /* PropertySignature */: |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
case 250 /* EnumMember */: |
|
case 248 /* PropertyAssignment */: |
|
case 169 /* PropertyAccessExpression */: |
|
// Name in member declaration or property name in property access |
|
return parent.name === node; |
|
case 136 /* QualifiedName */: |
|
// Name on right hand side of dot in a type query |
|
if (parent.right === node) { |
|
while (parent.kind === 136 /* QualifiedName */) { |
|
parent = parent.parent; |
|
} |
|
return parent.kind === 155 /* TypeQuery */; |
|
} |
|
return false; |
|
case 166 /* BindingElement */: |
|
case 229 /* ImportSpecifier */: |
|
// Property name in binding element or import specifier |
|
return parent.propertyName === node; |
|
case 233 /* ExportSpecifier */: |
|
// Any name in an export specifier |
|
return true; |
|
} |
|
return false; |
|
} |
|
ts.isIdentifierName = isIdentifierName; |
|
// An alias symbol is created by one of the following declarations: |
|
// import <symbol> = ... |
|
// import <symbol> from ... |
|
// import * as <symbol> from ... |
|
// import { x as <symbol> } from ... |
|
// export { x as <symbol> } from ... |
|
// export = ... |
|
// export default ... |
|
function isAliasSymbolDeclaration(node) { |
|
return node.kind === 224 /* ImportEqualsDeclaration */ || |
|
node.kind === 226 /* ImportClause */ && !!node.name || |
|
node.kind === 227 /* NamespaceImport */ || |
|
node.kind === 229 /* ImportSpecifier */ || |
|
node.kind === 233 /* ExportSpecifier */ || |
|
node.kind === 230 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; |
|
} |
|
ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; |
|
function getClassExtendsHeritageClauseElement(node) { |
|
var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); |
|
return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; |
|
} |
|
ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; |
|
function getClassImplementsHeritageClauseElements(node) { |
|
var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); |
|
return heritageClause ? heritageClause.types : undefined; |
|
} |
|
ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; |
|
function getInterfaceBaseTypeNodes(node) { |
|
var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); |
|
return heritageClause ? heritageClause.types : undefined; |
|
} |
|
ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; |
|
function getHeritageClause(clauses, kind) { |
|
if (clauses) { |
|
for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { |
|
var clause = clauses_1[_i]; |
|
if (clause.token === kind) { |
|
return clause; |
|
} |
|
} |
|
} |
|
return undefined; |
|
} |
|
ts.getHeritageClause = getHeritageClause; |
|
function tryResolveScriptReference(host, sourceFile, reference) { |
|
if (!host.getCompilerOptions().noResolve) { |
|
var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); |
|
return host.getSourceFile(referenceFileName); |
|
} |
|
} |
|
ts.tryResolveScriptReference = tryResolveScriptReference; |
|
function getAncestor(node, kind) { |
|
while (node) { |
|
if (node.kind === kind) { |
|
return node; |
|
} |
|
node = node.parent; |
|
} |
|
return undefined; |
|
} |
|
ts.getAncestor = getAncestor; |
|
function getFileReferenceFromReferencePath(comment, commentRange) { |
|
var simpleReferenceRegEx = /^\/\/\/\s*<reference\s+/gim; |
|
var isNoDefaultLibRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/gim; |
|
if (simpleReferenceRegEx.test(comment)) { |
|
if (isNoDefaultLibRegEx.test(comment)) { |
|
return { |
|
isNoDefaultLib: true |
|
}; |
|
} |
|
else { |
|
var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); |
|
if (matchResult) { |
|
var start = commentRange.pos; |
|
var end = commentRange.end; |
|
return { |
|
fileReference: { |
|
pos: start, |
|
end: end, |
|
fileName: matchResult[3] |
|
}, |
|
isNoDefaultLib: false |
|
}; |
|
} |
|
else { |
|
return { |
|
diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, |
|
isNoDefaultLib: false |
|
}; |
|
} |
|
} |
|
} |
|
return undefined; |
|
} |
|
ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; |
|
function isKeyword(token) { |
|
return 70 /* FirstKeyword */ <= token && token <= 135 /* LastKeyword */; |
|
} |
|
ts.isKeyword = isKeyword; |
|
function isTrivia(token) { |
|
return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; |
|
} |
|
ts.isTrivia = isTrivia; |
|
function isAsyncFunctionLike(node) { |
|
return isFunctionLike(node) && (node.flags & 256 /* Async */) !== 0 && !isAccessor(node); |
|
} |
|
ts.isAsyncFunctionLike = isAsyncFunctionLike; |
|
function isStringOrNumericLiteral(kind) { |
|
return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */; |
|
} |
|
ts.isStringOrNumericLiteral = isStringOrNumericLiteral; |
|
/** |
|
* A declaration has a dynamic name if both of the following are true: |
|
* 1. The declaration has a computed property name |
|
* 2. The computed name is *not* expressed as Symbol.<name>, where name |
|
* is a property of the Symbol constructor that denotes a built in |
|
* Symbol. |
|
*/ |
|
function hasDynamicName(declaration) { |
|
return declaration.name && isDynamicName(declaration.name); |
|
} |
|
ts.hasDynamicName = hasDynamicName; |
|
function isDynamicName(name) { |
|
return name.kind === 137 /* ComputedPropertyName */ && |
|
!isStringOrNumericLiteral(name.expression.kind) && |
|
!isWellKnownSymbolSyntactically(name.expression); |
|
} |
|
ts.isDynamicName = isDynamicName; |
|
/** |
|
* Checks if the expression is of the form: |
|
* Symbol.name |
|
* where Symbol is literally the word "Symbol", and name is any identifierName |
|
*/ |
|
function isWellKnownSymbolSyntactically(node) { |
|
return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); |
|
} |
|
ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; |
|
function getPropertyNameForPropertyNameNode(name) { |
|
if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { |
|
return name.text; |
|
} |
|
if (name.kind === 137 /* ComputedPropertyName */) { |
|
var nameExpression = name.expression; |
|
if (isWellKnownSymbolSyntactically(nameExpression)) { |
|
var rightHandSideName = nameExpression.name.text; |
|
return getPropertyNameForKnownSymbolName(rightHandSideName); |
|
} |
|
} |
|
return undefined; |
|
} |
|
ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; |
|
function getPropertyNameForKnownSymbolName(symbolName) { |
|
return "__@" + symbolName; |
|
} |
|
ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; |
|
/** |
|
* Includes the word "Symbol" with unicode escapes |
|
*/ |
|
function isESSymbolIdentifier(node) { |
|
return node.kind === 69 /* Identifier */ && node.text === "Symbol"; |
|
} |
|
ts.isESSymbolIdentifier = isESSymbolIdentifier; |
|
function isModifierKind(token) { |
|
switch (token) { |
|
case 115 /* AbstractKeyword */: |
|
case 118 /* AsyncKeyword */: |
|
case 74 /* ConstKeyword */: |
|
case 122 /* DeclareKeyword */: |
|
case 77 /* DefaultKeyword */: |
|
case 82 /* ExportKeyword */: |
|
case 112 /* PublicKeyword */: |
|
case 110 /* PrivateKeyword */: |
|
case 111 /* ProtectedKeyword */: |
|
case 113 /* StaticKeyword */: |
|
return true; |
|
} |
|
return false; |
|
} |
|
ts.isModifierKind = isModifierKind; |
|
function isParameterDeclaration(node) { |
|
var root = getRootDeclaration(node); |
|
return root.kind === 139 /* Parameter */; |
|
} |
|
ts.isParameterDeclaration = isParameterDeclaration; |
|
function getRootDeclaration(node) { |
|
while (node.kind === 166 /* BindingElement */) { |
|
node = node.parent.parent; |
|
} |
|
return node; |
|
} |
|
ts.getRootDeclaration = getRootDeclaration; |
|
function nodeStartsNewLexicalEnvironment(n) { |
|
return isFunctionLike(n) || n.kind === 221 /* ModuleDeclaration */ || n.kind === 251 /* SourceFile */; |
|
} |
|
ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; |
|
/** |
|
* Creates a shallow, memberwise clone of a node. The "kind", "pos", "end", "flags", and "parent" |
|
* properties are excluded by default, and can be provided via the "location", "flags", and |
|
* "parent" parameters. |
|
* @param node The node to clone. |
|
* @param location An optional TextRange to use to supply the new position. |
|
* @param flags The NodeFlags to use for the cloned node. |
|
* @param parent The parent for the new node. |
|
*/ |
|
function cloneNode(node, location, flags, parent) { |
|
// We don't use "clone" from core.ts here, as we need to preserve the prototype chain of |
|
// the original node. We also need to exclude specific properties and only include own- |
|
// properties (to skip members already defined on the shared prototype). |
|
var clone = location !== undefined |
|
? ts.createNode(node.kind, location.pos, location.end) |
|
: createSynthesizedNode(node.kind); |
|
for (var key in node) { |
|
if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { |
|
continue; |
|
} |
|
clone[key] = node[key]; |
|
} |
|
if (flags !== undefined) { |
|
clone.flags = flags; |
|
} |
|
if (parent !== undefined) { |
|
clone.parent = parent; |
|
} |
|
return clone; |
|
} |
|
ts.cloneNode = cloneNode; |
|
/** |
|
* Creates a deep clone of an EntityName, with new parent pointers. |
|
* @param node The EntityName to clone. |
|
* @param parent The parent for the cloned node. |
|
*/ |
|
function cloneEntityName(node, parent) { |
|
var clone = cloneNode(node, node, node.flags, parent); |
|
if (isQualifiedName(clone)) { |
|
var left = clone.left, right = clone.right; |
|
clone.left = cloneEntityName(left, clone); |
|
clone.right = cloneNode(right, right, right.flags, parent); |
|
} |
|
return clone; |
|
} |
|
ts.cloneEntityName = cloneEntityName; |
|
function isQualifiedName(node) { |
|
return node.kind === 136 /* QualifiedName */; |
|
} |
|
ts.isQualifiedName = isQualifiedName; |
|
function nodeIsSynthesized(node) { |
|
return node.pos === -1; |
|
} |
|
ts.nodeIsSynthesized = nodeIsSynthesized; |
|
function createSynthesizedNode(kind, startsOnNewLine) { |
|
var node = ts.createNode(kind, /* pos */ -1, /* end */ -1); |
|
node.startsOnNewLine = startsOnNewLine; |
|
return node; |
|
} |
|
ts.createSynthesizedNode = createSynthesizedNode; |
|
function createSynthesizedNodeArray() { |
|
var array = []; |
|
array.pos = -1; |
|
array.end = -1; |
|
return array; |
|
} |
|
ts.createSynthesizedNodeArray = createSynthesizedNodeArray; |
|
function createDiagnosticCollection() { |
|
var nonFileDiagnostics = []; |
|
var fileDiagnostics = {}; |
|
var diagnosticsModified = false; |
|
var modificationCount = 0; |
|
return { |
|
add: add, |
|
getGlobalDiagnostics: getGlobalDiagnostics, |
|
getDiagnostics: getDiagnostics, |
|
getModificationCount: getModificationCount, |
|
reattachFileDiagnostics: reattachFileDiagnostics |
|
}; |
|
function getModificationCount() { |
|
return modificationCount; |
|
} |
|
function reattachFileDiagnostics(newFile) { |
|
if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { |
|
return; |
|
} |
|
for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { |
|
var diagnostic = _a[_i]; |
|
diagnostic.file = newFile; |
|
} |
|
} |
|
function add(diagnostic) { |
|
var diagnostics; |
|
if (diagnostic.file) { |
|
diagnostics = fileDiagnostics[diagnostic.file.fileName]; |
|
if (!diagnostics) { |
|
diagnostics = []; |
|
fileDiagnostics[diagnostic.file.fileName] = diagnostics; |
|
} |
|
} |
|
else { |
|
diagnostics = nonFileDiagnostics; |
|
} |
|
diagnostics.push(diagnostic); |
|
diagnosticsModified = true; |
|
modificationCount++; |
|
} |
|
function getGlobalDiagnostics() { |
|
sortAndDeduplicate(); |
|
return nonFileDiagnostics; |
|
} |
|
function getDiagnostics(fileName) { |
|
sortAndDeduplicate(); |
|
if (fileName) { |
|
return fileDiagnostics[fileName] || []; |
|
} |
|
var allDiagnostics = []; |
|
function pushDiagnostic(d) { |
|
allDiagnostics.push(d); |
|
} |
|
ts.forEach(nonFileDiagnostics, pushDiagnostic); |
|
for (var key in fileDiagnostics) { |
|
if (ts.hasProperty(fileDiagnostics, key)) { |
|
ts.forEach(fileDiagnostics[key], pushDiagnostic); |
|
} |
|
} |
|
return ts.sortAndDeduplicateDiagnostics(allDiagnostics); |
|
} |
|
function sortAndDeduplicate() { |
|
if (!diagnosticsModified) { |
|
return; |
|
} |
|
diagnosticsModified = false; |
|
nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); |
|
for (var key in fileDiagnostics) { |
|
if (ts.hasProperty(fileDiagnostics, key)) { |
|
fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); |
|
} |
|
} |
|
} |
|
} |
|
ts.createDiagnosticCollection = createDiagnosticCollection; |
|
// This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, |
|
// paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in |
|
// the language service. These characters should be escaped when printing, and if any characters are added, |
|
// the map below must be updated. Note that this regexp *does not* include the 'delete' character. |
|
// There is no reason for this other than that JSON.stringify does not handle it either. |
|
var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; |
|
var escapedCharsMap = { |
|
"\0": "\\0", |
|
"\t": "\\t", |
|
"\v": "\\v", |
|
"\f": "\\f", |
|
"\b": "\\b", |
|
"\r": "\\r", |
|
"\n": "\\n", |
|
"\\": "\\\\", |
|
"\"": "\\\"", |
|
"\u2028": "\\u2028", |
|
"\u2029": "\\u2029", |
|
"\u0085": "\\u0085" // nextLine |
|
}; |
|
/** |
|
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), |
|
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) |
|
* Note that this doesn't actually wrap the input in double quotes. |
|
*/ |
|
function escapeString(s) { |
|
s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; |
|
return s; |
|
function getReplacement(c) { |
|
return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); |
|
} |
|
} |
|
ts.escapeString = escapeString; |
|
function isIntrinsicJsxName(name) { |
|
var ch = name.substr(0, 1); |
|
return ch.toLowerCase() === ch; |
|
} |
|
ts.isIntrinsicJsxName = isIntrinsicJsxName; |
|
function get16BitUnicodeEscapeSequence(charCode) { |
|
var hexCharCode = charCode.toString(16).toUpperCase(); |
|
var paddedHexCode = ("0000" + hexCharCode).slice(-4); |
|
return "\\u" + paddedHexCode; |
|
} |
|
var nonAsciiCharacters = /[^\u0000-\u007F]/g; |
|
function escapeNonAsciiCharacters(s) { |
|
// Replace non-ASCII characters with '\uNNNN' escapes if any exist. |
|
// Otherwise just return the original string. |
|
return nonAsciiCharacters.test(s) ? |
|
s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : |
|
s; |
|
} |
|
ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; |
|
var indentStrings = ["", " "]; |
|
function getIndentString(level) { |
|
if (indentStrings[level] === undefined) { |
|
indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; |
|
} |
|
return indentStrings[level]; |
|
} |
|
ts.getIndentString = getIndentString; |
|
function getIndentSize() { |
|
return indentStrings[1].length; |
|
} |
|
ts.getIndentSize = getIndentSize; |
|
function createTextWriter(newLine) { |
|
var output; |
|
var indent; |
|
var lineStart; |
|
var lineCount; |
|
var linePos; |
|
function write(s) { |
|
if (s && s.length) { |
|
if (lineStart) { |
|
output += getIndentString(indent); |
|
lineStart = false; |
|
} |
|
output += s; |
|
} |
|
} |
|
function reset() { |
|
output = ""; |
|
indent = 0; |
|
lineStart = true; |
|
lineCount = 0; |
|
linePos = 0; |
|
} |
|
function rawWrite(s) { |
|
if (s !== undefined) { |
|
if (lineStart) { |
|
lineStart = false; |
|
} |
|
output += s; |
|
} |
|
} |
|
function writeLiteral(s) { |
|
if (s && s.length) { |
|
write(s); |
|
var lineStartsOfS = ts.computeLineStarts(s); |
|
if (lineStartsOfS.length > 1) { |
|
lineCount = lineCount + lineStartsOfS.length - 1; |
|
linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); |
|
} |
|
} |
|
} |
|
function writeLine() { |
|
if (!lineStart) { |
|
output += newLine; |
|
lineCount++; |
|
linePos = output.length; |
|
lineStart = true; |
|
} |
|
} |
|
function writeTextOfNode(text, node) { |
|
write(getTextOfNodeFromSourceText(text, node)); |
|
} |
|
reset(); |
|
return { |
|
write: write, |
|
rawWrite: rawWrite, |
|
writeTextOfNode: writeTextOfNode, |
|
writeLiteral: writeLiteral, |
|
writeLine: writeLine, |
|
increaseIndent: function () { indent++; }, |
|
decreaseIndent: function () { indent--; }, |
|
getIndent: function () { return indent; }, |
|
getTextPos: function () { return output.length; }, |
|
getLine: function () { return lineCount + 1; }, |
|
getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, |
|
getText: function () { return output; }, |
|
reset: reset |
|
}; |
|
} |
|
ts.createTextWriter = createTextWriter; |
|
/** |
|
* Resolves a local path to a path which is absolute to the base of the emit |
|
*/ |
|
function getExternalModuleNameFromPath(host, fileName) { |
|
var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; |
|
var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); |
|
var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); |
|
var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); |
|
return ts.removeFileExtension(relativePath); |
|
} |
|
ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; |
|
function getOwnEmitOutputFilePath(sourceFile, host, extension) { |
|
var compilerOptions = host.getCompilerOptions(); |
|
var emitOutputFilePathWithoutExtension; |
|
if (compilerOptions.outDir) { |
|
emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); |
|
} |
|
else { |
|
emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); |
|
} |
|
return emitOutputFilePathWithoutExtension + extension; |
|
} |
|
ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; |
|
function getEmitScriptTarget(compilerOptions) { |
|
return compilerOptions.target || 0 /* ES3 */; |
|
} |
|
ts.getEmitScriptTarget = getEmitScriptTarget; |
|
function getEmitModuleKind(compilerOptions) { |
|
return typeof compilerOptions.module === "number" ? |
|
compilerOptions.module : |
|
getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? 5 /* ES6 */ : 1 /* CommonJS */; |
|
} |
|
ts.getEmitModuleKind = getEmitModuleKind; |
|
function forEachExpectedEmitFile(host, action, targetSourceFile) { |
|
var options = host.getCompilerOptions(); |
|
// Emit on each source file |
|
if (options.outFile || options.out) { |
|
onBundledEmit(host); |
|
} |
|
else { |
|
var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; |
|
for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { |
|
var sourceFile = sourceFiles_1[_i]; |
|
if (!isDeclarationFile(sourceFile)) { |
|
onSingleFileEmit(host, sourceFile); |
|
} |
|
} |
|
} |
|
function onSingleFileEmit(host, sourceFile) { |
|
// JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. |
|
// So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. |
|
// For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve |
|
var extension = ".js"; |
|
if (options.jsx === 1 /* Preserve */) { |
|
if (isSourceFileJavaScript(sourceFile)) { |
|
if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { |
|
extension = ".jsx"; |
|
} |
|
} |
|
else if (sourceFile.languageVariant === 1 /* JSX */) { |
|
// TypeScript source file preserving JSX syntax |
|
extension = ".jsx"; |
|
} |
|
} |
|
var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); |
|
var emitFileNames = { |
|
jsFilePath: jsFilePath, |
|
sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), |
|
declarationFilePath: !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitFilePath(jsFilePath, options) : undefined |
|
}; |
|
action(emitFileNames, [sourceFile], /*isBundledEmit*/ false); |
|
} |
|
function onBundledEmit(host) { |
|
// Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified |
|
var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && |
|
(!isExternalModule(sourceFile) || |
|
(getEmitModuleKind(options) && isExternalModule(sourceFile))); }); // module that can emit - note falsy value from getEmitModuleKind means the module kind that shouldn't be emitted |
|
if (bundledSources.length) { |
|
var jsFilePath = options.outFile || options.out; |
|
var emitFileNames = { |
|
jsFilePath: jsFilePath, |
|
sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), |
|
declarationFilePath: getDeclarationEmitFilePath(jsFilePath, options) |
|
}; |
|
action(emitFileNames, bundledSources, /*isBundledEmit*/ true); |
|
} |
|
} |
|
function getSourceMapFilePath(jsFilePath, options) { |
|
return options.sourceMap ? jsFilePath + ".map" : undefined; |
|
} |
|
function getDeclarationEmitFilePath(jsFilePath, options) { |
|
return options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; |
|
} |
|
} |
|
ts.forEachExpectedEmitFile = forEachExpectedEmitFile; |
|
function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { |
|
var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); |
|
sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), ""); |
|
return ts.combinePaths(newDirPath, sourceFilePath); |
|
} |
|
ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; |
|
function writeFile(host, diagnostics, fileName, data, writeByteOrderMark) { |
|
host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { |
|
diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); |
|
}); |
|
} |
|
ts.writeFile = writeFile; |
|
function getLineOfLocalPosition(currentSourceFile, pos) { |
|
return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; |
|
} |
|
ts.getLineOfLocalPosition = getLineOfLocalPosition; |
|
function getLineOfLocalPositionFromLineMap(lineMap, pos) { |
|
return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; |
|
} |
|
ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; |
|
function getFirstConstructorWithBody(node) { |
|
return ts.forEach(node.members, function (member) { |
|
if (member.kind === 145 /* Constructor */ && nodeIsPresent(member.body)) { |
|
return member; |
|
} |
|
}); |
|
} |
|
ts.getFirstConstructorWithBody = getFirstConstructorWithBody; |
|
function getSetAccessorTypeAnnotationNode(accessor) { |
|
return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; |
|
} |
|
ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; |
|
function getAllAccessorDeclarations(declarations, accessor) { |
|
var firstAccessor; |
|
var secondAccessor; |
|
var getAccessor; |
|
var setAccessor; |
|
if (hasDynamicName(accessor)) { |
|
firstAccessor = accessor; |
|
if (accessor.kind === 146 /* GetAccessor */) { |
|
getAccessor = accessor; |
|
} |
|
else if (accessor.kind === 147 /* SetAccessor */) { |
|
setAccessor = accessor; |
|
} |
|
else { |
|
ts.Debug.fail("Accessor has wrong kind"); |
|
} |
|
} |
|
else { |
|
ts.forEach(declarations, function (member) { |
|
if ((member.kind === 146 /* GetAccessor */ || member.kind === 147 /* SetAccessor */) |
|
&& (member.flags & 64 /* Static */) === (accessor.flags & 64 /* Static */)) { |
|
var memberName = getPropertyNameForPropertyNameNode(member.name); |
|
var accessorName = getPropertyNameForPropertyNameNode(accessor.name); |
|
if (memberName === accessorName) { |
|
if (!firstAccessor) { |
|
firstAccessor = member; |
|
} |
|
else if (!secondAccessor) { |
|
secondAccessor = member; |
|
} |
|
if (member.kind === 146 /* GetAccessor */ && !getAccessor) { |
|
getAccessor = member; |
|
} |
|
if (member.kind === 147 /* SetAccessor */ && !setAccessor) { |
|
setAccessor = member; |
|
} |
|
} |
|
} |
|
}); |
|
} |
|
return { |
|
firstAccessor: firstAccessor, |
|
secondAccessor: secondAccessor, |
|
getAccessor: getAccessor, |
|
setAccessor: setAccessor |
|
}; |
|
} |
|
ts.getAllAccessorDeclarations = getAllAccessorDeclarations; |
|
function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { |
|
// If the leading comments start on different line than the start of node, write new line |
|
if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && |
|
getLineOfLocalPositionFromLineMap(lineMap, node.pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { |
|
writer.writeLine(); |
|
} |
|
} |
|
ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; |
|
function emitComments(text, lineMap, writer, comments, trailingSeparator, newLine, writeComment) { |
|
var emitLeadingSpace = !trailingSeparator; |
|
ts.forEach(comments, function (comment) { |
|
if (emitLeadingSpace) { |
|
writer.write(" "); |
|
emitLeadingSpace = false; |
|
} |
|
writeComment(text, lineMap, writer, comment, newLine); |
|
if (comment.hasTrailingNewLine) { |
|
writer.writeLine(); |
|
} |
|
else if (trailingSeparator) { |
|
writer.write(" "); |
|
} |
|
else { |
|
// Emit leading space to separate comment during next comment emit |
|
emitLeadingSpace = true; |
|
} |
|
}); |
|
} |
|
ts.emitComments = emitComments; |
|
/** |
|
* Detached comment is a comment at the top of file or function body that is separated from |
|
* the next statement by space. |
|
*/ |
|
function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { |
|
var leadingComments; |
|
var currentDetachedCommentInfo; |
|
if (removeComments) { |
|
// removeComments is true, only reserve pinned comment at the top of file |
|
// For example: |
|
// /*! Pinned Comment */ |
|
// |
|
// var x = 10; |
|
if (node.pos === 0) { |
|
leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); |
|
} |
|
} |
|
else { |
|
// removeComments is false, just get detached as normal and bypass the process to filter comment |
|
leadingComments = ts.getLeadingCommentRanges(text, node.pos); |
|
} |
|
if (leadingComments) { |
|
var detachedComments = []; |
|
var lastComment = void 0; |
|
for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { |
|
var comment = leadingComments_1[_i]; |
|
if (lastComment) { |
|
var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); |
|
var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); |
|
if (commentLine >= lastCommentLine + 2) { |
|
// There was a blank line between the last comment and this comment. This |
|
// comment is not part of the copyright comments. Return what we have so |
|
// far. |
|
break; |
|
} |
|
} |
|
detachedComments.push(comment); |
|
lastComment = comment; |
|
} |
|
if (detachedComments.length) { |
|
// All comments look like they could have been part of the copyright header. Make |
|
// sure there is at least one blank line between it and the node. If not, it's not |
|
// a copyright header. |
|
var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); |
|
var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); |
|
if (nodeLine >= lastCommentLine + 2) { |
|
// Valid detachedComments |
|
emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); |
|
emitComments(text, lineMap, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); |
|
currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; |
|
} |
|
} |
|
} |
|
return currentDetachedCommentInfo; |
|
function isPinnedComment(comment) { |
|
return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && |
|
text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; |
|
} |
|
} |
|
ts.emitDetachedComments = emitDetachedComments; |
|
function writeCommentRange(text, lineMap, writer, comment, newLine) { |
|
if (text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { |
|
var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, comment.pos); |
|
var lineCount = lineMap.length; |
|
var firstCommentLineIndent = void 0; |
|
for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { |
|
var nextLineStart = (currentLine + 1) === lineCount |
|
? text.length + 1 |
|
: lineMap[currentLine + 1]; |
|
if (pos !== comment.pos) { |
|
// If we are not emitting first line, we need to write the spaces to adjust the alignment |
|
if (firstCommentLineIndent === undefined) { |
|
firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], comment.pos); |
|
} |
|
// These are number of spaces writer is going to write at current indent |
|
var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); |
|
// Number of spaces we want to be writing |
|
// eg: Assume writer indent |
|
// module m { |
|
// /* starts at character 9 this is line 1 |
|
// * starts at character pos 4 line --1 = 8 - 8 + 3 |
|
// More left indented comment */ --2 = 8 - 8 + 2 |
|
// class c { } |
|
// } |
|
// module m { |
|
// /* this is line 1 -- Assume current writer indent 8 |
|
// * line --3 = 8 - 4 + 5 |
|
// More right indented comment */ --4 = 8 - 4 + 11 |
|
// class c { } |
|
// } |
|
var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); |
|
if (spacesToEmit > 0) { |
|
var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); |
|
var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); |
|
// Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces |
|
writer.rawWrite(indentSizeSpaceString); |
|
// Emit the single spaces (in eg: 1: 3 spaces, 2: 2 spaces, 3: 1 space, 4: 3 spaces) |
|
while (numberOfSingleSpacesToEmit) { |
|
writer.rawWrite(" "); |
|
numberOfSingleSpacesToEmit--; |
|
} |
|
} |
|
else { |
|
// No spaces to emit write empty string |
|
writer.rawWrite(""); |
|
} |
|
} |
|
// Write the comment line text |
|
writeTrimmedCurrentLine(text, comment, writer, newLine, pos, nextLineStart); |
|
pos = nextLineStart; |
|
} |
|
} |
|
else { |
|
// Single line comment of style //.... |
|
writer.write(text.substring(comment.pos, comment.end)); |
|
} |
|
} |
|
ts.writeCommentRange = writeCommentRange; |
|
function writeTrimmedCurrentLine(text, comment, writer, newLine, pos, nextLineStart) { |
|
var end = Math.min(comment.end, nextLineStart - 1); |
|
var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); |
|
if (currentLineText) { |
|
// trimmed forward and ending spaces text |
|
writer.write(currentLineText); |
|
if (end !== comment.end) { |
|
writer.writeLine(); |
|
} |
|
} |
|
else { |
|
// Empty string - make sure we write empty line |
|
writer.writeLiteral(newLine); |
|
} |
|
} |
|
function calculateIndent(text, pos, end) { |
|
var currentLineIndent = 0; |
|
for (; pos < end && ts.isWhiteSpace(text.charCodeAt(pos)); pos++) { |
|
if (text.charCodeAt(pos) === 9 /* tab */) { |
|
// Tabs = TabSize = indent size and go to next tabStop |
|
currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); |
|
} |
|
else { |
|
// Single space |
|
currentLineIndent++; |
|
} |
|
} |
|
return currentLineIndent; |
|
} |
|
function modifierToFlag(token) { |
|
switch (token) { |
|
case 113 /* StaticKeyword */: return 64 /* Static */; |
|
case 112 /* PublicKeyword */: return 8 /* Public */; |
|
case 111 /* ProtectedKeyword */: return 32 /* Protected */; |
|
case 110 /* PrivateKeyword */: return 16 /* Private */; |
|
case 115 /* AbstractKeyword */: return 128 /* Abstract */; |
|
case 82 /* ExportKeyword */: return 2 /* Export */; |
|
case 122 /* DeclareKeyword */: return 4 /* Ambient */; |
|
case 74 /* ConstKeyword */: return 16384 /* Const */; |
|
case 77 /* DefaultKeyword */: return 512 /* Default */; |
|
case 118 /* AsyncKeyword */: return 256 /* Async */; |
|
} |
|
return 0; |
|
} |
|
ts.modifierToFlag = modifierToFlag; |
|
function isLeftHandSideExpression(expr) { |
|
if (expr) { |
|
switch (expr.kind) { |
|
case 169 /* PropertyAccessExpression */: |
|
case 170 /* ElementAccessExpression */: |
|
case 172 /* NewExpression */: |
|
case 171 /* CallExpression */: |
|
case 236 /* JsxElement */: |
|
case 237 /* JsxSelfClosingElement */: |
|
case 173 /* TaggedTemplateExpression */: |
|
case 167 /* ArrayLiteralExpression */: |
|
case 175 /* ParenthesizedExpression */: |
|
case 168 /* ObjectLiteralExpression */: |
|
case 189 /* ClassExpression */: |
|
case 176 /* FunctionExpression */: |
|
case 69 /* Identifier */: |
|
case 10 /* RegularExpressionLiteral */: |
|
case 8 /* NumericLiteral */: |
|
case 9 /* StringLiteral */: |
|
case 11 /* NoSubstitutionTemplateLiteral */: |
|
case 186 /* TemplateExpression */: |
|
case 84 /* FalseKeyword */: |
|
case 93 /* NullKeyword */: |
|
case 97 /* ThisKeyword */: |
|
case 99 /* TrueKeyword */: |
|
case 95 /* SuperKeyword */: |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
ts.isLeftHandSideExpression = isLeftHandSideExpression; |
|
function isAssignmentOperator(token) { |
|
return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; |
|
} |
|
ts.isAssignmentOperator = isAssignmentOperator; |
|
function isExpressionWithTypeArgumentsInClassExtendsClause(node) { |
|
return node.kind === 191 /* ExpressionWithTypeArguments */ && |
|
node.parent.token === 83 /* ExtendsKeyword */ && |
|
isClassLike(node.parent.parent); |
|
} |
|
ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; |
|
// Returns false if this heritage clause element's expression contains something unsupported |
|
// (i.e. not a name or dotted name). |
|
function isSupportedExpressionWithTypeArguments(node) { |
|
return isSupportedExpressionWithTypeArgumentsRest(node.expression); |
|
} |
|
ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; |
|
function isSupportedExpressionWithTypeArgumentsRest(node) { |
|
if (node.kind === 69 /* Identifier */) { |
|
return true; |
|
} |
|
else if (isPropertyAccessExpression(node)) { |
|
return isSupportedExpressionWithTypeArgumentsRest(node.expression); |
|
} |
|
else { |
|
return false; |
|
} |
|
} |
|
function isRightSideOfQualifiedNameOrPropertyAccess(node) { |
|
return (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node) || |
|
(node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node); |
|
} |
|
ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; |
|
function isEmptyObjectLiteralOrArrayLiteral(expression) { |
|
var kind = expression.kind; |
|
if (kind === 168 /* ObjectLiteralExpression */) { |
|
return expression.properties.length === 0; |
|
} |
|
if (kind === 167 /* ArrayLiteralExpression */) { |
|
return expression.elements.length === 0; |
|
} |
|
return false; |
|
} |
|
ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; |
|
function getLocalSymbolForExportDefault(symbol) { |
|
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; |
|
} |
|
ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; |
|
function hasJavaScriptFileExtension(fileName) { |
|
return ts.forEach(ts.supportedJavascriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); |
|
} |
|
ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; |
|
function hasTypeScriptFileExtension(fileName) { |
|
return ts.forEach(ts.supportedTypeScriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); |
|
} |
|
ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; |
|
/** |
|
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences |
|
* representing the UTF-8 encoding of the character, and return the expanded char code list. |
|
*/ |
|
function getExpandedCharCodes(input) { |
|
var output = []; |
|
var length = input.length; |
|
for (var i = 0; i < length; i++) { |
|
var charCode = input.charCodeAt(i); |
|
// handel utf8 |
|
if (charCode < 0x80) { |
|
output.push(charCode); |
|
} |
|
else if (charCode < 0x800) { |
|
output.push((charCode >> 6) | 192); |
|
output.push((charCode & 63) | 128); |
|
} |
|
else if (charCode < 0x10000) { |
|
output.push((charCode >> 12) | 224); |
|
output.push(((charCode >> 6) & 63) | 128); |
|
output.push((charCode & 63) | 128); |
|
} |
|
else if (charCode < 0x20000) { |
|
output.push((charCode >> 18) | 240); |
|
output.push(((charCode >> 12) & 63) | 128); |
|
output.push(((charCode >> 6) & 63) | 128); |
|
output.push((charCode & 63) | 128); |
|
} |
|
else { |
|
ts.Debug.assert(false, "Unexpected code point"); |
|
} |
|
} |
|
return output; |
|
} |
|
/** |
|
* Serialize an object graph into a JSON string. This is intended only for use on an acyclic graph |
|
* as the fallback implementation does not check for circular references by default. |
|
*/ |
|
ts.stringify = typeof JSON !== "undefined" && JSON.stringify |
|
? JSON.stringify |
|
: stringifyFallback; |
|
/** |
|
* Serialize an object graph into a JSON string. |
|
*/ |
|
function stringifyFallback(value) { |
|
// JSON.stringify returns `undefined` here, instead of the string "undefined". |
|
return value === undefined ? undefined : stringifyValue(value); |
|
} |
|
function stringifyValue(value) { |
|
return typeof value === "string" ? "\"" + escapeString(value) + "\"" |
|
: typeof value === "number" ? isFinite(value) ? String(value) : "null" |
|
: typeof value === "boolean" ? value ? "true" : "false" |
|
: typeof value === "object" && value ? ts.isArray(value) ? cycleCheck(stringifyArray, value) : cycleCheck(stringifyObject, value) |
|
: "null"; |
|
} |
|
function cycleCheck(cb, value) { |
|
ts.Debug.assert(!value.hasOwnProperty("__cycle"), "Converting circular structure to JSON"); |
|
value.__cycle = true; |
|
var result = cb(value); |
|
delete value.__cycle; |
|
return result; |
|
} |
|
function stringifyArray(value) { |
|
return "[" + ts.reduceLeft(value, stringifyElement, "") + "]"; |
|
} |
|
function stringifyElement(memo, value) { |
|
return (memo ? memo + "," : memo) + stringifyValue(value); |
|
} |
|
function stringifyObject(value) { |
|
return "{" + ts.reduceProperties(value, stringifyProperty, "") + "}"; |
|
} |
|
function stringifyProperty(memo, value, key) { |
|
return value === undefined || typeof value === "function" || key === "__cycle" ? memo |
|
: (memo ? memo + "," : memo) + ("\"" + escapeString(key) + "\":" + stringifyValue(value)); |
|
} |
|
var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; |
|
/** |
|
* Converts a string to a base-64 encoded ASCII string. |
|
*/ |
|
function convertToBase64(input) { |
|
var result = ""; |
|
var charCodes = getExpandedCharCodes(input); |
|
var i = 0; |
|
var length = charCodes.length; |
|
var byte1, byte2, byte3, byte4; |
|
while (i < length) { |
|
// Convert every 6-bits in the input 3 character points |
|
// into a base64 digit |
|
byte1 = charCodes[i] >> 2; |
|
byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; |
|
byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; |
|
byte4 = charCodes[i + 2] & 63; |
|
// We are out of characters in the input, set the extra |
|
// digits to 64 (padding character). |
|
if (i + 1 >= length) { |
|
byte3 = byte4 = 64; |
|
} |
|
else if (i + 2 >= length) { |
|
byte4 = 64; |
|
} |
|
// Write to the ouput |
|
result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); |
|
i += 3; |
|
} |
|
return result; |
|
} |
|
ts.convertToBase64 = convertToBase64; |
|
function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { |
|
return !ts.isRootedDiskPath(absoluteOrRelativePath) |
|
? absoluteOrRelativePath |
|
: ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /* isAbsolutePathAnUrl */ false); |
|
} |
|
ts.convertToRelativePath = convertToRelativePath; |
|
var carriageReturnLineFeed = "\r\n"; |
|
var lineFeed = "\n"; |
|
function getNewLineCharacter(options) { |
|
if (options.newLine === 0 /* CarriageReturnLineFeed */) { |
|
return carriageReturnLineFeed; |
|
} |
|
else if (options.newLine === 1 /* LineFeed */) { |
|
return lineFeed; |
|
} |
|
else if (ts.sys) { |
|
return ts.sys.newLine; |
|
} |
|
return carriageReturnLineFeed; |
|
} |
|
ts.getNewLineCharacter = getNewLineCharacter; |
|
})(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; |
|
} |
|
ts.textSpanEnd = textSpanEnd; |
|
function textSpanIsEmpty(span) { |
|
return span.length === 0; |
|
} |
|
ts.textSpanIsEmpty = textSpanIsEmpty; |
|
function textSpanContainsPosition(span, position) { |
|
return position >= span.start && position < textSpanEnd(span); |
|
} |
|
ts.textSpanContainsPosition = textSpanContainsPosition; |
|
// Returns true if 'span' contains 'other'. |
|
function textSpanContainsTextSpan(span, other) { |
|
return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); |
|
} |
|
ts.textSpanContainsTextSpan = textSpanContainsTextSpan; |
|
function textSpanOverlapsWith(span, other) { |
|
var overlapStart = Math.max(span.start, other.start); |
|
var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); |
|
return overlapStart < overlapEnd; |
|
} |
|
ts.textSpanOverlapsWith = textSpanOverlapsWith; |
|
function textSpanOverlap(span1, span2) { |
|
var overlapStart = Math.max(span1.start, span2.start); |
|
var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); |
|
if (overlapStart < overlapEnd) { |
|
return createTextSpanFromBounds(overlapStart, overlapEnd); |
|
} |
|
return undefined; |
|
} |
|
ts.textSpanOverlap = textSpanOverlap; |
|
function textSpanIntersectsWithTextSpan(span, other) { |
|
return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; |
|
} |
|
ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; |
|
function textSpanIntersectsWith(span, start, length) { |
|
var end = start + length; |
|
return start <= textSpanEnd(span) && end >= span.start; |
|
} |
|
ts.textSpanIntersectsWith = textSpanIntersectsWith; |
|
function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { |
|
var end1 = start1 + length1; |
|
var end2 = start2 + length2; |
|
return start2 <= end1 && end2 >= start1; |
|
} |
|
ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; |
|
function textSpanIntersectsWithPosition(span, position) { |
|
return position <= textSpanEnd(span) && position >= span.start; |
|
} |
|
ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; |
|
function textSpanIntersection(span1, span2) { |
|
var intersectStart = Math.max(span1.start, span2.start); |
|
var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); |
|
if (intersectStart <= intersectEnd) { |
|
return createTextSpanFromBounds(intersectStart, intersectEnd); |
|
} |
|
return undefined; |
|
} |
|
ts.textSpanIntersection = textSpanIntersection; |
|
function createTextSpan(start, length) { |
|
if (start < 0) { |
|
throw new Error("start < 0"); |
|
} |
|
if (length < 0) { |
|
throw new Error("length < 0"); |
|
} |
|
return { start: start, length: length }; |
|
} |
|
ts.createTextSpan = createTextSpan; |
|
function createTextSpanFromBounds(start, end) { |
|
return createTextSpan(start, end - start); |
|
} |
|
ts.createTextSpanFromBounds = createTextSpanFromBounds; |
|
function textChangeRangeNewSpan(range) { |
|
return createTextSpan(range.span.start, range.newLength); |
|
} |
|
ts.textChangeRangeNewSpan = textChangeRangeNewSpan; |
|
function textChangeRangeIsUnchanged(range) { |
|
return textSpanIsEmpty(range.span) && range.newLength === 0; |
|
} |
|
ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; |
|
function createTextChangeRange(span, newLength) { |
|
if (newLength < 0) { |
|
throw new Error("newLength < 0"); |
|
} |
|
return { span: span, newLength: newLength }; |
|
} |
|
ts.createTextChangeRange = createTextChangeRange; |
|
ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); |
|
/** |
|
* Called to merge all the changes that occurred across several versions of a script snapshot |
|
* into a single change. i.e. if a user keeps making successive edits to a script we will |
|
* have a text change from V1 to V2, V2 to V3, ..., Vn. |
|
* |
|
* This function will then merge those changes into a single change range valid between V1 and |
|
* Vn. |
|
*/ |
|
function collapseTextChangeRangesAcrossMultipleVersions(changes) { |
|
if (changes.length === 0) { |
|
return ts.unchangedTextChangeRange; |
|
} |
|
if (changes.length === 1) { |
|
return changes[0]; |
|
} |
|
// We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd } |
|
// as it makes things much easier to reason about. |
|
var change0 = changes[0]; |
|
var oldStartN = change0.span.start; |
|
var oldEndN = textSpanEnd(change0.span); |
|
var newEndN = oldStartN + change0.newLength; |
|
for (var i = 1; i < changes.length; i++) { |
|
var nextChange = changes[i]; |
|
// Consider the following case: |
|
// i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting |
|
// at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }. |
|
// i.e. the span starting at 30 with length 30 is increased to length 40. |
|
// |
|
// 0 10 20 30 40 50 60 70 80 90 100 |
|
// ------------------------------------------------------------------------------------------------------- |
|
// | / |
|
// | /---- |
|
// T1 | /---- |
|
// | /---- |
|
// | /---- |
|
// ------------------------------------------------------------------------------------------------------- |
|
// | \ |
|
// | \ |
|
// T2 | \ |
|
// | \ |
|
// | \ |
|
// ------------------------------------------------------------------------------------------------------- |
|
// |
|
// Merging these turns out to not be too difficult. First, determining the new start of the change is trivial |
|
// it's just the min of the old and new starts. i.e.: |
|
// |
|
// 0 10 20 30 40 50 60 70 80 90 100 |
|
// ------------------------------------------------------------*------------------------------------------ |
|
// | / |
|
// | /---- |
|
// T1 | /---- |
|
// | /---- |
|
// | /---- |
|
// ----------------------------------------$-------------------$------------------------------------------ |
|
// . | \ |
|
// . | \ |
|
// T2 . | \ |
|
// . | \ |
|
// . | \ |
|
// ----------------------------------------------------------------------*-------------------------------- |
|
// |
|
// (Note the dots represent the newly inferrred start. |
|
// Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the |
|
// absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see |
|
// which if the two $'s precedes the other, and we move that one forward until they line up. in this case that |
|
// means: |
|
// |
|
// 0 10 20 30 40 50 60 70 80 90 100 |
|
// --------------------------------------------------------------------------------*---------------------- |
|
// | / |
|
// | /---- |
|
// T1 | /---- |
|
// | /---- |
|
// | /---- |
|
// ------------------------------------------------------------$------------------------------------------ |
|
// . | \ |
|
// . | \ |
|
// T2 . | \ |
|
// . | \ |
|
// . | \ |
|
// ----------------------------------------------------------------------*-------------------------------- |
|
// |
|
// In other words (in this case), we're recognizing that the second edit happened after where the first edit |
|
// ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started |
|
// that's the same as if we started at char 80 instead of 60. |
|
// |
|
// As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter |
|
// than pusing the first edit forward to match the second, we'll push the second edit forward to match the |
|
// first. |
|
// |
|
// In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange |
|
// semantics: { { start: 10, length: 70 }, newLength: 60 } |
|
// |
|
// The math then works out as follows. |
|
// If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the |
|
// final result like so: |
|
// |
|
// { |
|
// oldStart3: Min(oldStart1, oldStart2), |
|
// oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)), |
|
// newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)) |
|
// } |
|
var oldStart1 = oldStartN; |
|
var oldEnd1 = oldEndN; |
|
var newEnd1 = newEndN; |
|
var oldStart2 = nextChange.span.start; |
|
var oldEnd2 = textSpanEnd(nextChange.span); |
|
var newEnd2 = oldStart2 + nextChange.newLength; |
|
oldStartN = Math.min(oldStart1, oldStart2); |
|
oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); |
|
newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); |
|
} |
|
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); |
|
} |
|
ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; |
|
function getTypeParameterOwner(d) { |
|
if (d && d.kind === 138 /* TypeParameter */) { |
|
for (var current = d; current; current = current.parent) { |
|
if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 218 /* InterfaceDeclaration */) { |
|
return current; |
|
} |
|
} |
|
} |
|
} |
|
ts.getTypeParameterOwner = getTypeParameterOwner; |
|
function isParameterPropertyDeclaration(node) { |
|
return node.flags & 56 /* AccessibilityModifier */ && node.parent.kind === 145 /* Constructor */ && ts.isClassLike(node.parent.parent); |
|
} |
|
ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; |
|
})(ts || (ts = {})); |
|
/// <reference path="utilities.ts"/> |
|
/// <reference path="scanner.ts"/> |
|
var ts; |
|
(function (ts) { |
|
/* @internal */ ts.parseTime = 0; |
|
var NodeConstructor; |
|
var SourceFileConstructor; |
|
function createNode(kind, pos, end) { |
|
if (kind === 251 /* SourceFile */) { |
|
return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); |
|
} |
|
else { |
|
return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end); |
|
} |
|
} |
|
ts.createNode = createNode; |
|
function visitNode(cbNode, node) { |
|
if (node) { |
|
return cbNode(node); |
|
} |
|
} |
|
function visitNodeArray(cbNodes, nodes) { |
|
if (nodes) { |
|
return cbNodes(nodes); |
|
} |
|
} |
|
function visitEachNode(cbNode, nodes) { |
|
if (nodes) { |
|
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { |
|
var node = nodes_1[_i]; |
|
var result = cbNode(node); |
|
if (result) { |
|
return result; |
|
} |
|
} |
|
} |
|
} |
|
// Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes |
|
// stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, |
|
// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns |
|
// a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. |
|
function forEachChild(node, cbNode, cbNodeArray) { |
|
if (!node) { |
|
return; |
|
} |
|
// The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray |
|
// callback parameters, but that causes a closure allocation for each invocation with noticeable effects |
|
// on performance. |
|
var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; |
|
var cbNodes = cbNodeArray || cbNode; |
|
switch (node.kind) { |
|
case 136 /* QualifiedName */: |
|
return visitNode(cbNode, node.left) || |
|
visitNode(cbNode, node.right); |
|
case 138 /* TypeParameter */: |
|
return visitNode(cbNode, node.name) || |
|
visitNode(cbNode, node.constraint) || |
|
visitNode(cbNode, node.expression); |
|
case 249 /* ShorthandPropertyAssignment */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.name) || |
|
visitNode(cbNode, node.questionToken) || |
|
visitNode(cbNode, node.equalsToken) || |
|
visitNode(cbNode, node.objectAssignmentInitializer); |
|
case 139 /* Parameter */: |
|
case 142 /* PropertyDeclaration */: |
|
case 141 /* PropertySignature */: |
|
case 248 /* PropertyAssignment */: |
|
case 214 /* VariableDeclaration */: |
|
case 166 /* BindingElement */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.propertyName) || |
|
visitNode(cbNode, node.dotDotDotToken) || |
|
visitNode(cbNode, node.name) || |
|
visitNode(cbNode, node.questionToken) || |
|
visitNode(cbNode, node.type) || |
|
visitNode(cbNode, node.initializer); |
|
case 153 /* FunctionType */: |
|
case 154 /* ConstructorType */: |
|
case 148 /* CallSignature */: |
|
case 149 /* ConstructSignature */: |
|
case 150 /* IndexSignature */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNodes(cbNodes, node.typeParameters) || |
|
visitNodes(cbNodes, node.parameters) || |
|
visitNode(cbNode, node.type); |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
case 145 /* Constructor */: |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
case 176 /* FunctionExpression */: |
|
case 216 /* FunctionDeclaration */: |
|
case 177 /* ArrowFunction */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.asteriskToken) || |
|
visitNode(cbNode, node.name) || |
|
visitNode(cbNode, node.questionToken) || |
|
visitNodes(cbNodes, node.typeParameters) || |
|
visitNodes(cbNodes, node.parameters) || |
|
visitNode(cbNode, node.type) || |
|
visitNode(cbNode, node.equalsGreaterThanToken) || |
|
visitNode(cbNode, node.body); |
|
case 152 /* TypeReference */: |
|
return visitNode(cbNode, node.typeName) || |
|
visitNodes(cbNodes, node.typeArguments); |
|
case 151 /* TypePredicate */: |
|
return visitNode(cbNode, node.parameterName) || |
|
visitNode(cbNode, node.type); |
|
case 155 /* TypeQuery */: |
|
return visitNode(cbNode, node.exprName); |
|
case 156 /* TypeLiteral */: |
|
return visitNodes(cbNodes, node.members); |
|
case 157 /* ArrayType */: |
|
return visitNode(cbNode, node.elementType); |
|
case 158 /* TupleType */: |
|
return visitNodes(cbNodes, node.elementTypes); |
|
case 159 /* UnionType */: |
|
case 160 /* IntersectionType */: |
|
return visitNodes(cbNodes, node.types); |
|
case 161 /* ParenthesizedType */: |
|
return visitNode(cbNode, node.type); |
|
case 164 /* ObjectBindingPattern */: |
|
case 165 /* ArrayBindingPattern */: |
|
return visitNodes(cbNodes, node.elements); |
|
case 167 /* ArrayLiteralExpression */: |
|
return visitNodes(cbNodes, node.elements); |
|
case 168 /* ObjectLiteralExpression */: |
|
return visitNodes(cbNodes, node.properties); |
|
case 169 /* PropertyAccessExpression */: |
|
return visitNode(cbNode, node.expression) || |
|
visitNode(cbNode, node.dotToken) || |
|
visitNode(cbNode, node.name); |
|
case 170 /* ElementAccessExpression */: |
|
return visitNode(cbNode, node.expression) || |
|
visitNode(cbNode, node.argumentExpression); |
|
case 171 /* CallExpression */: |
|
case 172 /* NewExpression */: |
|
return visitNode(cbNode, node.expression) || |
|
visitNodes(cbNodes, node.typeArguments) || |
|
visitNodes(cbNodes, node.arguments); |
|
case 173 /* TaggedTemplateExpression */: |
|
return visitNode(cbNode, node.tag) || |
|
visitNode(cbNode, node.template); |
|
case 174 /* TypeAssertionExpression */: |
|
return visitNode(cbNode, node.type) || |
|
visitNode(cbNode, node.expression); |
|
case 175 /* ParenthesizedExpression */: |
|
return visitNode(cbNode, node.expression); |
|
case 178 /* DeleteExpression */: |
|
return visitNode(cbNode, node.expression); |
|
case 179 /* TypeOfExpression */: |
|
return visitNode(cbNode, node.expression); |
|
case 180 /* VoidExpression */: |
|
return visitNode(cbNode, node.expression); |
|
case 182 /* PrefixUnaryExpression */: |
|
return visitNode(cbNode, node.operand); |
|
case 187 /* YieldExpression */: |
|
return visitNode(cbNode, node.asteriskToken) || |
|
visitNode(cbNode, node.expression); |
|
case 181 /* AwaitExpression */: |
|
return visitNode(cbNode, node.expression); |
|
case 183 /* PostfixUnaryExpression */: |
|
return visitNode(cbNode, node.operand); |
|
case 184 /* BinaryExpression */: |
|
return visitNode(cbNode, node.left) || |
|
visitNode(cbNode, node.operatorToken) || |
|
visitNode(cbNode, node.right); |
|
case 192 /* AsExpression */: |
|
return visitNode(cbNode, node.expression) || |
|
visitNode(cbNode, node.type); |
|
case 185 /* ConditionalExpression */: |
|
return visitNode(cbNode, node.condition) || |
|
visitNode(cbNode, node.questionToken) || |
|
visitNode(cbNode, node.whenTrue) || |
|
visitNode(cbNode, node.colonToken) || |
|
visitNode(cbNode, node.whenFalse); |
|
case 188 /* SpreadElementExpression */: |
|
return visitNode(cbNode, node.expression); |
|
case 195 /* Block */: |
|
case 222 /* ModuleBlock */: |
|
return visitNodes(cbNodes, node.statements); |
|
case 251 /* SourceFile */: |
|
return visitNodes(cbNodes, node.statements) || |
|
visitNode(cbNode, node.endOfFileToken); |
|
case 196 /* VariableStatement */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.declarationList); |
|
case 215 /* VariableDeclarationList */: |
|
return visitNodes(cbNodes, node.declarations); |
|
case 198 /* ExpressionStatement */: |
|
return visitNode(cbNode, node.expression); |
|
case 199 /* IfStatement */: |
|
return visitNode(cbNode, node.expression) || |
|
visitNode(cbNode, node.thenStatement) || |
|
visitNode(cbNode, node.elseStatement); |
|
case 200 /* DoStatement */: |
|
return visitNode(cbNode, node.statement) || |
|
visitNode(cbNode, node.expression); |
|
case 201 /* WhileStatement */: |
|
return visitNode(cbNode, node.expression) || |
|
visitNode(cbNode, node.statement); |
|
case 202 /* ForStatement */: |
|
return visitNode(cbNode, node.initializer) || |
|
visitNode(cbNode, node.condition) || |
|
visitNode(cbNode, node.incrementor) || |
|
visitNode(cbNode, node.statement); |
|
case 203 /* ForInStatement */: |
|
return visitNode(cbNode, node.initializer) || |
|
visitNode(cbNode, node.expression) || |
|
visitNode(cbNode, node.statement); |
|
case 204 /* ForOfStatement */: |
|
return visitNode(cbNode, node.initializer) || |
|
visitNode(cbNode, node.expression) || |
|
visitNode(cbNode, node.statement); |
|
case 205 /* ContinueStatement */: |
|
case 206 /* BreakStatement */: |
|
return visitNode(cbNode, node.label); |
|
case 207 /* ReturnStatement */: |
|
return visitNode(cbNode, node.expression); |
|
case 208 /* WithStatement */: |
|
return visitNode(cbNode, node.expression) || |
|
visitNode(cbNode, node.statement); |
|
case 209 /* SwitchStatement */: |
|
return visitNode(cbNode, node.expression) || |
|
visitNode(cbNode, node.caseBlock); |
|
case 223 /* CaseBlock */: |
|
return visitNodes(cbNodes, node.clauses); |
|
case 244 /* CaseClause */: |
|
return visitNode(cbNode, node.expression) || |
|
visitNodes(cbNodes, node.statements); |
|
case 245 /* DefaultClause */: |
|
return visitNodes(cbNodes, node.statements); |
|
case 210 /* LabeledStatement */: |
|
return visitNode(cbNode, node.label) || |
|
visitNode(cbNode, node.statement); |
|
case 211 /* ThrowStatement */: |
|
return visitNode(cbNode, node.expression); |
|
case 212 /* TryStatement */: |
|
return visitNode(cbNode, node.tryBlock) || |
|
visitNode(cbNode, node.catchClause) || |
|
visitNode(cbNode, node.finallyBlock); |
|
case 247 /* CatchClause */: |
|
return visitNode(cbNode, node.variableDeclaration) || |
|
visitNode(cbNode, node.block); |
|
case 140 /* Decorator */: |
|
return visitNode(cbNode, node.expression); |
|
case 217 /* ClassDeclaration */: |
|
case 189 /* ClassExpression */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.name) || |
|
visitNodes(cbNodes, node.typeParameters) || |
|
visitNodes(cbNodes, node.heritageClauses) || |
|
visitNodes(cbNodes, node.members); |
|
case 218 /* InterfaceDeclaration */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.name) || |
|
visitNodes(cbNodes, node.typeParameters) || |
|
visitNodes(cbNodes, node.heritageClauses) || |
|
visitNodes(cbNodes, node.members); |
|
case 219 /* TypeAliasDeclaration */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.name) || |
|
visitNodes(cbNodes, node.typeParameters) || |
|
visitNode(cbNode, node.type); |
|
case 220 /* EnumDeclaration */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.name) || |
|
visitNodes(cbNodes, node.members); |
|
case 250 /* EnumMember */: |
|
return visitNode(cbNode, node.name) || |
|
visitNode(cbNode, node.initializer); |
|
case 221 /* ModuleDeclaration */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.name) || |
|
visitNode(cbNode, node.body); |
|
case 224 /* ImportEqualsDeclaration */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.name) || |
|
visitNode(cbNode, node.moduleReference); |
|
case 225 /* ImportDeclaration */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.importClause) || |
|
visitNode(cbNode, node.moduleSpecifier); |
|
case 226 /* ImportClause */: |
|
return visitNode(cbNode, node.name) || |
|
visitNode(cbNode, node.namedBindings); |
|
case 227 /* NamespaceImport */: |
|
return visitNode(cbNode, node.name); |
|
case 228 /* NamedImports */: |
|
case 232 /* NamedExports */: |
|
return visitNodes(cbNodes, node.elements); |
|
case 231 /* ExportDeclaration */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.exportClause) || |
|
visitNode(cbNode, node.moduleSpecifier); |
|
case 229 /* ImportSpecifier */: |
|
case 233 /* ExportSpecifier */: |
|
return visitNode(cbNode, node.propertyName) || |
|
visitNode(cbNode, node.name); |
|
case 230 /* ExportAssignment */: |
|
return visitNodes(cbNodes, node.decorators) || |
|
visitNodes(cbNodes, node.modifiers) || |
|
visitNode(cbNode, node.expression); |
|
case 186 /* TemplateExpression */: |
|
return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); |
|
case 193 /* TemplateSpan */: |
|
return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); |
|
case 137 /* ComputedPropertyName */: |
|
return visitNode(cbNode, node.expression); |
|
case 246 /* HeritageClause */: |
|
return visitNodes(cbNodes, node.types); |
|
case 191 /* ExpressionWithTypeArguments */: |
|
return visitNode(cbNode, node.expression) || |
|
visitNodes(cbNodes, node.typeArguments); |
|
case 235 /* ExternalModuleReference */: |
|
return visitNode(cbNode, node.expression); |
|
case 234 /* MissingDeclaration */: |
|
return visitNodes(cbNodes, node.decorators); |
|
case 236 /* JsxElement */: |
|
return visitNode(cbNode, node.openingElement) || |
|
visitNodes(cbNodes, node.children) || |
|
visitNode(cbNode, node.closingElement); |
|
case 237 /* JsxSelfClosingElement */: |
|
case 238 /* JsxOpeningElement */: |
|
return visitNode(cbNode, node.tagName) || |
|
visitNodes(cbNodes, node.attributes); |
|
case 241 /* JsxAttribute */: |
|
return visitNode(cbNode, node.name) || |
|
visitNode(cbNode, node.initializer); |
|
case 242 /* JsxSpreadAttribute */: |
|
return visitNode(cbNode, node.expression); |
|
case 243 /* JsxExpression */: |
|
return visitNode(cbNode, node.expression); |
|
case 240 /* JsxClosingElement */: |
|
return visitNode(cbNode, node.tagName); |
|
case 252 /* JSDocTypeExpression */: |
|
return visitNode(cbNode, node.type); |
|
case 256 /* JSDocUnionType */: |
|
return visitNodes(cbNodes, node.types); |
|
case 257 /* JSDocTupleType */: |
|
return visitNodes(cbNodes, node.types); |
|
case 255 /* JSDocArrayType */: |
|
return visitNode(cbNode, node.elementType); |
|
case 259 /* JSDocNonNullableType */: |
|
return visitNode(cbNode, node.type); |
|
case 258 /* JSDocNullableType */: |
|
return visitNode(cbNode, node.type); |
|
case 260 /* JSDocRecordType */: |
|
return visitNodes(cbNodes, node.members); |
|
case 262 /* JSDocTypeReference */: |
|
return visitNode(cbNode, node.name) || |
|
visitNodes(cbNodes, node.typeArguments); |
|
case 263 /* JSDocOptionalType */: |
|
return visitNode(cbNode, node.type); |
|
case 264 /* JSDocFunctionType */: |
|
return visitNodes(cbNodes, node.parameters) || |
|
visitNode(cbNode, node.type); |
|
case 265 /* JSDocVariadicType */: |
|
return visitNode(cbNode, node.type); |
|
case 266 /* JSDocConstructorType */: |
|
return visitNode(cbNode, node.type); |
|
case 267 /* JSDocThisType */: |
|
return visitNode(cbNode, node.type); |
|
case 261 /* JSDocRecordMember */: |
|
return visitNode(cbNode, node.name) || |
|
visitNode(cbNode, node.type); |
|
case 268 /* JSDocComment */: |
|
return visitNodes(cbNodes, node.tags); |
|
case 270 /* JSDocParameterTag */: |
|
return visitNode(cbNode, node.preParameterName) || |
|
visitNode(cbNode, node.typeExpression) || |
|
visitNode(cbNode, node.postParameterName); |
|
case 271 /* JSDocReturnTag */: |
|
return visitNode(cbNode, node.typeExpression); |
|
case 272 /* JSDocTypeTag */: |
|
return visitNode(cbNode, node.typeExpression); |
|
case 273 /* JSDocTemplateTag */: |
|
return visitNodes(cbNodes, node.typeParameters); |
|
} |
|
} |
|
ts.forEachChild = forEachChild; |
|
function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { |
|
if (setParentNodes === void 0) { setParentNodes = false; } |
|
var start = new Date().getTime(); |
|
var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); |
|
ts.parseTime += new Date().getTime() - start; |
|
return result; |
|
} |
|
ts.createSourceFile = createSourceFile; |
|
// Produces a new SourceFile for the 'newText' provided. The 'textChangeRange' parameter |
|
// indicates what changed between the 'text' that this SourceFile has and the 'newText'. |
|
// The SourceFile will be created with the compiler attempting to reuse as many nodes from |
|
// this file as possible. |
|
// |
|
// Note: this function mutates nodes from this SourceFile. That means any existing nodes |
|
// from this SourceFile that are being held onto may change as a result (including |
|
// becoming detached from any SourceFile). It is recommended that this SourceFile not |
|
// be used once 'update' is called on it. |
|
function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { |
|
return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); |
|
} |
|
ts.updateSourceFile = updateSourceFile; |
|
/* @internal */ |
|
function parseIsolatedJSDocComment(content, start, length) { |
|
return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); |
|
} |
|
ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment; |
|
/* @internal */ |
|
// Exposed only for testing. |
|
function parseJSDocTypeExpressionForTests(content, start, length) { |
|
return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length); |
|
} |
|
ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; |
|
// Implement the parser as a singleton module. We do this for perf reasons because creating |
|
// parser instances can actually be expensive enough to impact us on projects with many source |
|
// files. |
|
var Parser; |
|
(function (Parser) { |
|
// Share a single scanner across all calls to parse a source file. This helps speed things |
|
// up by avoiding the cost of creating/compiling scanners over and over again. |
|
var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); |
|
var disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; |
|
// capture constructors in 'initializeState' to avoid null checks |
|
var NodeConstructor; |
|
var SourceFileConstructor; |
|
var sourceFile; |
|
var parseDiagnostics; |
|
var syntaxCursor; |
|
var token; |
|
var sourceText; |
|
var nodeCount; |
|
var identifiers; |
|
var identifierCount; |
|
var parsingContext; |
|
// Flags that dictate what parsing context we're in. For example: |
|
// Whether or not we are in strict parsing mode. All that changes in strict parsing mode is |
|
// that some tokens that would be considered identifiers may be considered keywords. |
|
// |
|
// When adding more parser context flags, consider which is the more common case that the |
|
// flag will be in. This should be the 'false' state for that flag. The reason for this is |
|
// that we don't store data in our nodes unless the value is in the *non-default* state. So, |
|
// for example, more often than code 'allows-in' (or doesn't 'disallow-in'). We opt for |
|
// 'disallow-in' set to 'false'. Otherwise, if we had 'allowsIn' set to 'true', then almost |
|
// all nodes would need extra state on them to store this info. |
|
// |
|
// Note: 'allowIn' and 'allowYield' track 1:1 with the [in] and [yield] concepts in the ES6 |
|
// grammar specification. |
|
// |
|
// An important thing about these context concepts. By default they are effectively inherited |
|
// while parsing through every grammar production. i.e. if you don't change them, then when |
|
// you parse a sub-production, it will have the same context values as the parent production. |
|
// This is great most of the time. After all, consider all the 'expression' grammar productions |
|
// and how nearly all of them pass along the 'in' and 'yield' context values: |
|
// |
|
// EqualityExpression[In, Yield] : |
|
// RelationalExpression[?In, ?Yield] |
|
// EqualityExpression[?In, ?Yield] == RelationalExpression[?In, ?Yield] |
|
// EqualityExpression[?In, ?Yield] != RelationalExpression[?In, ?Yield] |
|
// EqualityExpression[?In, ?Yield] === RelationalExpression[?In, ?Yield] |
|
// EqualityExpression[?In, ?Yield] !== RelationalExpression[?In, ?Yield] |
|
// |
|
// Where you have to be careful is then understanding what the points are in the grammar |
|
// where the values are *not* passed along. For example: |
|
// |
|
// SingleNameBinding[Yield,GeneratorParameter] |
|
// [+GeneratorParameter]BindingIdentifier[Yield] Initializer[In]opt |
|
// [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt |
|
// |
|
// Here this is saying that if the GeneratorParameter context flag is set, that we should |
|
// explicitly set the 'yield' context flag to false before calling into the BindingIdentifier |
|
// and we should explicitly unset the 'yield' context flag before calling into the Initializer. |
|
// production. Conversely, if the GeneratorParameter context flag is not set, then we |
|
// should leave the 'yield' context flag alone. |
|
// |
|
// Getting this all correct is tricky and requires careful reading of the grammar to |
|
// understand when these values should be changed versus when they should be inherited. |
|
// |
|
// Note: it should not be necessary to save/restore these flags during speculative/lookahead |
|
// parsing. These context flags are naturally stored and restored through normal recursive |
|
// descent parsing and unwinding. |
|
var contextFlags; |
|
// Whether or not we've had a parse error since creating the last AST node. If we have |
|
// encountered an error, it will be stored on the next AST node we create. Parse errors |
|
// can be broken down into three categories: |
|
// |
|
// 1) An error that occurred during scanning. For example, an unterminated literal, or a |
|
// character that was completely not understood. |
|
// |
|
// 2) A token was expected, but was not present. This type of error is commonly produced |
|
// by the 'parseExpected' function. |
|
// |
|
// 3) A token was present that no parsing function was able to consume. This type of error |
|
// only occurs in the 'abortParsingListOrMoveToNextToken' function when the parser |
|
// decides to skip the token. |
|
// |
|
// In all of these cases, we want to mark the next node as having had an error before it. |
|
// With this mark, we can know in incremental settings if this node can be reused, or if |
|
// we have to reparse it. If we don't keep this information around, we may just reuse the |
|
// node. in that event we would then not produce the same errors as we did before, causing |
|
// significant confusion problems. |
|
// |
|
// Note: it is necessary that this value be saved/restored during speculative/lookahead |
|
// parsing. During lookahead parsing, we will often create a node. That node will have |
|
// this value attached, and then this value will be set back to 'false'. If we decide to |
|
// rewind, we must get back to the same value we had prior to the lookahead. |
|
// |
|
// Note: any errors at the end of the file that do not precede a regular node, should get |
|
// attached to the EOF token. |
|
var parseErrorBeforeNextFinishedNode = false; |
|
function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { |
|
scriptKind = ts.ensureScriptKind(fileName, scriptKind); |
|
initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); |
|
var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); |
|
clearState(); |
|
return result; |
|
} |
|
Parser.parseSourceFile = parseSourceFile; |
|
function getLanguageVariant(scriptKind) { |
|
// .tsx and .jsx files are treated as jsx language variant. |
|
return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ ? 1 /* JSX */ : 0 /* Standard */; |
|
} |
|
function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { |
|
NodeConstructor = ts.objectAllocator.getNodeConstructor(); |
|
SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor(); |
|
sourceText = _sourceText; |
|
syntaxCursor = _syntaxCursor; |
|
parseDiagnostics = []; |
|
parsingContext = 0; |
|
identifiers = {}; |
|
identifierCount = 0; |
|
nodeCount = 0; |
|
contextFlags = scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */ ? 32 /* JavaScriptFile */ : 0 /* None */; |
|
parseErrorBeforeNextFinishedNode = false; |
|
// Initialize and prime the scanner before parsing the source elements. |
|
scanner.setText(sourceText); |
|
scanner.setOnError(scanError); |
|
scanner.setScriptTarget(languageVersion); |
|
scanner.setLanguageVariant(getLanguageVariant(scriptKind)); |
|
} |
|
function clearState() { |
|
// Clear out the text the scanner is pointing at, so it doesn't keep anything alive unnecessarily. |
|
scanner.setText(""); |
|
scanner.setOnError(undefined); |
|
// Clear any data. We don't want to accidently hold onto it for too long. |
|
parseDiagnostics = undefined; |
|
sourceFile = undefined; |
|
identifiers = undefined; |
|
syntaxCursor = undefined; |
|
sourceText = undefined; |
|
} |
|
function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { |
|
sourceFile = createSourceFile(fileName, languageVersion, scriptKind); |
|
if (contextFlags & 32 /* JavaScriptFile */) { |
|
sourceFile.parserContextFlags = 32 /* JavaScriptFile */; |
|
} |
|
// Prime the scanner. |
|
token = nextToken(); |
|
processReferenceComments(sourceFile); |
|
sourceFile.statements = parseList(0 /* SourceElements */, parseStatement); |
|
ts.Debug.assert(token === 1 /* EndOfFileToken */); |
|
sourceFile.endOfFileToken = parseTokenNode(); |
|
setExternalModuleIndicator(sourceFile); |
|
sourceFile.nodeCount = nodeCount; |
|
sourceFile.identifierCount = identifierCount; |
|
sourceFile.identifiers = identifiers; |
|
sourceFile.parseDiagnostics = parseDiagnostics; |
|
if (setParentNodes) { |
|
fixupParentReferences(sourceFile); |
|
} |
|
return sourceFile; |
|
} |
|
function addJSDocComment(node) { |
|
if (contextFlags & 32 /* JavaScriptFile */) { |
|
var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); |
|
if (comments) { |
|
for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { |
|
var comment = comments_1[_i]; |
|
var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); |
|
if (jsDocComment) { |
|
node.jsDocComment = jsDocComment; |
|
} |
|
} |
|
} |
|
} |
|
return node; |
|
} |
|
function fixupParentReferences(sourceFile) { |
|
// normally parent references are set during binding. However, for clients that only need |
|
// a syntax tree, and no semantic features, then the binding process is an unnecessary |
|
// overhead. This functions allows us to set all the parents, without all the expense of |
|
// binding. |
|
var parent = sourceFile; |
|
forEachChild(sourceFile, visitNode); |
|
return; |
|
function visitNode(n) { |
|
// walk down setting parents that differ from the parent we think it should be. This |
|
// allows us to quickly bail out of setting parents for subtrees during incremental |
|
// parsing |
|
if (n.parent !== parent) { |
|
n.parent = parent; |
|
var saveParent = parent; |
|
parent = n; |
|
forEachChild(n, visitNode); |
|
parent = saveParent; |
|
} |
|
} |
|
} |
|
Parser.fixupParentReferences = fixupParentReferences; |
|
function createSourceFile(fileName, languageVersion, scriptKind) { |
|
// code from createNode is inlined here so createNode won't have to deal with special case of creating source files |
|
// this is quite rare comparing to other nodes and createNode should be as fast as possible |
|
var sourceFile = new SourceFileConstructor(251 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); |
|
nodeCount++; |
|
sourceFile.text = sourceText; |
|
sourceFile.bindDiagnostics = []; |
|
sourceFile.languageVersion = languageVersion; |
|
sourceFile.fileName = ts.normalizePath(fileName); |
|
sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 /* DeclarationFile */ : 0; |
|
sourceFile.languageVariant = getLanguageVariant(scriptKind); |
|
sourceFile.scriptKind = scriptKind; |
|
return sourceFile; |
|
} |
|
function setContextFlag(val, flag) { |
|
if (val) { |
|
contextFlags |= flag; |
|
} |
|
else { |
|
contextFlags &= ~flag; |
|
} |
|
} |
|
function setDisallowInContext(val) { |
|
setContextFlag(val, 1 /* DisallowIn */); |
|
} |
|
function setYieldContext(val) { |
|
setContextFlag(val, 2 /* Yield */); |
|
} |
|
function setDecoratorContext(val) { |
|
setContextFlag(val, 4 /* Decorator */); |
|
} |
|
function setAwaitContext(val) { |
|
setContextFlag(val, 8 /* Await */); |
|
} |
|
function doOutsideOfContext(context, func) { |
|
// contextFlagsToClear will contain only the context flags that are |
|
// currently set that we need to temporarily clear |
|
// We don't just blindly reset to the previous flags to ensure |
|
// that we do not mutate cached flags for the incremental |
|
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and |
|
// HasAggregatedChildData). |
|
var contextFlagsToClear = context & contextFlags; |
|
if (contextFlagsToClear) { |
|
// clear the requested context flags |
|
setContextFlag(/*val*/ false, contextFlagsToClear); |
|
var result = func(); |
|
// restore the context flags we just cleared |
|
setContextFlag(/*val*/ true, contextFlagsToClear); |
|
return result; |
|
} |
|
// no need to do anything special as we are not in any of the requested contexts |
|
return func(); |
|
} |
|
function doInsideOfContext(context, func) { |
|
// contextFlagsToSet will contain only the context flags that |
|
// are not currently set that we need to temporarily enable. |
|
// We don't just blindly reset to the previous flags to ensure |
|
// that we do not mutate cached flags for the incremental |
|
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and |
|
// HasAggregatedChildData). |
|
var contextFlagsToSet = context & ~contextFlags; |
|
if (contextFlagsToSet) { |
|
// set the requested context flags |
|
setContextFlag(/*val*/ true, contextFlagsToSet); |
|
var result = func(); |
|
// reset the context flags we just set |
|
setContextFlag(/*val*/ false, contextFlagsToSet); |
|
return result; |
|
} |
|
// no need to do anything special as we are already in all of the requested contexts |
|
return func(); |
|
} |
|
function allowInAnd(func) { |
|
return doOutsideOfContext(1 /* DisallowIn */, func); |
|
} |
|
function disallowInAnd(func) { |
|
return doInsideOfContext(1 /* DisallowIn */, func); |
|
} |
|
function doInYieldContext(func) { |
|
return doInsideOfContext(2 /* Yield */, func); |
|
} |
|
function doInDecoratorContext(func) { |
|
return doInsideOfContext(4 /* Decorator */, func); |
|
} |
|
function doInAwaitContext(func) { |
|
return doInsideOfContext(8 /* Await */, func); |
|
} |
|
function doOutsideOfAwaitContext(func) { |
|
return doOutsideOfContext(8 /* Await */, func); |
|
} |
|
function doInYieldAndAwaitContext(func) { |
|
return doInsideOfContext(2 /* Yield */ | 8 /* Await */, func); |
|
} |
|
function inContext(flags) { |
|
return (contextFlags & flags) !== 0; |
|
} |
|
function inYieldContext() { |
|
return inContext(2 /* Yield */); |
|
} |
|
function inDisallowInContext() { |
|
return inContext(1 /* DisallowIn */); |
|
} |
|
function inDecoratorContext() { |
|
return inContext(4 /* Decorator */); |
|
} |
|
function inAwaitContext() { |
|
return inContext(8 /* Await */); |
|
} |
|
function parseErrorAtCurrentToken(message, arg0) { |
|
var start = scanner.getTokenPos(); |
|
var length = scanner.getTextPos() - start; |
|
parseErrorAtPosition(start, length, message, arg0); |
|
} |
|
function parseErrorAtPosition(start, length, message, arg0) { |
|
// Don't report another error if it would just be at the same position as the last error. |
|
var lastError = ts.lastOrUndefined(parseDiagnostics); |
|
if (!lastError || start !== lastError.start) { |
|
parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); |
|
} |
|
// Mark that we've encountered an error. We'll set an appropriate bit on the next |
|
// node we finish so that it can't be reused incrementally. |
|
parseErrorBeforeNextFinishedNode = true; |
|
} |
|
function scanError(message, length) { |
|
var pos = scanner.getTextPos(); |
|
parseErrorAtPosition(pos, length || 0, message); |
|
} |
|
function getNodePos() { |
|
return scanner.getStartPos(); |
|
} |
|
function getNodeEnd() { |
|
return scanner.getStartPos(); |
|
} |
|
function nextToken() { |
|
return token = scanner.scan(); |
|
} |
|
function reScanGreaterToken() { |
|
return token = scanner.reScanGreaterToken(); |
|
} |
|
function reScanSlashToken() { |
|
return token = scanner.reScanSlashToken(); |
|
} |
|
function reScanTemplateToken() { |
|
return token = scanner.reScanTemplateToken(); |
|
} |
|
function scanJsxIdentifier() { |
|
return token = scanner.scanJsxIdentifier(); |
|
} |
|
function scanJsxText() { |
|
return token = scanner.scanJsxToken(); |
|
} |
|
function speculationHelper(callback, isLookAhead) { |
|
// Keep track of the state we'll need to rollback to if lookahead fails (or if the |
|
// caller asked us to always reset our state). |
|
var saveToken = token; |
|
var saveParseDiagnosticsLength = parseDiagnostics.length; |
|
var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; |
|
// Note: it is not actually necessary to save/restore the context flags here. That's |
|
// because the saving/restoring of these flags happens naturally through the recursive |
|
// descent nature of our parser. However, we still store this here just so we can |
|
// assert that that invariant holds. |
|
var saveContextFlags = contextFlags; |
|
// If we're only looking ahead, then tell the scanner to only lookahead as well. |
|
// Otherwise, if we're actually speculatively parsing, then tell the scanner to do the |
|
// same. |
|
var result = isLookAhead |
|
? scanner.lookAhead(callback) |
|
: scanner.tryScan(callback); |
|
ts.Debug.assert(saveContextFlags === contextFlags); |
|
// If our callback returned something 'falsy' or we're just looking ahead, |
|
// then unconditionally restore us to where we were. |
|
if (!result || isLookAhead) { |
|
token = saveToken; |
|
parseDiagnostics.length = saveParseDiagnosticsLength; |
|
parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; |
|
} |
|
return result; |
|
} |
|
/** Invokes the provided callback then unconditionally restores the parser to the state it |
|
* was in immediately prior to invoking the callback. The result of invoking the callback |
|
* is returned from this function. |
|
*/ |
|
function lookAhead(callback) { |
|
return speculationHelper(callback, /*isLookAhead*/ true); |
|
} |
|
/** Invokes the provided callback. If the callback returns something falsy, then it restores |
|
* the parser to the state it was in immediately prior to invoking the callback. If the |
|
* callback returns something truthy, then the parser state is not rolled back. The result |
|
* of invoking the callback is returned from this function. |
|
*/ |
|
function tryParse(callback) { |
|
return speculationHelper(callback, /*isLookAhead*/ false); |
|
} |
|
// Ignore strict mode flag because we will report an error in type checker instead. |
|
function isIdentifier() { |
|
if (token === 69 /* Identifier */) { |
|
return true; |
|
} |
|
// 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 === 114 /* YieldKeyword */ && inYieldContext()) { |
|
return false; |
|
} |
|
// If we have a 'await' keyword, and we're in the [Await] context, then 'await' is |
|
// considered a keyword and is not an identifier. |
|
if (token === 119 /* AwaitKeyword */ && inAwaitContext()) { |
|
return false; |
|
} |
|
return token > 105 /* LastReservedWord */; |
|
} |
|
function parseExpected(kind, diagnosticMessage, shouldAdvance) { |
|
if (shouldAdvance === void 0) { shouldAdvance = true; } |
|
if (token === kind) { |
|
if (shouldAdvance) { |
|
nextToken(); |
|
} |
|
return true; |
|
} |
|
// Report specific message if provided with one. Otherwise, report generic fallback message. |
|
if (diagnosticMessage) { |
|
parseErrorAtCurrentToken(diagnosticMessage); |
|
} |
|
else { |
|
parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); |
|
} |
|
return false; |
|
} |
|
function parseOptional(t) { |
|
if (token === t) { |
|
nextToken(); |
|
return true; |
|
} |
|
return false; |
|
} |
|
function parseOptionalToken(t) { |
|
if (token === t) { |
|
return parseTokenNode(); |
|
} |
|
return undefined; |
|
} |
|
function parseExpectedToken(t, reportAtCurrentPosition, diagnosticMessage, arg0) { |
|
return parseOptionalToken(t) || |
|
createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0); |
|
} |
|
function parseTokenNode() { |
|
var node = createNode(token); |
|
nextToken(); |
|
return finishNode(node); |
|
} |
|
function canParseSemicolon() { |
|
// If there's a real semicolon, then we can always parse it out. |
|
if (token === 23 /* SemicolonToken */) { |
|
return true; |
|
} |
|
// We can parse out an optional semicolon in ASI cases in the following cases. |
|
return token === 16 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); |
|
} |
|
function parseSemicolon() { |
|
if (canParseSemicolon()) { |
|
if (token === 23 /* SemicolonToken */) { |
|
// consume the semicolon if it was explicitly provided. |
|
nextToken(); |
|
} |
|
return true; |
|
} |
|
else { |
|
return parseExpected(23 /* SemicolonToken */); |
|
} |
|
} |
|
// note: this function creates only node |
|
function createNode(kind, pos) { |
|
nodeCount++; |
|
if (!(pos >= 0)) { |
|
pos = scanner.getStartPos(); |
|
} |
|
return new NodeConstructor(kind, pos, pos); |
|
} |
|
function finishNode(node, end) { |
|
node.end = end === undefined ? scanner.getStartPos() : end; |
|
if (contextFlags) { |
|
node.parserContextFlags = contextFlags; |
|
} |
|
// Keep track on the node if we encountered an error while parsing it. If we did, then |
|
// we cannot reuse the node incrementally. Once we've marked this node, clear out the |
|
// flag so that we don't mark any subsequent nodes. |
|
if (parseErrorBeforeNextFinishedNode) { |
|
parseErrorBeforeNextFinishedNode = false; |
|
node.parserContextFlags |= 16 /* ThisNodeHasError */; |
|
} |
|
return node; |
|
} |
|
function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { |
|
if (reportAtCurrentPosition) { |
|
parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); |
|
} |
|
else { |
|
parseErrorAtCurrentToken(diagnosticMessage, arg0); |
|
} |
|
var result = createNode(kind, scanner.getStartPos()); |
|
result.text = ""; |
|
return finishNode(result); |
|
} |
|
function internIdentifier(text) { |
|
text = ts.escapeIdentifier(text); |
|
return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); |
|
} |
|
// An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues |
|
// with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for |
|
// each identifier in order to reduce memory consumption. |
|
function createIdentifier(isIdentifier, diagnosticMessage) { |
|
identifierCount++; |
|
if (isIdentifier) { |
|
var node = createNode(69 /* Identifier */); |
|
// Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker |
|
if (token !== 69 /* Identifier */) { |
|
node.originalKeywordKind = token; |
|
} |
|
node.text = internIdentifier(scanner.getTokenValue()); |
|
nextToken(); |
|
return finishNode(node); |
|
} |
|
return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); |
|
} |
|
function parseIdentifier(diagnosticMessage) { |
|
return createIdentifier(isIdentifier(), diagnosticMessage); |
|
} |
|
function parseIdentifierName() { |
|
return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); |
|
} |
|
function isLiteralPropertyName() { |
|
return ts.tokenIsIdentifierOrKeyword(token) || |
|
token === 9 /* StringLiteral */ || |
|
token === 8 /* NumericLiteral */; |
|
} |
|
function parsePropertyNameWorker(allowComputedPropertyNames) { |
|
if (token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */) { |
|
return parseLiteralNode(/*internName*/ true); |
|
} |
|
if (allowComputedPropertyNames && token === 19 /* OpenBracketToken */) { |
|
return parseComputedPropertyName(); |
|
} |
|
return parseIdentifierName(); |
|
} |
|
function parsePropertyName() { |
|
return parsePropertyNameWorker(/*allowComputedPropertyNames*/ true); |
|
} |
|
function parseSimplePropertyName() { |
|
return parsePropertyNameWorker(/*allowComputedPropertyNames*/ false); |
|
} |
|
function isSimplePropertyName() { |
|
return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token); |
|
} |
|
function parseComputedPropertyName() { |
|
// PropertyName [Yield]: |
|
// LiteralPropertyName |
|
// ComputedPropertyName[?Yield] |
|
var node = createNode(137 /* ComputedPropertyName */); |
|
parseExpected(19 /* OpenBracketToken */); |
|
// We parse any expression (including a comma expression). But the grammar |
|
// says that only an assignment expression is allowed, so the grammar checker |
|
// will error if it sees a comma expression. |
|
node.expression = allowInAnd(parseExpression); |
|
parseExpected(20 /* CloseBracketToken */); |
|
return finishNode(node); |
|
} |
|
function parseContextualModifier(t) { |
|
return token === t && tryParse(nextTokenCanFollowModifier); |
|
} |
|
function nextTokenIsOnSameLineAndCanFollowModifier() { |
|
nextToken(); |
|
if (scanner.hasPrecedingLineBreak()) { |
|
return false; |
|
} |
|
return canFollowModifier(); |
|
} |
|
function nextTokenCanFollowModifier() { |
|
if (token === 74 /* ConstKeyword */) { |
|
// 'const' is only a modifier if followed by 'enum'. |
|
return nextToken() === 81 /* EnumKeyword */; |
|
} |
|
if (token === 82 /* ExportKeyword */) { |
|
nextToken(); |
|
if (token === 77 /* DefaultKeyword */) { |
|
return lookAhead(nextTokenIsClassOrFunction); |
|
} |
|
return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); |
|
} |
|
if (token === 77 /* DefaultKeyword */) { |
|
return nextTokenIsClassOrFunction(); |
|
} |
|
if (token === 113 /* StaticKeyword */) { |
|
nextToken(); |
|
return canFollowModifier(); |
|
} |
|
return nextTokenIsOnSameLineAndCanFollowModifier(); |
|
} |
|
function parseAnyContextualModifier() { |
|
return ts.isModifierKind(token) && tryParse(nextTokenCanFollowModifier); |
|
} |
|
function canFollowModifier() { |
|
return token === 19 /* OpenBracketToken */ |
|
|| token === 15 /* OpenBraceToken */ |
|
|| token === 37 /* AsteriskToken */ |
|
|| isLiteralPropertyName(); |
|
} |
|
function nextTokenIsClassOrFunction() { |
|
nextToken(); |
|
return token === 73 /* ClassKeyword */ || token === 87 /* FunctionKeyword */; |
|
} |
|
// True if positioned at the start of a list element |
|
function isListElement(parsingContext, inErrorRecovery) { |
|
var node = currentNode(parsingContext); |
|
if (node) { |
|
return true; |
|
} |
|
switch (parsingContext) { |
|
case 0 /* SourceElements */: |
|
case 1 /* BlockStatements */: |
|
case 3 /* SwitchClauseStatements */: |
|
// If we're in error recovery, then we don't want to treat ';' as an empty statement. |
|
// The problem is that ';' can show up in far too many contexts, and if we see one |
|
// and assume it's a statement, then we may bail out inappropriately from whatever |
|
// we're parsing. For example, if we have a semicolon in the middle of a class, then |
|
// we really don't want to assume the class is over and we're on a statement in the |
|
// outer module. We just want to consume and move on. |
|
return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); |
|
case 2 /* SwitchClauses */: |
|
return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; |
|
case 4 /* TypeMembers */: |
|
return isStartOfTypeMember(); |
|
case 5 /* ClassMembers */: |
|
// We allow semicolons as class elements (as specified by ES6) as long as we're |
|
// not in error recovery. If we're in error recovery, we don't want an errant |
|
// semicolon to be treated as a class member (since they're almost always used |
|
// for statements. |
|
return lookAhead(isClassMemberStart) || (token === 23 /* SemicolonToken */ && !inErrorRecovery); |
|
case 6 /* EnumMembers */: |
|
// Include open bracket computed properties. This technically also lets in indexers, |
|
// which would be a candidate for improved error reporting. |
|
return token === 19 /* OpenBracketToken */ || isLiteralPropertyName(); |
|
case 12 /* ObjectLiteralMembers */: |
|
return token === 19 /* OpenBracketToken */ || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); |
|
case 9 /* ObjectBindingElements */: |
|
return token === 19 /* OpenBracketToken */ || isLiteralPropertyName(); |
|
case 7 /* HeritageClauseElement */: |
|
// If we see { } then only consume it as an expression if it is followed by , or { |
|
// That way we won't consume the body of a class in its heritage clause. |
|
if (token === 15 /* OpenBraceToken */) { |
|
return lookAhead(isValidHeritageClauseObjectLiteral); |
|
} |
|
if (!inErrorRecovery) { |
|
return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword(); |
|
} |
|
else { |
|
// If we're in error recovery we tighten up what we're willing to match. |
|
// That way we don't treat something like "this" as a valid heritage clause |
|
// element during recovery. |
|
return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); |
|
} |
|
case 8 /* VariableDeclarations */: |
|
return isIdentifierOrPattern(); |
|
case 10 /* ArrayBindingElements */: |
|
return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); |
|
case 17 /* TypeParameters */: |
|
return isIdentifier(); |
|
case 11 /* ArgumentExpressions */: |
|
case 15 /* ArrayLiteralMembers */: |
|
return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isStartOfExpression(); |
|
case 16 /* Parameters */: |
|
return isStartOfParameter(); |
|
case 18 /* TypeArguments */: |
|
case 19 /* TupleElementTypes */: |
|
return token === 24 /* CommaToken */ || isStartOfType(); |
|
case 20 /* HeritageClauses */: |
|
return isHeritageClause(); |
|
case 21 /* ImportOrExportSpecifiers */: |
|
return ts.tokenIsIdentifierOrKeyword(token); |
|
case 13 /* JsxAttributes */: |
|
return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */; |
|
case 14 /* JsxChildren */: |
|
return true; |
|
case 22 /* JSDocFunctionParameters */: |
|
case 23 /* JSDocTypeArguments */: |
|
case 25 /* JSDocTupleTypes */: |
|
return JSDocParser.isJSDocType(); |
|
case 24 /* JSDocRecordMembers */: |
|
return isSimplePropertyName(); |
|
} |
|
ts.Debug.fail("Non-exhaustive case in 'isListElement'."); |
|
} |
|
function isValidHeritageClauseObjectLiteral() { |
|
ts.Debug.assert(token === 15 /* OpenBraceToken */); |
|
if (nextToken() === 16 /* CloseBraceToken */) { |
|
// if we see "extends {}" then only treat the {} as what we're extending (and not |
|
// the class body) if we have: |
|
// |
|
// extends {} { |
|
// extends {}, |
|
// extends {} extends |
|
// extends {} implements |
|
var next = nextToken(); |
|
return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; |
|
} |
|
return true; |
|
} |
|
function nextTokenIsIdentifier() { |
|
nextToken(); |
|
return isIdentifier(); |
|
} |
|
function nextTokenIsIdentifierOrKeyword() { |
|
nextToken(); |
|
return ts.tokenIsIdentifierOrKeyword(token); |
|
} |
|
function isHeritageClauseExtendsOrImplementsKeyword() { |
|
if (token === 106 /* ImplementsKeyword */ || |
|
token === 83 /* ExtendsKeyword */) { |
|
return lookAhead(nextTokenIsStartOfExpression); |
|
} |
|
return false; |
|
} |
|
function nextTokenIsStartOfExpression() { |
|
nextToken(); |
|
return isStartOfExpression(); |
|
} |
|
// True if positioned at a list terminator |
|
function isListTerminator(kind) { |
|
if (token === 1 /* EndOfFileToken */) { |
|
// Being at the end of the file ends all lists. |
|
return true; |
|
} |
|
switch (kind) { |
|
case 1 /* BlockStatements */: |
|
case 2 /* SwitchClauses */: |
|
case 4 /* TypeMembers */: |
|
case 5 /* ClassMembers */: |
|
case 6 /* EnumMembers */: |
|
case 12 /* ObjectLiteralMembers */: |
|
case 9 /* ObjectBindingElements */: |
|
case 21 /* ImportOrExportSpecifiers */: |
|
return token === 16 /* CloseBraceToken */; |
|
case 3 /* SwitchClauseStatements */: |
|
return token === 16 /* CloseBraceToken */ || token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; |
|
case 7 /* HeritageClauseElement */: |
|
return token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; |
|
case 8 /* VariableDeclarations */: |
|
return isVariableDeclaratorListTerminator(); |
|
case 17 /* TypeParameters */: |
|
// Tokens other than '>' are here for better error recovery |
|
return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; |
|
case 11 /* ArgumentExpressions */: |
|
// Tokens other than ')' are here for better error recovery |
|
return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; |
|
case 15 /* ArrayLiteralMembers */: |
|
case 19 /* TupleElementTypes */: |
|
case 10 /* ArrayBindingElements */: |
|
return token === 20 /* CloseBracketToken */; |
|
case 16 /* Parameters */: |
|
// Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery |
|
return token === 18 /* CloseParenToken */ || token === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; |
|
case 18 /* TypeArguments */: |
|
// Tokens other than '>' are here for better error recovery |
|
return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */; |
|
case 20 /* HeritageClauses */: |
|
return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; |
|
case 13 /* JsxAttributes */: |
|
return token === 27 /* GreaterThanToken */ || token === 39 /* SlashToken */; |
|
case 14 /* JsxChildren */: |
|
return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); |
|
case 22 /* JSDocFunctionParameters */: |
|
return token === 18 /* CloseParenToken */ || token === 54 /* ColonToken */ || token === 16 /* CloseBraceToken */; |
|
case 23 /* JSDocTypeArguments */: |
|
return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; |
|
case 25 /* JSDocTupleTypes */: |
|
return token === 20 /* CloseBracketToken */ || token === 16 /* CloseBraceToken */; |
|
case 24 /* JSDocRecordMembers */: |
|
return token === 16 /* CloseBraceToken */; |
|
} |
|
} |
|
function isVariableDeclaratorListTerminator() { |
|
// If we can consume a semicolon (either explicitly, or with ASI), then consider us done |
|
// with parsing the list of variable declarators. |
|
if (canParseSemicolon()) { |
|
return true; |
|
} |
|
// in the case where we're parsing the variable declarator of a 'for-in' statement, we |
|
// are done if we see an 'in' keyword in front of us. Same with for-of |
|
if (isInOrOfKeyword(token)) { |
|
return true; |
|
} |
|
// ERROR RECOVERY TWEAK: |
|
// For better error recovery, if we see an '=>' then we just stop immediately. We've got an |
|
// arrow function here and it's going to be very unlikely that we'll resynchronize and get |
|
// another variable declaration. |
|
if (token === 34 /* EqualsGreaterThanToken */) { |
|
return true; |
|
} |
|
// Keep trying to parse out variable declarators. |
|
return false; |
|
} |
|
// True if positioned at element or terminator of the current list or any enclosing list |
|
function isInSomeParsingContext() { |
|
for (var kind = 0; kind < 26 /* Count */; kind++) { |
|
if (parsingContext & (1 << kind)) { |
|
if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { |
|
return true; |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
// Parses a list of elements |
|
function parseList(kind, parseElement) { |
|
var saveParsingContext = parsingContext; |
|
parsingContext |= 1 << kind; |
|
var result = []; |
|
result.pos = getNodePos(); |
|
while (!isListTerminator(kind)) { |
|
if (isListElement(kind, /*inErrorRecovery*/ false)) { |
|
var element = parseListElement(kind, parseElement); |
|
result.push(element); |
|
continue; |
|
} |
|
if (abortParsingListOrMoveToNextToken(kind)) { |
|
break; |
|
} |
|
} |
|
result.end = getNodeEnd(); |
|
parsingContext = saveParsingContext; |
|
return result; |
|
} |
|
function parseListElement(parsingContext, parseElement) { |
|
var node = currentNode(parsingContext); |
|
if (node) { |
|
return consumeNode(node); |
|
} |
|
return parseElement(); |
|
} |
|
function currentNode(parsingContext) { |
|
// If there is an outstanding parse error that we've encountered, but not attached to |
|
// some node, then we cannot get a node from the old source tree. This is because we |
|
// want to mark the next node we encounter as being unusable. |
|
// |
|
// Note: This may be too conservative. Perhaps we could reuse the node and set the bit |
|
// on it (or its leftmost child) as having the error. For now though, being conservative |
|
// is nice and likely won't ever affect perf. |
|
if (parseErrorBeforeNextFinishedNode) { |
|
return undefined; |
|
} |
|
if (!syntaxCursor) { |
|
// if we don't have a cursor, we could never return a node from the old tree. |
|
return undefined; |
|
} |
|
var node = syntaxCursor.currentNode(scanner.getStartPos()); |
|
// Can't reuse a missing node. |
|
if (ts.nodeIsMissing(node)) { |
|
return undefined; |
|
} |
|
// Can't reuse a node that intersected the change range. |
|
if (node.intersectsChange) { |
|
return undefined; |
|
} |
|
// Can't reuse a node that contains a parse error. This is necessary so that we |
|
// produce the same set of errors again. |
|
if (ts.containsParseError(node)) { |
|
return undefined; |
|
} |
|
// We can only reuse a node if it was parsed under the same strict mode that we're |
|
// currently in. i.e. if we originally parsed a node in non-strict mode, but then |
|
// the user added 'using strict' at the top of the file, then we can't use that node |
|
// again as the presense of strict mode may cause us to parse the tokens in the file |
|
// differetly. |
|
// |
|
// Note: we *can* reuse tokens when the strict mode changes. That's because tokens |
|
// are unaffected by strict mode. It's just the parser will decide what to do with it |
|
// differently depending on what mode it is in. |
|
// |
|
// This also applies to all our other context flags as well. |
|
var nodeContextFlags = node.parserContextFlags & 63 /* ParserGeneratedFlags */; |
|
if (nodeContextFlags !== contextFlags) { |
|
return undefined; |
|
} |
|
// Ok, we have a node that looks like it could be reused. Now verify that it is valid |
|
// in the currest list parsing context that we're currently at. |
|
if (!canReuseNode(node, parsingContext)) { |
|
return undefined; |
|
} |
|
return node; |
|
} |
|
function consumeNode(node) { |
|
// Move the scanner so it is after the node we just consumed. |
|
scanner.setTextPos(node.end); |
|
nextToken(); |
|
return node; |
|
} |
|
function canReuseNode(node, parsingContext) { |
|
switch (parsingContext) { |
|
case 5 /* ClassMembers */: |
|
return isReusableClassMember(node); |
|
case 2 /* SwitchClauses */: |
|
return isReusableSwitchClause(node); |
|
case 0 /* SourceElements */: |
|
case 1 /* BlockStatements */: |
|
case 3 /* SwitchClauseStatements */: |
|
return isReusableStatement(node); |
|
case 6 /* EnumMembers */: |
|
return isReusableEnumMember(node); |
|
case 4 /* TypeMembers */: |
|
return isReusableTypeMember(node); |
|
case 8 /* VariableDeclarations */: |
|
return isReusableVariableDeclaration(node); |
|
case 16 /* Parameters */: |
|
return isReusableParameter(node); |
|
// Any other lists we do not care about reusing nodes in. But feel free to add if |
|
// you can do so safely. Danger areas involve nodes that may involve speculative |
|
// parsing. If speculative parsing is involved with the node, then the range the |
|
// parser reached while looking ahead might be in the edited range (see the example |
|
// in canReuseVariableDeclaratorNode for a good case of this). |
|
case 20 /* HeritageClauses */: |
|
// This would probably be safe to reuse. There is no speculative parsing with |
|
// heritage clauses. |
|
case 17 /* TypeParameters */: |
|
// This would probably be safe to reuse. There is no speculative parsing with |
|
// type parameters. Note that that's because type *parameters* only occur in |
|
// unambiguous *type* contexts. While type *arguments* occur in very ambiguous |
|
// *expression* contexts. |
|
case 19 /* TupleElementTypes */: |
|
// This would probably be safe to reuse. There is no speculative parsing with |
|
// tuple types. |
|
// Technically, type argument list types are probably safe to reuse. While |
|
// speculative parsing is involved with them (since type argument lists are only |
|
// produced from speculative parsing a < as a type argument list), we only have |
|
// the types because speculative parsing succeeded. Thus, the lookahead never |
|
// went past the end of the list and rewound. |
|
case 18 /* TypeArguments */: |
|
// Note: these are almost certainly not safe to ever reuse. Expressions commonly |
|
// need a large amount of lookahead, and we should not reuse them as they may |
|
// have actually intersected the edit. |
|
case 11 /* ArgumentExpressions */: |
|
// This is not safe to reuse for the same reason as the 'AssignmentExpression' |
|
// cases. i.e. a property assignment may end with an expression, and thus might |
|
// have lookahead far beyond it's old node. |
|
case 12 /* ObjectLiteralMembers */: |
|
// This is probably not safe to reuse. There can be speculative parsing with |
|
// type names in a heritage clause. There can be generic names in the type |
|
// name list, and there can be left hand side expressions (which can have type |
|
// arguments.) |
|
case 7 /* HeritageClauseElement */: |
|
// Perhaps safe to reuse, but it's unlikely we'd see more than a dozen attributes |
|
// on any given element. Same for children. |
|
case 13 /* JsxAttributes */: |
|
case 14 /* JsxChildren */: |
|
} |
|
return false; |
|
} |
|
function isReusableClassMember(node) { |
|
if (node) { |
|
switch (node.kind) { |
|
case 145 /* Constructor */: |
|
case 150 /* IndexSignature */: |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
case 142 /* PropertyDeclaration */: |
|
case 194 /* SemicolonClassElement */: |
|
return true; |
|
case 144 /* MethodDeclaration */: |
|
// Method declarations are not necessarily reusable. An object-literal |
|
// may have a method calls "constructor(...)" and we must reparse that |
|
// into an actual .ConstructorDeclaration. |
|
var methodDeclaration = node; |
|
var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ && |
|
methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; |
|
return !nameIsConstructor; |
|
} |
|
} |
|
return false; |
|
} |
|
function isReusableSwitchClause(node) { |
|
if (node) { |
|
switch (node.kind) { |
|
case 244 /* CaseClause */: |
|
case 245 /* DefaultClause */: |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
function isReusableStatement(node) { |
|
if (node) { |
|
switch (node.kind) { |
|
case 216 /* FunctionDeclaration */: |
|
case 196 /* VariableStatement */: |
|
case 195 /* Block */: |
|
case 199 /* IfStatement */: |
|
case 198 /* ExpressionStatement */: |
|
case 211 /* ThrowStatement */: |
|
case 207 /* ReturnStatement */: |
|
case 209 /* SwitchStatement */: |
|
case 206 /* BreakStatement */: |
|
case 205 /* ContinueStatement */: |
|
case 203 /* ForInStatement */: |
|
case 204 /* ForOfStatement */: |
|
case 202 /* ForStatement */: |
|
case 201 /* WhileStatement */: |
|
case 208 /* WithStatement */: |
|
case 197 /* EmptyStatement */: |
|
case 212 /* TryStatement */: |
|
case 210 /* LabeledStatement */: |
|
case 200 /* DoStatement */: |
|
case 213 /* DebuggerStatement */: |
|
case 225 /* ImportDeclaration */: |
|
case 224 /* ImportEqualsDeclaration */: |
|
case 231 /* ExportDeclaration */: |
|
case 230 /* ExportAssignment */: |
|
case 221 /* ModuleDeclaration */: |
|
case 217 /* ClassDeclaration */: |
|
case 218 /* InterfaceDeclaration */: |
|
case 220 /* EnumDeclaration */: |
|
case 219 /* TypeAliasDeclaration */: |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
function isReusableEnumMember(node) { |
|
return node.kind === 250 /* EnumMember */; |
|
} |
|
function isReusableTypeMember(node) { |
|
if (node) { |
|
switch (node.kind) { |
|
case 149 /* ConstructSignature */: |
|
case 143 /* MethodSignature */: |
|
case 150 /* IndexSignature */: |
|
case 141 /* PropertySignature */: |
|
case 148 /* CallSignature */: |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
function isReusableVariableDeclaration(node) { |
|
if (node.kind !== 214 /* VariableDeclaration */) { |
|
return false; |
|
} |
|
// Very subtle incremental parsing bug. Consider the following code: |
|
// |
|
// let v = new List < A, B |
|
// |
|
// This is actually legal code. It's a list of variable declarators "v = new List<A" |
|
// on one side and "B" on the other. If you then change that to: |
|
// |
|
// let v = new List < A, B >() |
|
// |
|
// then we have a problem. "v = new List<A" doesn't intersect the change range, so we |
|
// start reparsing at "B" and we completely fail to handle this properly. |
|
// |
|
// In order to prevent this, we do not allow a variable declarator to be reused if it |
|
// has an initializer. |
|
var variableDeclarator = node; |
|
return variableDeclarator.initializer === undefined; |
|
} |
|
function isReusableParameter(node) { |
|
if (node.kind !== 139 /* Parameter */) { |
|
return false; |
|
} |
|
// See the comment in isReusableVariableDeclaration for why we do this. |
|
var parameter = node; |
|
return parameter.initializer === undefined; |
|
} |
|
// Returns true if we should abort parsing. |
|
function abortParsingListOrMoveToNextToken(kind) { |
|
parseErrorAtCurrentToken(parsingContextErrors(kind)); |
|
if (isInSomeParsingContext()) { |
|
return true; |
|
} |
|
nextToken(); |
|
return false; |
|
} |
|
function parsingContextErrors(context) { |
|
switch (context) { |
|
case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; |
|
case 1 /* BlockStatements */: return ts.Diagnostics.Declaration_or_statement_expected; |
|
case 2 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; |
|
case 3 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; |
|
case 4 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; |
|
case 5 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; |
|
case 6 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; |
|
case 7 /* HeritageClauseElement */: return ts.Diagnostics.Expression_expected; |
|
case 8 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; |
|
case 9 /* ObjectBindingElements */: return ts.Diagnostics.Property_destructuring_pattern_expected; |
|
case 10 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; |
|
case 11 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; |
|
case 12 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; |
|
case 15 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; |
|
case 16 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; |
|
case 17 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; |
|
case 18 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; |
|
case 19 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; |
|
case 20 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; |
|
case 21 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; |
|
case 13 /* JsxAttributes */: return ts.Diagnostics.Identifier_expected; |
|
case 14 /* JsxChildren */: return ts.Diagnostics.Identifier_expected; |
|
case 22 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; |
|
case 23 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; |
|
case 25 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; |
|
case 24 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; |
|
} |
|
} |
|
; |
|
// Parses a comma-delimited list of elements |
|
function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimeter) { |
|
var saveParsingContext = parsingContext; |
|
parsingContext |= 1 << kind; |
|
var result = []; |
|
result.pos = getNodePos(); |
|
var commaStart = -1; // Meaning the previous token was not a comma |
|
while (true) { |
|
if (isListElement(kind, /*inErrorRecovery*/ false)) { |
|
result.push(parseListElement(kind, parseElement)); |
|
commaStart = scanner.getTokenPos(); |
|
if (parseOptional(24 /* CommaToken */)) { |
|
continue; |
|
} |
|
commaStart = -1; // Back to the state where the last token was not a comma |
|
if (isListTerminator(kind)) { |
|
break; |
|
} |
|
// We didn't get a comma, and the list wasn't terminated, explicitly parse |
|
// out a comma so we give a good error message. |
|
parseExpected(24 /* CommaToken */); |
|
// If the token was a semicolon, and the caller allows that, then skip it and |
|
// continue. This ensures we get back on track and don't result in tons of |
|
// parse errors. For example, this can happen when people do things like use |
|
// a semicolon to delimit object literal members. Note: we'll have already |
|
// reported an error when we called parseExpected above. |
|
if (considerSemicolonAsDelimeter && token === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { |
|
nextToken(); |
|
} |
|
continue; |
|
} |
|
if (isListTerminator(kind)) { |
|
break; |
|
} |
|
if (abortParsingListOrMoveToNextToken(kind)) { |
|
break; |
|
} |
|
} |
|
// Recording the trailing comma is deliberately done after the previous |
|
// loop, and not just if we see a list terminator. This is because the list |
|
// may have ended incorrectly, but it is still important to know if there |
|
// was a trailing comma. |
|
// Check if the last token was a comma. |
|
if (commaStart >= 0) { |
|
// Always preserve a trailing comma by marking it on the NodeArray |
|
result.hasTrailingComma = true; |
|
} |
|
result.end = getNodeEnd(); |
|
parsingContext = saveParsingContext; |
|
return result; |
|
} |
|
function createMissingList() { |
|
var pos = getNodePos(); |
|
var result = []; |
|
result.pos = pos; |
|
result.end = pos; |
|
return result; |
|
} |
|
function parseBracketedList(kind, parseElement, open, close) { |
|
if (parseExpected(open)) { |
|
var result = parseDelimitedList(kind, parseElement); |
|
parseExpected(close); |
|
return result; |
|
} |
|
return createMissingList(); |
|
} |
|
// The allowReservedWords parameter controls whether reserved words are permitted after the first dot |
|
function parseEntityName(allowReservedWords, diagnosticMessage) { |
|
var entity = parseIdentifier(diagnosticMessage); |
|
while (parseOptional(21 /* DotToken */)) { |
|
var node = createNode(136 /* QualifiedName */, entity.pos); |
|
node.left = entity; |
|
node.right = parseRightSideOfDot(allowReservedWords); |
|
entity = finishNode(node); |
|
} |
|
return entity; |
|
} |
|
function parseRightSideOfDot(allowIdentifierNames) { |
|
// Technically a keyword is valid here as all identifiers and keywords are identifier names. |
|
// However, often we'll encounter this in error situations when the identifier or keyword |
|
// is actually starting another valid construct. |
|
// |
|
// So, we check for the following specific case: |
|
// |
|
// name. |
|
// identifierOrKeyword identifierNameOrKeyword |
|
// |
|
// Note: the newlines are important here. For example, if that above code |
|
// were rewritten into: |
|
// |
|
// name.identifierOrKeyword |
|
// identifierNameOrKeyword |
|
// |
|
// Then we would consider it valid. That's because ASI would take effect and |
|
// the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". |
|
// In the first case though, ASI will not take effect because there is not a |
|
// line terminator after the identifier or keyword. |
|
if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { |
|
var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); |
|
if (matchesPattern) { |
|
// Report that we need an identifier. However, report it right after the dot, |
|
// and not on the next token. This is because the next token might actually |
|
// be an identifier and the error would be quite confusing. |
|
return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); |
|
} |
|
} |
|
return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); |
|
} |
|
function parseTemplateExpression() { |
|
var template = createNode(186 /* TemplateExpression */); |
|
template.head = parseTemplateLiteralFragment(); |
|
ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); |
|
var templateSpans = []; |
|
templateSpans.pos = getNodePos(); |
|
do { |
|
templateSpans.push(parseTemplateSpan()); |
|
} while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); |
|
templateSpans.end = getNodeEnd(); |
|
template.templateSpans = templateSpans; |
|
return finishNode(template); |
|
} |
|
function parseTemplateSpan() { |
|
var span = createNode(193 /* TemplateSpan */); |
|
span.expression = allowInAnd(parseExpression); |
|
var literal; |
|
if (token === 16 /* CloseBraceToken */) { |
|
reScanTemplateToken(); |
|
literal = parseTemplateLiteralFragment(); |
|
} |
|
else { |
|
literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); |
|
} |
|
span.literal = literal; |
|
return finishNode(span); |
|
} |
|
function parseStringLiteralTypeNode() { |
|
return parseLiteralLikeNode(163 /* StringLiteralType */, /*internName*/ true); |
|
} |
|
function parseLiteralNode(internName) { |
|
return parseLiteralLikeNode(token, internName); |
|
} |
|
function parseTemplateLiteralFragment() { |
|
return parseLiteralLikeNode(token, /*internName*/ false); |
|
} |
|
function parseLiteralLikeNode(kind, internName) { |
|
var node = createNode(kind); |
|
var text = scanner.getTokenValue(); |
|
node.text = internName ? internIdentifier(text) : text; |
|
if (scanner.hasExtendedUnicodeEscape()) { |
|
node.hasExtendedUnicodeEscape = true; |
|
} |
|
if (scanner.isUnterminated()) { |
|
node.isUnterminated = true; |
|
} |
|
var tokenPos = scanner.getTokenPos(); |
|
nextToken(); |
|
finishNode(node); |
|
// Octal literals are not allowed in strict mode or ES5 |
|
// Note that theoretically the following condition would hold true literals like 009, |
|
// which is not octal.But because of how the scanner separates the tokens, we would |
|
// never get a token like this. Instead, we would get 00 and 9 as two separate tokens. |
|
// We also do not need to check for negatives because any prefix operator would be part of a |
|
// parent unary expression. |
|
if (node.kind === 8 /* NumericLiteral */ |
|
&& sourceText.charCodeAt(tokenPos) === 48 /* _0 */ |
|
&& ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { |
|
node.flags |= 32768 /* OctalLiteral */; |
|
} |
|
return node; |
|
} |
|
// TYPES |
|
function parseTypeReference() { |
|
var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); |
|
var node = createNode(152 /* TypeReference */, typeName.pos); |
|
node.typeName = typeName; |
|
if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { |
|
node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); |
|
} |
|
return finishNode(node); |
|
} |
|
function parseThisTypePredicate(lhs) { |
|
nextToken(); |
|
var node = createNode(151 /* TypePredicate */, lhs.pos); |
|
node.parameterName = lhs; |
|
node.type = parseType(); |
|
return finishNode(node); |
|
} |
|
function parseThisTypeNode() { |
|
var node = createNode(162 /* ThisType */); |
|
nextToken(); |
|
return finishNode(node); |
|
} |
|
function parseTypeQuery() { |
|
var node = createNode(155 /* TypeQuery */); |
|
parseExpected(101 /* TypeOfKeyword */); |
|
node.exprName = parseEntityName(/*allowReservedWords*/ true); |
|
return finishNode(node); |
|
} |
|
function parseTypeParameter() { |
|
var node = createNode(138 /* TypeParameter */); |
|
node.name = parseIdentifier(); |
|
if (parseOptional(83 /* ExtendsKeyword */)) { |
|
// It's not uncommon for people to write improper constraints to a generic. If the |
|
// user writes a constraint that is an expression and not an actual type, then parse |
|
// it out as an expression (so we can recover well), but report that a type is needed |
|
// instead. |
|
if (isStartOfType() || !isStartOfExpression()) { |
|
node.constraint = parseType(); |
|
} |
|
else { |
|
// It was not a type, and it looked like an expression. Parse out an expression |
|
// here so we recover well. Note: it is important that we call parseUnaryExpression |
|
// and not parseExpression here. If the user has: |
|
// |
|
// <T extends ""> |
|
// |
|
// We do *not* want to consume the > as we're consuming the expression for "". |
|
node.expression = parseUnaryExpressionOrHigher(); |
|
} |
|
} |
|
return finishNode(node); |
|
} |
|
function parseTypeParameters() { |
|
if (token === 25 /* LessThanToken */) { |
|
return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); |
|
} |
|
} |
|
function parseParameterType() { |
|
if (parseOptional(54 /* ColonToken */)) { |
|
return parseType(); |
|
} |
|
return undefined; |
|
} |
|
function isStartOfParameter() { |
|
return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token) || token === 55 /* AtToken */; |
|
} |
|
function setModifiers(node, modifiers) { |
|
if (modifiers) { |
|
node.flags |= modifiers.flags; |
|
node.modifiers = modifiers; |
|
} |
|
} |
|
function parseParameter() { |
|
var node = createNode(139 /* Parameter */); |
|
node.decorators = parseDecorators(); |
|
setModifiers(node, parseModifiers()); |
|
node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); |
|
// FormalParameter [Yield,Await]: |
|
// BindingElement[?Yield,?Await] |
|
node.name = parseIdentifierOrPattern(); |
|
if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifierKind(token)) { |
|
// in cases like |
|
// 'use strict' |
|
// function foo(static) |
|
// isParameter('static') === true, because of isModifier('static') |
|
// however 'static' is not a legal identifier in a strict mode. |
|
// so result of this function will be ParameterDeclaration (flags = 0, name = missing, type = undefined, initializer = undefined) |
|
// and current token will not change => parsing of the enclosing parameter list will last till the end of time (or OOM) |
|
// to avoid this we'll advance cursor to the next token. |
|
nextToken(); |
|
} |
|
node.questionToken = parseOptionalToken(53 /* QuestionToken */); |
|
node.type = parseParameterType(); |
|
node.initializer = parseBindingElementInitializer(/*inParameter*/ true); |
|
// Do not check for initializers in an ambient context for parameters. This is not |
|
// a grammar error because the grammar allows arbitrary call signatures in |
|
// an ambient context. |
|
// It is actually not necessary for this to be an error at all. The reason is that |
|
// function/constructor implementations are syntactically disallowed in ambient |
|
// contexts. In addition, parameter initializers are semantically disallowed in |
|
// overload signatures. So parameter initializers are transitively disallowed in |
|
// ambient contexts. |
|
return addJSDocComment(finishNode(node)); |
|
} |
|
function parseBindingElementInitializer(inParameter) { |
|
return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); |
|
} |
|
function parseParameterInitializer() { |
|
return parseInitializer(/*inParameter*/ true); |
|
} |
|
function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { |
|
var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; |
|
signature.typeParameters = parseTypeParameters(); |
|
signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); |
|
if (returnTokenRequired) { |
|
parseExpected(returnToken); |
|
signature.type = parseTypeOrTypePredicate(); |
|
} |
|
else if (parseOptional(returnToken)) { |
|
signature.type = parseTypeOrTypePredicate(); |
|
} |
|
} |
|
function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { |
|
// FormalParameters [Yield,Await]: (modified) |
|
// [empty] |
|
// FormalParameterList[?Yield,Await] |
|
// |
|
// FormalParameter[Yield,Await]: (modified) |
|
// BindingElement[?Yield,Await] |
|
// |
|
// BindingElement [Yield,Await]: (modified) |
|
// SingleNameBinding[?Yield,?Await] |
|
// BindingPattern[?Yield,?Await]Initializer [In, ?Yield,?Await] opt |
|
// |
|
// SingleNameBinding [Yield,Await]: |
|
// BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt |
|
if (parseExpected(17 /* OpenParenToken */)) { |
|
var savedYieldContext = inYieldContext(); |
|
var savedAwaitContext = inAwaitContext(); |
|
setYieldContext(yieldContext); |
|
setAwaitContext(awaitContext); |
|
var result = parseDelimitedList(16 /* Parameters */, parseParameter); |
|
setYieldContext(savedYieldContext); |
|
setAwaitContext(savedAwaitContext); |
|
if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { |
|
// Caller insisted that we had to end with a ) We didn't. So just return |
|
// undefined here. |
|
return undefined; |
|
} |
|
return result; |
|
} |
|
// We didn't even have an open paren. If the caller requires a complete parameter list, |
|
// we definitely can't provide that. However, if they're ok with an incomplete one, |
|
// then just return an empty set of parameters. |
|
return requireCompleteParameterList ? undefined : createMissingList(); |
|
} |
|
function parseTypeMemberSemicolon() { |
|
// We allow type members to be separated by commas or (possibly ASI) semicolons. |
|
// First check if it was a comma. If so, we're done with the member. |
|
if (parseOptional(24 /* CommaToken */)) { |
|
return; |
|
} |
|
// Didn't have a comma. We must have a (possible ASI) semicolon. |
|
parseSemicolon(); |
|
} |
|
function parseSignatureMember(kind) { |
|
var node = createNode(kind); |
|
if (kind === 149 /* ConstructSignature */) { |
|
parseExpected(92 /* NewKeyword */); |
|
} |
|
fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); |
|
parseTypeMemberSemicolon(); |
|
return finishNode(node); |
|
} |
|
function isIndexSignature() { |
|
if (token !== 19 /* OpenBracketToken */) { |
|
return false; |
|
} |
|
return lookAhead(isUnambiguouslyIndexSignature); |
|
} |
|
function isUnambiguouslyIndexSignature() { |
|
// The only allowed sequence is: |
|
// |
|
// [id: |
|
// |
|
// However, for error recovery, we also check the following cases: |
|
// |
|
// [... |
|
// [id, |
|
// [id?, |
|
// [id?: |
|
// [id?] |
|
// [public id |
|
// [private id |
|
// [protected id |
|
// [] |
|
// |
|
nextToken(); |
|
if (token === 22 /* DotDotDotToken */ || token === 20 /* CloseBracketToken */) { |
|
return true; |
|
} |
|
if (ts.isModifierKind(token)) { |
|
nextToken(); |
|
if (isIdentifier()) { |
|
return true; |
|
} |
|
} |
|
else if (!isIdentifier()) { |
|
return false; |
|
} |
|
else { |
|
// Skip the identifier |
|
nextToken(); |
|
} |
|
// A colon signifies a well formed indexer |
|
// A comma should be a badly formed indexer because comma expressions are not allowed |
|
// in computed properties. |
|
if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */) { |
|
return true; |
|
} |
|
// Question mark could be an indexer with an optional property, |
|
// or it could be a conditional expression in a computed property. |
|
if (token !== 53 /* QuestionToken */) { |
|
return false; |
|
} |
|
// If any of the following tokens are after the question mark, it cannot |
|
// be a conditional expression, so treat it as an indexer. |
|
nextToken(); |
|
return token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; |
|
} |
|
function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { |
|
var node = createNode(150 /* IndexSignature */, fullStart); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); |
|
node.type = parseTypeAnnotation(); |
|
parseTypeMemberSemicolon(); |
|
return finishNode(node); |
|
} |
|
function parsePropertyOrMethodSignature() { |
|
var fullStart = scanner.getStartPos(); |
|
var name = parsePropertyName(); |
|
var questionToken = parseOptionalToken(53 /* QuestionToken */); |
|
if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { |
|
var method = createNode(143 /* MethodSignature */, fullStart); |
|
method.name = name; |
|
method.questionToken = questionToken; |
|
// Method signatues don't exist in expression contexts. So they have neither |
|
// [Yield] nor [Await] |
|
fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); |
|
parseTypeMemberSemicolon(); |
|
return finishNode(method); |
|
} |
|
else { |
|
var property = createNode(141 /* PropertySignature */, fullStart); |
|
property.name = name; |
|
property.questionToken = questionToken; |
|
property.type = parseTypeAnnotation(); |
|
if (token === 56 /* EqualsToken */) { |
|
// Although type literal properties cannot not have initializers, we attempt |
|
// to parse an initializer so we can report in the checker that an interface |
|
// property or type literal property cannot have an initializer. |
|
property.initializer = parseNonParameterInitializer(); |
|
} |
|
parseTypeMemberSemicolon(); |
|
return finishNode(property); |
|
} |
|
} |
|
function isStartOfTypeMember() { |
|
switch (token) { |
|
case 17 /* OpenParenToken */: |
|
case 25 /* LessThanToken */: |
|
case 19 /* OpenBracketToken */: |
|
return true; |
|
default: |
|
if (ts.isModifierKind(token)) { |
|
var result = lookAhead(isStartOfIndexSignatureDeclaration); |
|
if (result) { |
|
return result; |
|
} |
|
} |
|
return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); |
|
} |
|
} |
|
function isStartOfIndexSignatureDeclaration() { |
|
while (ts.isModifierKind(token)) { |
|
nextToken(); |
|
} |
|
return isIndexSignature(); |
|
} |
|
function isTypeMemberWithLiteralPropertyName() { |
|
nextToken(); |
|
return token === 17 /* OpenParenToken */ || |
|
token === 25 /* LessThanToken */ || |
|
token === 53 /* QuestionToken */ || |
|
token === 54 /* ColonToken */ || |
|
canParseSemicolon(); |
|
} |
|
function parseTypeMember() { |
|
switch (token) { |
|
case 17 /* OpenParenToken */: |
|
case 25 /* LessThanToken */: |
|
return parseSignatureMember(148 /* CallSignature */); |
|
case 19 /* OpenBracketToken */: |
|
// Indexer or computed property |
|
return isIndexSignature() |
|
? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) |
|
: parsePropertyOrMethodSignature(); |
|
case 92 /* NewKeyword */: |
|
if (lookAhead(isStartOfConstructSignature)) { |
|
return parseSignatureMember(149 /* ConstructSignature */); |
|
} |
|
// fall through. |
|
case 9 /* StringLiteral */: |
|
case 8 /* NumericLiteral */: |
|
return parsePropertyOrMethodSignature(); |
|
default: |
|
// Index declaration as allowed as a type member. But as per the grammar, |
|
// they also allow modifiers. So we have to check for an index declaration |
|
// that might be following modifiers. This ensures that things work properly |
|
// when incrementally parsing as the parser will produce the Index declaration |
|
// if it has the same text regardless of whether it is inside a class or an |
|
// object type. |
|
if (ts.isModifierKind(token)) { |
|
var result = tryParse(parseIndexSignatureWithModifiers); |
|
if (result) { |
|
return result; |
|
} |
|
} |
|
if (ts.tokenIsIdentifierOrKeyword(token)) { |
|
return parsePropertyOrMethodSignature(); |
|
} |
|
} |
|
} |
|
function parseIndexSignatureWithModifiers() { |
|
var fullStart = scanner.getStartPos(); |
|
var decorators = parseDecorators(); |
|
var modifiers = parseModifiers(); |
|
return isIndexSignature() |
|
? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) |
|
: undefined; |
|
} |
|
function isStartOfConstructSignature() { |
|
nextToken(); |
|
return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; |
|
} |
|
function parseTypeLiteral() { |
|
var node = createNode(156 /* TypeLiteral */); |
|
node.members = parseObjectTypeMembers(); |
|
return finishNode(node); |
|
} |
|
function parseObjectTypeMembers() { |
|
var members; |
|
if (parseExpected(15 /* OpenBraceToken */)) { |
|
members = parseList(4 /* TypeMembers */, parseTypeMember); |
|
parseExpected(16 /* CloseBraceToken */); |
|
} |
|
else { |
|
members = createMissingList(); |
|
} |
|
return members; |
|
} |
|
function parseTupleType() { |
|
var node = createNode(158 /* TupleType */); |
|
node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); |
|
return finishNode(node); |
|
} |
|
function parseParenthesizedType() { |
|
var node = createNode(161 /* ParenthesizedType */); |
|
parseExpected(17 /* OpenParenToken */); |
|
node.type = parseType(); |
|
parseExpected(18 /* CloseParenToken */); |
|
return finishNode(node); |
|
} |
|
function parseFunctionOrConstructorType(kind) { |
|
var node = createNode(kind); |
|
if (kind === 154 /* ConstructorType */) { |
|
parseExpected(92 /* NewKeyword */); |
|
} |
|
fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); |
|
return finishNode(node); |
|
} |
|
function parseKeywordAndNoDot() { |
|
var node = parseTokenNode(); |
|
return token === 21 /* DotToken */ ? undefined : node; |
|
} |
|
function parseNonArrayType() { |
|
switch (token) { |
|
case 117 /* AnyKeyword */: |
|
case 130 /* StringKeyword */: |
|
case 128 /* NumberKeyword */: |
|
case 120 /* BooleanKeyword */: |
|
case 131 /* SymbolKeyword */: |
|
// If these are followed by a dot, then parse these out as a dotted type reference instead. |
|
var node = tryParse(parseKeywordAndNoDot); |
|
return node || parseTypeReference(); |
|
case 9 /* StringLiteral */: |
|
return parseStringLiteralTypeNode(); |
|
case 103 /* VoidKeyword */: |
|
return parseTokenNode(); |
|
case 97 /* ThisKeyword */: { |
|
var thisKeyword = parseThisTypeNode(); |
|
if (token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { |
|
return parseThisTypePredicate(thisKeyword); |
|
} |
|
else { |
|
return thisKeyword; |
|
} |
|
} |
|
case 101 /* TypeOfKeyword */: |
|
return parseTypeQuery(); |
|
case 15 /* OpenBraceToken */: |
|
return parseTypeLiteral(); |
|
case 19 /* OpenBracketToken */: |
|
return parseTupleType(); |
|
case 17 /* OpenParenToken */: |
|
return parseParenthesizedType(); |
|
default: |
|
return parseTypeReference(); |
|
} |
|
} |
|
function isStartOfType() { |
|
switch (token) { |
|
case 117 /* AnyKeyword */: |
|
case 130 /* StringKeyword */: |
|
case 128 /* NumberKeyword */: |
|
case 120 /* BooleanKeyword */: |
|
case 131 /* SymbolKeyword */: |
|
case 103 /* VoidKeyword */: |
|
case 97 /* ThisKeyword */: |
|
case 101 /* TypeOfKeyword */: |
|
case 15 /* OpenBraceToken */: |
|
case 19 /* OpenBracketToken */: |
|
case 25 /* LessThanToken */: |
|
case 92 /* NewKeyword */: |
|
case 9 /* StringLiteral */: |
|
return true; |
|
case 17 /* OpenParenToken */: |
|
// Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, |
|
// or something that starts a type. We don't want to consider things like '(1)' a type. |
|
return lookAhead(isStartOfParenthesizedOrFunctionType); |
|
default: |
|
return isIdentifier(); |
|
} |
|
} |
|
function isStartOfParenthesizedOrFunctionType() { |
|
nextToken(); |
|
return token === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); |
|
} |
|
function parseArrayTypeOrHigher() { |
|
var type = parseNonArrayType(); |
|
while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { |
|
parseExpected(20 /* CloseBracketToken */); |
|
var node = createNode(157 /* ArrayType */, type.pos); |
|
node.elementType = type; |
|
type = finishNode(node); |
|
} |
|
return type; |
|
} |
|
function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { |
|
var type = parseConstituentType(); |
|
if (token === operator) { |
|
var types = [type]; |
|
types.pos = type.pos; |
|
while (parseOptional(operator)) { |
|
types.push(parseConstituentType()); |
|
} |
|
types.end = getNodeEnd(); |
|
var node = createNode(kind, type.pos); |
|
node.types = types; |
|
type = finishNode(node); |
|
} |
|
return type; |
|
} |
|
function parseIntersectionTypeOrHigher() { |
|
return parseUnionOrIntersectionType(160 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); |
|
} |
|
function parseUnionTypeOrHigher() { |
|
return parseUnionOrIntersectionType(159 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); |
|
} |
|
function isStartOfFunctionType() { |
|
if (token === 25 /* LessThanToken */) { |
|
return true; |
|
} |
|
return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); |
|
} |
|
function isUnambiguouslyStartOfFunctionType() { |
|
nextToken(); |
|
if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { |
|
// ( ) |
|
// ( ... |
|
return true; |
|
} |
|
if (isIdentifier() || ts.isModifierKind(token)) { |
|
nextToken(); |
|
if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || |
|
token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ || |
|
isIdentifier() || ts.isModifierKind(token)) { |
|
// ( id : |
|
// ( id , |
|
// ( id ? |
|
// ( id = |
|
// ( modifier id |
|
return true; |
|
} |
|
if (token === 18 /* CloseParenToken */) { |
|
nextToken(); |
|
if (token === 34 /* EqualsGreaterThanToken */) { |
|
// ( id ) => |
|
return true; |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
function parseTypeOrTypePredicate() { |
|
var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); |
|
var type = parseType(); |
|
if (typePredicateVariable) { |
|
var node = createNode(151 /* TypePredicate */, typePredicateVariable.pos); |
|
node.parameterName = typePredicateVariable; |
|
node.type = type; |
|
return finishNode(node); |
|
} |
|
else { |
|
return type; |
|
} |
|
} |
|
function parseTypePredicatePrefix() { |
|
var id = parseIdentifier(); |
|
if (token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { |
|
nextToken(); |
|
return id; |
|
} |
|
} |
|
function parseType() { |
|
// The rules about 'yield' only apply to actual code/expression contexts. They don't |
|
// apply to 'type' contexts. So we disable these parameters here before moving on. |
|
return doOutsideOfContext(10 /* TypeExcludesFlags */, parseTypeWorker); |
|
} |
|
function parseTypeWorker() { |
|
if (isStartOfFunctionType()) { |
|
return parseFunctionOrConstructorType(153 /* FunctionType */); |
|
} |
|
if (token === 92 /* NewKeyword */) { |
|
return parseFunctionOrConstructorType(154 /* ConstructorType */); |
|
} |
|
return parseUnionTypeOrHigher(); |
|
} |
|
function parseTypeAnnotation() { |
|
return parseOptional(54 /* ColonToken */) ? parseType() : undefined; |
|
} |
|
// EXPRESSIONS |
|
function isStartOfLeftHandSideExpression() { |
|
switch (token) { |
|
case 97 /* ThisKeyword */: |
|
case 95 /* SuperKeyword */: |
|
case 93 /* NullKeyword */: |
|
case 99 /* TrueKeyword */: |
|
case 84 /* FalseKeyword */: |
|
case 8 /* NumericLiteral */: |
|
case 9 /* StringLiteral */: |
|
case 11 /* NoSubstitutionTemplateLiteral */: |
|
case 12 /* TemplateHead */: |
|
case 17 /* OpenParenToken */: |
|
case 19 /* OpenBracketToken */: |
|
case 15 /* OpenBraceToken */: |
|
case 87 /* FunctionKeyword */: |
|
case 73 /* ClassKeyword */: |
|
case 92 /* NewKeyword */: |
|
case 39 /* SlashToken */: |
|
case 61 /* SlashEqualsToken */: |
|
case 69 /* Identifier */: |
|
return true; |
|
default: |
|
return isIdentifier(); |
|
} |
|
} |
|
function isStartOfExpression() { |
|
if (isStartOfLeftHandSideExpression()) { |
|
return true; |
|
} |
|
switch (token) { |
|
case 35 /* PlusToken */: |
|
case 36 /* MinusToken */: |
|
case 50 /* TildeToken */: |
|
case 49 /* ExclamationToken */: |
|
case 78 /* DeleteKeyword */: |
|
case 101 /* TypeOfKeyword */: |
|
case 103 /* VoidKeyword */: |
|
case 41 /* PlusPlusToken */: |
|
case 42 /* MinusMinusToken */: |
|
case 25 /* LessThanToken */: |
|
case 119 /* AwaitKeyword */: |
|
case 114 /* YieldKeyword */: |
|
// Yield/await 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 async function, or in strict mode (or both)) and it started a yield or await expression. |
|
return true; |
|
default: |
|
// Error tolerance. If we see the start of some binary operator, we consider |
|
// that the start of an expression. That way we'll parse out a missing identifier, |
|
// give a good message about an identifier being missing, and then consume the |
|
// rest of the binary expression. |
|
if (isBinaryOperator()) { |
|
return true; |
|
} |
|
return isIdentifier(); |
|
} |
|
} |
|
function isStartOfExpressionStatement() { |
|
// As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. |
|
return token !== 15 /* OpenBraceToken */ && |
|
token !== 87 /* FunctionKeyword */ && |
|
token !== 73 /* ClassKeyword */ && |
|
token !== 55 /* AtToken */ && |
|
isStartOfExpression(); |
|
} |
|
function parseExpression() { |
|
// Expression[in]: |
|
// AssignmentExpression[in] |
|
// Expression[in] , AssignmentExpression[in] |
|
// clear the decorator context when parsing Expression, as it should be unambiguous when parsing a decorator |
|
var saveDecoratorContext = inDecoratorContext(); |
|
if (saveDecoratorContext) { |
|
setDecoratorContext(/*val*/ false); |
|
} |
|
var expr = parseAssignmentExpressionOrHigher(); |
|
var operatorToken; |
|
while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { |
|
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); |
|
} |
|
if (saveDecoratorContext) { |
|
setDecoratorContext(/*val*/ true); |
|
} |
|
return expr; |
|
} |
|
function parseInitializer(inParameter) { |
|
if (token !== 56 /* EqualsToken */) { |
|
// It's not uncommon during typing for the user to miss writing the '=' token. Check if |
|
// there is no newline after the last token and if we're on an expression. If so, parse |
|
// this as an equals-value clause with a missing equals. |
|
// NOTE: There are two places where we allow equals-value clauses. The first is in a |
|
// variable declarator. The second is with a parameter. For variable declarators |
|
// it's more likely that a { would be a allowed (as an object literal). While this |
|
// is also allowed for parameters, the risk is that we consume the { as an object |
|
// literal when it really will be for the block following the parameter. |
|
if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15 /* OpenBraceToken */) || !isStartOfExpression()) { |
|
// preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - |
|
// do not try to parse initializer |
|
return undefined; |
|
} |
|
} |
|
// Initializer[In, Yield] : |
|
// = AssignmentExpression[?In, ?Yield] |
|
parseExpected(56 /* EqualsToken */); |
|
return parseAssignmentExpressionOrHigher(); |
|
} |
|
function parseAssignmentExpressionOrHigher() { |
|
// AssignmentExpression[in,yield]: |
|
// 1) ConditionalExpression[?in,?yield] |
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] |
|
// 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] |
|
// 4) ArrowFunctionExpression[?in,?yield] |
|
// 5) [+Yield] YieldExpression[?In] |
|
// |
|
// Note: for ease of implementation we treat productions '2' and '3' as the same thing. |
|
// (i.e. they're both BinaryExpressions with an assignment operator in it). |
|
// First, do the simple check if we have a YieldExpression (production '5'). |
|
if (isYieldExpression()) { |
|
return parseYieldExpression(); |
|
} |
|
// Then, check if we have an arrow function (production '4') that starts with a parenthesized |
|
// parameter list. If we do, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is |
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done |
|
// with AssignmentExpression if we see one. |
|
var arrowExpression = tryParseParenthesizedArrowFunctionExpression(); |
|
if (arrowExpression) { |
|
return arrowExpression; |
|
} |
|
// Now try to see if we're in production '1', '2' or '3'. A conditional expression can |
|
// start with a LogicalOrExpression, while the assignment productions can only start with |
|
// LeftHandSideExpressions. |
|
// |
|
// So, first, we try to just parse out a BinaryExpression. If we get something that is a |
|
// LeftHandSide or higher, then we can try to parse out the assignment expression part. |
|
// Otherwise, we try to parse out the conditional expression bit. We want to allow any |
|
// binary expression here, so we pass in the 'lowest' precedence here so that it matches |
|
// and consumes anything. |
|
var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); |
|
// To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized |
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single |
|
// identifier and the current token is an arrow. |
|
if (expr.kind === 69 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { |
|
return parseSimpleArrowFunctionExpression(expr); |
|
} |
|
// Now see if we might be in cases '2' or '3'. |
|
// If the expression was a LHS expression, and we have an assignment operator, then |
|
// we're in '2' or '3'. Consume the assignment and return. |
|
// |
|
// Note: we call reScanGreaterToken so that we get an appropriately merged token |
|
// for cases like > > = becoming >>= |
|
if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { |
|
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher()); |
|
} |
|
// It wasn't an assignment or a lambda. This is a conditional expression: |
|
return parseConditionalExpressionRest(expr); |
|
} |
|
function isYieldExpression() { |
|
if (token === 114 /* 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()) { |
|
return true; |
|
} |
|
// We're in a context where 'yield expr' is not allowed. However, if we can |
|
// definitely tell that the user was trying to parse a 'yield expr' and not |
|
// just a normal expr that start with a 'yield' identifier, then parse out |
|
// a 'yield expr'. We can then report an error later that they are only |
|
// allowed in generator expressions. |
|
// |
|
// for example, if we see 'yield(foo)', then we'll have to treat that as an |
|
// invocation expression of something called 'yield'. However, if we have |
|
// 'yield foo' then that is not legal as a normal expression, so we can |
|
// definitely recognize this as a yield expression. |
|
// |
|
// for now we just check if the next token is an identifier. More heuristics |
|
// can be added here later as necessary. We just need to make sure that we |
|
// don't accidently consume something legal. |
|
return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); |
|
} |
|
return false; |
|
} |
|
function nextTokenIsIdentifierOnSameLine() { |
|
nextToken(); |
|
return !scanner.hasPrecedingLineBreak() && isIdentifier(); |
|
} |
|
function parseYieldExpression() { |
|
var node = createNode(187 /* YieldExpression */); |
|
// YieldExpression[In] : |
|
// yield |
|
// yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] |
|
// yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] |
|
nextToken(); |
|
if (!scanner.hasPrecedingLineBreak() && |
|
(token === 37 /* AsteriskToken */ || isStartOfExpression())) { |
|
node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); |
|
node.expression = parseAssignmentExpressionOrHigher(); |
|
return finishNode(node); |
|
} |
|
else { |
|
// if the next token is not on the same line as yield. or we don't have an '*' or |
|
// the start of an expressin, then this is just a simple "yield" expression. |
|
return finishNode(node); |
|
} |
|
} |
|
function parseSimpleArrowFunctionExpression(identifier) { |
|
ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); |
|
var node = createNode(177 /* ArrowFunction */, identifier.pos); |
|
var parameter = createNode(139 /* Parameter */, identifier.pos); |
|
parameter.name = identifier; |
|
finishNode(parameter); |
|
node.parameters = [parameter]; |
|
node.parameters.pos = parameter.pos; |
|
node.parameters.end = parameter.end; |
|
node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); |
|
node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); |
|
return finishNode(node); |
|
} |
|
function tryParseParenthesizedArrowFunctionExpression() { |
|
var triState = isParenthesizedArrowFunctionExpression(); |
|
if (triState === 0 /* False */) { |
|
// It's definitely not a parenthesized arrow function expression. |
|
return undefined; |
|
} |
|
// If we definitely have an arrow function, then we can just parse one, not requiring a |
|
// following => or { token. Otherwise, we *might* have an arrow function. Try to parse |
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an |
|
// expression instead. |
|
var arrowFunction = triState === 1 /* True */ |
|
? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) |
|
: tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); |
|
if (!arrowFunction) { |
|
// Didn't appear to actually be a parenthesized arrow function. Just bail out. |
|
return undefined; |
|
} |
|
var isAsync = !!(arrowFunction.flags & 256 /* Async */); |
|
// If we have an arrow, then try to parse the body. Even if not, try to parse if we |
|
// have an opening brace, just in case we're in an error state. |
|
var lastToken = token; |
|
arrowFunction.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); |
|
arrowFunction.body = (lastToken === 34 /* EqualsGreaterThanToken */ || lastToken === 15 /* OpenBraceToken */) |
|
? parseArrowFunctionExpressionBody(isAsync) |
|
: parseIdentifier(); |
|
return finishNode(arrowFunction); |
|
} |
|
// True -> We definitely expect a parenthesized arrow function here. |
|
// False -> There *cannot* be a parenthesized arrow function here. |
|
// Unknown -> There *might* be a parenthesized arrow function here. |
|
// Speculatively look ahead to be sure, and rollback if not. |
|
function isParenthesizedArrowFunctionExpression() { |
|
if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 118 /* AsyncKeyword */) { |
|
return lookAhead(isParenthesizedArrowFunctionExpressionWorker); |
|
} |
|
if (token === 34 /* EqualsGreaterThanToken */) { |
|
// ERROR RECOVERY TWEAK: |
|
// If we see a standalone => try to parse it as an arrow function expression as that's |
|
// likely what the user intended to write. |
|
return 1 /* True */; |
|
} |
|
// Definitely not a parenthesized arrow function. |
|
return 0 /* False */; |
|
} |
|
function isParenthesizedArrowFunctionExpressionWorker() { |
|
if (token === 118 /* AsyncKeyword */) { |
|
nextToken(); |
|
if (scanner.hasPrecedingLineBreak()) { |
|
return 0 /* False */; |
|
} |
|
if (token !== 17 /* OpenParenToken */ && token !== 25 /* LessThanToken */) { |
|
return 0 /* False */; |
|
} |
|
} |
|
var first = token; |
|
var second = nextToken(); |
|
if (first === 17 /* OpenParenToken */) { |
|
if (second === 18 /* CloseParenToken */) { |
|
// Simple cases: "() =>", "(): ", and "() {". |
|
// This is an arrow function with no parameters. |
|
// The last one is not actually an arrow function, |
|
// but this is probably what the user intended. |
|
var third = nextToken(); |
|
switch (third) { |
|
case 34 /* EqualsGreaterThanToken */: |
|
case 54 /* ColonToken */: |
|
case 15 /* OpenBraceToken */: |
|
return 1 /* True */; |
|
default: |
|
return 0 /* False */; |
|
} |
|
} |
|
// If encounter "([" or "({", this could be the start of a binding pattern. |
|
// Examples: |
|
// ([ x ]) => { } |
|
// ({ x }) => { } |
|
// ([ x ]) |
|
// ({ x }) |
|
if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { |
|
return 2 /* Unknown */; |
|
} |
|
// Simple case: "(..." |
|
// This is an arrow function with a rest parameter. |
|
if (second === 22 /* DotDotDotToken */) { |
|
return 1 /* True */; |
|
} |
|
// If we had "(" followed by something that's not an identifier, |
|
// then this definitely doesn't look like a lambda. |
|
// Note: we could be a little more lenient and allow |
|
// "(public" or "(private". These would not ever actually be allowed, |
|
// but we could provide a good error message instead of bailing out. |
|
if (!isIdentifier()) { |
|
return 0 /* False */; |
|
} |
|
// If we have something like "(a:", then we must have a |
|
// type-annotated parameter in an arrow function expression. |
|
if (nextToken() === 54 /* ColonToken */) { |
|
return 1 /* True */; |
|
} |
|
// This *could* be a parenthesized arrow function. |
|
// Return Unknown to let the caller know. |
|
return 2 /* Unknown */; |
|
} |
|
else { |
|
ts.Debug.assert(first === 25 /* LessThanToken */); |
|
// If we have "<" not followed by an identifier, |
|
// then this definitely is not an arrow function. |
|
if (!isIdentifier()) { |
|
return 0 /* False */; |
|
} |
|
// JSX overrides |
|
if (sourceFile.languageVariant === 1 /* JSX */) { |
|
var isArrowFunctionInJsx = lookAhead(function () { |
|
var third = nextToken(); |
|
if (third === 83 /* ExtendsKeyword */) { |
|
var fourth = nextToken(); |
|
switch (fourth) { |
|
case 56 /* EqualsToken */: |
|
case 27 /* GreaterThanToken */: |
|
return false; |
|
default: |
|
return true; |
|
} |
|
} |
|
else if (third === 24 /* CommaToken */) { |
|
return true; |
|
} |
|
return false; |
|
}); |
|
if (isArrowFunctionInJsx) { |
|
return 1 /* True */; |
|
} |
|
return 0 /* False */; |
|
} |
|
// This *could* be a parenthesized arrow function. |
|
return 2 /* Unknown */; |
|
} |
|
} |
|
function parsePossibleParenthesizedArrowFunctionExpressionHead() { |
|
return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); |
|
} |
|
function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { |
|
var node = createNode(177 /* ArrowFunction */); |
|
setModifiers(node, parseModifiersForArrowFunction()); |
|
var isAsync = !!(node.flags & 256 /* Async */); |
|
// Arrow functions are never generators. |
|
// |
|
// If we're speculatively parsing a signature for a parenthesized arrow function, then |
|
// we have to have a complete parameter list. Otherwise we might see something like |
|
// a => (b => c) |
|
// And think that "(b =>" was actually a parenthesized arrow function with a missing |
|
// close paren. |
|
fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); |
|
// If we couldn't get parameters, we definitely could not parse out an arrow function. |
|
if (!node.parameters) { |
|
return undefined; |
|
} |
|
// Parsing a signature isn't enough. |
|
// Parenthesized arrow signatures often look like other valid expressions. |
|
// For instance: |
|
// - "(x = 10)" is an assignment expression parsed as a signature with a default parameter value. |
|
// - "(x,y)" is a comma expression parsed as a signature with two parameters. |
|
// - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. |
|
// |
|
// So we need just a bit of lookahead to ensure that it can only be a signature. |
|
if (!allowAmbiguity && token !== 34 /* EqualsGreaterThanToken */ && token !== 15 /* OpenBraceToken */) { |
|
// Returning undefined here will cause our caller to rewind to where we started from. |
|
return undefined; |
|
} |
|
return node; |
|
} |
|
function parseArrowFunctionExpressionBody(isAsync) { |
|
if (token === 15 /* OpenBraceToken */) { |
|
return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); |
|
} |
|
if (token !== 23 /* SemicolonToken */ && |
|
token !== 87 /* FunctionKeyword */ && |
|
token !== 73 /* ClassKeyword */ && |
|
isStartOfStatement() && |
|
!isStartOfExpressionStatement()) { |
|
// Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) |
|
// |
|
// Here we try to recover from a potential error situation in the case where the |
|
// user meant to supply a block. For example, if the user wrote: |
|
// |
|
// a => |
|
// let v = 0; |
|
// } |
|
// |
|
// they may be missing an open brace. Check to see if that's the case so we can |
|
// try to recover better. If we don't do this, then the next close curly we see may end |
|
// up preemptively closing the containing construct. |
|
// |
|
// Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. |
|
return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); |
|
} |
|
return isAsync |
|
? doInAwaitContext(parseAssignmentExpressionOrHigher) |
|
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); |
|
} |
|
function parseConditionalExpressionRest(leftOperand) { |
|
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. |
|
var questionToken = parseOptionalToken(53 /* QuestionToken */); |
|
if (!questionToken) { |
|
return leftOperand; |
|
} |
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and |
|
// we do not that for the 'whenFalse' part. |
|
var node = createNode(185 /* ConditionalExpression */, leftOperand.pos); |
|
node.condition = leftOperand; |
|
node.questionToken = questionToken; |
|
node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); |
|
node.colonToken = parseExpectedToken(54 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(54 /* ColonToken */)); |
|
node.whenFalse = parseAssignmentExpressionOrHigher(); |
|
return finishNode(node); |
|
} |
|
function parseBinaryExpressionOrHigher(precedence) { |
|
var leftOperand = parseUnaryExpressionOrHigher(); |
|
return parseBinaryExpressionRest(precedence, leftOperand); |
|
} |
|
function isInOrOfKeyword(t) { |
|
return t === 90 /* InKeyword */ || t === 135 /* OfKeyword */; |
|
} |
|
function parseBinaryExpressionRest(precedence, leftOperand) { |
|
while (true) { |
|
// We either have a binary operator here, or we're finished. We call |
|
// reScanGreaterToken so that we merge token sequences like > and = into >= |
|
reScanGreaterToken(); |
|
var newPrecedence = getBinaryOperatorPrecedence(); |
|
// Check the precedence to see if we should "take" this operator |
|
// - For left associative operator (all operator but **), consume the operator, |
|
// recursively call the function below, and parse binaryExpression as a rightOperand |
|
// of the caller if the new precendence of the operator is greater then or equal to the current precendence. |
|
// For example: |
|
// a - b - c; |
|
// ^token; leftOperand = b. Return b to the caller as a rightOperand |
|
// a * b - c |
|
// ^token; leftOperand = b. Return b to the caller as a rightOperand |
|
// a - b * c; |
|
// ^token; leftOperand = b. Return b * c to the caller as a rightOperand |
|
// - For right associative operator (**), consume the operator, recursively call the function |
|
// and parse binaryExpression as a rightOperand of the caller if the new precendence of |
|
// the operator is strictly grater than the current precendence |
|
// For example: |
|
// a ** b ** c; |
|
// ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand |
|
// a - b ** c; |
|
// ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand |
|
// a ** b - c |
|
// ^token; leftOperand = b. Return b to the caller as a rightOperand |
|
var consumeCurrentOperator = token === 38 /* AsteriskAsteriskToken */ ? |
|
newPrecedence >= precedence : |
|
newPrecedence > precedence; |
|
if (!consumeCurrentOperator) { |
|
break; |
|
} |
|
if (token === 90 /* InKeyword */ && inDisallowInContext()) { |
|
break; |
|
} |
|
if (token === 116 /* AsKeyword */) { |
|
// Make sure we *do* perform ASI for constructs like this: |
|
// var x = foo |
|
// as (Bar) |
|
// This should be parsed as an initialized variable, followed |
|
// by a function call to 'as' with the argument 'Bar' |
|
if (scanner.hasPrecedingLineBreak()) { |
|
break; |
|
} |
|
else { |
|
nextToken(); |
|
leftOperand = makeAsExpression(leftOperand, parseType()); |
|
} |
|
} |
|
else { |
|
leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); |
|
} |
|
} |
|
return leftOperand; |
|
} |
|
function isBinaryOperator() { |
|
if (inDisallowInContext() && token === 90 /* InKeyword */) { |
|
return false; |
|
} |
|
return getBinaryOperatorPrecedence() > 0; |
|
} |
|
function getBinaryOperatorPrecedence() { |
|
switch (token) { |
|
case 52 /* BarBarToken */: |
|
return 1; |
|
case 51 /* AmpersandAmpersandToken */: |
|
return 2; |
|
case 47 /* BarToken */: |
|
return 3; |
|
case 48 /* CaretToken */: |
|
return 4; |
|
case 46 /* AmpersandToken */: |
|
return 5; |
|
case 30 /* EqualsEqualsToken */: |
|
case 31 /* ExclamationEqualsToken */: |
|
case 32 /* EqualsEqualsEqualsToken */: |
|
case 33 /* ExclamationEqualsEqualsToken */: |
|
return 6; |
|
case 25 /* LessThanToken */: |
|
case 27 /* GreaterThanToken */: |
|
case 28 /* LessThanEqualsToken */: |
|
case 29 /* GreaterThanEqualsToken */: |
|
case 91 /* InstanceOfKeyword */: |
|
case 90 /* InKeyword */: |
|
case 116 /* AsKeyword */: |
|
return 7; |
|
case 43 /* LessThanLessThanToken */: |
|
case 44 /* GreaterThanGreaterThanToken */: |
|
case 45 /* GreaterThanGreaterThanGreaterThanToken */: |
|
return 8; |
|
case 35 /* PlusToken */: |
|
case 36 /* MinusToken */: |
|
return 9; |
|
case 37 /* AsteriskToken */: |
|
case 39 /* SlashToken */: |
|
case 40 /* PercentToken */: |
|
return 10; |
|
case 38 /* AsteriskAsteriskToken */: |
|
return 11; |
|
} |
|
// -1 is lower than all other precedences. Returning it will cause binary expression |
|
// parsing to stop. |
|
return -1; |
|
} |
|
function makeBinaryExpression(left, operatorToken, right) { |
|
var node = createNode(184 /* BinaryExpression */, left.pos); |
|
node.left = left; |
|
node.operatorToken = operatorToken; |
|
node.right = right; |
|
return finishNode(node); |
|
} |
|
function makeAsExpression(left, right) { |
|
var node = createNode(192 /* AsExpression */, left.pos); |
|
node.expression = left; |
|
node.type = right; |
|
return finishNode(node); |
|
} |
|
function parsePrefixUnaryExpression() { |
|
var node = createNode(182 /* PrefixUnaryExpression */); |
|
node.operator = token; |
|
nextToken(); |
|
node.operand = parseSimpleUnaryExpression(); |
|
return finishNode(node); |
|
} |
|
function parseDeleteExpression() { |
|
var node = createNode(178 /* DeleteExpression */); |
|
nextToken(); |
|
node.expression = parseSimpleUnaryExpression(); |
|
return finishNode(node); |
|
} |
|
function parseTypeOfExpression() { |
|
var node = createNode(179 /* TypeOfExpression */); |
|
nextToken(); |
|
node.expression = parseSimpleUnaryExpression(); |
|
return finishNode(node); |
|
} |
|
function parseVoidExpression() { |
|
var node = createNode(180 /* VoidExpression */); |
|
nextToken(); |
|
node.expression = parseSimpleUnaryExpression(); |
|
return finishNode(node); |
|
} |
|
function isAwaitExpression() { |
|
if (token === 119 /* AwaitKeyword */) { |
|
if (inAwaitContext()) { |
|
return true; |
|
} |
|
// here we are using similar heuristics as 'isYieldExpression' |
|
return lookAhead(nextTokenIsIdentifierOnSameLine); |
|
} |
|
return false; |
|
} |
|
function parseAwaitExpression() { |
|
var node = createNode(181 /* AwaitExpression */); |
|
nextToken(); |
|
node.expression = parseSimpleUnaryExpression(); |
|
return finishNode(node); |
|
} |
|
/** |
|
* Parse ES7 unary expression and await expression |
|
* |
|
* ES7 UnaryExpression: |
|
* 1) SimpleUnaryExpression[?yield] |
|
* 2) IncrementExpression[?yield] ** UnaryExpression[?yield] |
|
*/ |
|
function parseUnaryExpressionOrHigher() { |
|
if (isAwaitExpression()) { |
|
return parseAwaitExpression(); |
|
} |
|
if (isIncrementExpression()) { |
|
var incrementExpression = parseIncrementExpression(); |
|
return token === 38 /* AsteriskAsteriskToken */ ? |
|
parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : |
|
incrementExpression; |
|
} |
|
var unaryOperator = token; |
|
var simpleUnaryExpression = parseSimpleUnaryExpression(); |
|
if (token === 38 /* AsteriskAsteriskToken */) { |
|
var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); |
|
if (simpleUnaryExpression.kind === 174 /* TypeAssertionExpression */) { |
|
parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); |
|
} |
|
else { |
|
parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator)); |
|
} |
|
} |
|
return simpleUnaryExpression; |
|
} |
|
/** |
|
* Parse ES7 simple-unary expression or higher: |
|
* |
|
* ES7 SimpleUnaryExpression: |
|
* 1) IncrementExpression[?yield] |
|
* 2) delete UnaryExpression[?yield] |
|
* 3) void UnaryExpression[?yield] |
|
* 4) typeof UnaryExpression[?yield] |
|
* 5) + UnaryExpression[?yield] |
|
* 6) - UnaryExpression[?yield] |
|
* 7) ~ UnaryExpression[?yield] |
|
* 8) ! UnaryExpression[?yield] |
|
*/ |
|
function parseSimpleUnaryExpression() { |
|
switch (token) { |
|
case 35 /* PlusToken */: |
|
case 36 /* MinusToken */: |
|
case 50 /* TildeToken */: |
|
case 49 /* ExclamationToken */: |
|
return parsePrefixUnaryExpression(); |
|
case 78 /* DeleteKeyword */: |
|
return parseDeleteExpression(); |
|
case 101 /* TypeOfKeyword */: |
|
return parseTypeOfExpression(); |
|
case 103 /* VoidKeyword */: |
|
return parseVoidExpression(); |
|
case 25 /* LessThanToken */: |
|
// This is modified UnaryExpression grammar in TypeScript |
|
// UnaryExpression (modified): |
|
// < type > UnaryExpression |
|
return parseTypeAssertion(); |
|
default: |
|
return parseIncrementExpression(); |
|
} |
|
} |
|
/** |
|
* Check if the current token can possibly be an ES7 increment expression. |
|
* |
|
* ES7 IncrementExpression: |
|
* LeftHandSideExpression[?Yield] |
|
* LeftHandSideExpression[?Yield][no LineTerminator here]++ |
|
* LeftHandSideExpression[?Yield][no LineTerminator here]-- |
|
* ++LeftHandSideExpression[?Yield] |
|
* --LeftHandSideExpression[?Yield] |
|
*/ |
|
function isIncrementExpression() { |
|
// This function is called inside parseUnaryExpression to decide |
|
// whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly |
|
switch (token) { |
|
case 35 /* PlusToken */: |
|
case 36 /* MinusToken */: |
|
case 50 /* TildeToken */: |
|
case 49 /* ExclamationToken */: |
|
case 78 /* DeleteKeyword */: |
|
case 101 /* TypeOfKeyword */: |
|
case 103 /* VoidKeyword */: |
|
return false; |
|
case 25 /* LessThanToken */: |
|
// If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression |
|
if (sourceFile.languageVariant !== 1 /* JSX */) { |
|
return false; |
|
} |
|
// We are in JSX context and the token is part of JSXElement. |
|
// Fall through |
|
default: |
|
return true; |
|
} |
|
} |
|
/** |
|
* Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression. |
|
* |
|
* ES7 IncrementExpression[yield]: |
|
* 1) LeftHandSideExpression[?yield] |
|
* 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++ |
|
* 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]-- |
|
* 4) ++LeftHandSideExpression[?yield] |
|
* 5) --LeftHandSideExpression[?yield] |
|
* In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression |
|
*/ |
|
function parseIncrementExpression() { |
|
if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { |
|
var node = createNode(182 /* PrefixUnaryExpression */); |
|
node.operator = token; |
|
nextToken(); |
|
node.operand = parseLeftHandSideExpressionOrHigher(); |
|
return finishNode(node); |
|
} |
|
else if (sourceFile.languageVariant === 1 /* JSX */ && token === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { |
|
// JSXElement is part of primaryExpression |
|
return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); |
|
} |
|
var expression = parseLeftHandSideExpressionOrHigher(); |
|
ts.Debug.assert(ts.isLeftHandSideExpression(expression)); |
|
if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { |
|
var node = createNode(183 /* PostfixUnaryExpression */, expression.pos); |
|
node.operand = expression; |
|
node.operator = token; |
|
nextToken(); |
|
return finishNode(node); |
|
} |
|
return expression; |
|
} |
|
function parseLeftHandSideExpressionOrHigher() { |
|
// Original Ecma: |
|
// LeftHandSideExpression: See 11.2 |
|
// NewExpression |
|
// CallExpression |
|
// |
|
// Our simplification: |
|
// |
|
// LeftHandSideExpression: See 11.2 |
|
// MemberExpression |
|
// CallExpression |
|
// |
|
// See comment in parseMemberExpressionOrHigher on how we replaced NewExpression with |
|
// MemberExpression to make our lives easier. |
|
// |
|
// to best understand the below code, it's important to see how CallExpression expands |
|
// out into its own productions: |
|
// |
|
// CallExpression: |
|
// MemberExpression Arguments |
|
// CallExpression Arguments |
|
// CallExpression[Expression] |
|
// CallExpression.IdentifierName |
|
// super ( ArgumentListopt ) |
|
// super.IdentifierName |
|
// |
|
// Because of the recursion in these calls, we need to bottom out first. There are two |
|
// bottom out states we can run into. Either we see 'super' which must start either of |
|
// the last two CallExpression productions. Or we have a MemberExpression which either |
|
// completes the LeftHandSideExpression, or starts the beginning of the first four |
|
// CallExpression productions. |
|
var expression = token === 95 /* SuperKeyword */ |
|
? parseSuperExpression() |
|
: parseMemberExpressionOrHigher(); |
|
// Now, we *may* be complete. However, we might have consumed the start of a |
|
// CallExpression. As such, we need to consume the rest of it here to be complete. |
|
return parseCallExpressionRest(expression); |
|
} |
|
function parseMemberExpressionOrHigher() { |
|
// Note: to make our lives simpler, we decompose the the NewExpression productions and |
|
// place ObjectCreationExpression and FunctionExpression into PrimaryExpression. |
|
// like so: |
|
// |
|
// PrimaryExpression : See 11.1 |
|
// this |
|
// Identifier |
|
// Literal |
|
// ArrayLiteral |
|
// ObjectLiteral |
|
// (Expression) |
|
// FunctionExpression |
|
// new MemberExpression Arguments? |
|
// |
|
// MemberExpression : See 11.2 |
|
// PrimaryExpression |
|
// MemberExpression[Expression] |
|
// MemberExpression.IdentifierName |
|
// |
|
// CallExpression : See 11.2 |
|
// MemberExpression |
|
// CallExpression Arguments |
|
// CallExpression[Expression] |
|
// CallExpression.IdentifierName |
|
// |
|
// Technically this is ambiguous. i.e. CallExpression defines: |
|
// |
|
// CallExpression: |
|
// CallExpression Arguments |
|
// |
|
// If you see: "new Foo()" |
|
// |
|
// Then that could be treated as a single ObjectCreationExpression, or it could be |
|
// treated as the invocation of "new Foo". We disambiguate that in code (to match |
|
// the original grammar) by making sure that if we see an ObjectCreationExpression |
|
// we always consume arguments if they are there. So we treat "new Foo()" as an |
|
// object creation only, and not at all as an invocation) Another way to think |
|
// about this is that for every "new" that we see, we will consume an argument list if |
|
// it is there as part of the *associated* object creation node. Any additional |
|
// argument lists we see, will become invocation expressions. |
|
// |
|
// Because there are no other places in the grammar now that refer to FunctionExpression |
|
// or ObjectCreationExpression, it is safe to push down into the PrimaryExpression |
|
// production. |
|
// |
|
// Because CallExpression and MemberExpression are left recursive, we need to bottom out |
|
// of the recursion immediately. So we parse out a primary expression to start with. |
|
var expression = parsePrimaryExpression(); |
|
return parseMemberExpressionRest(expression); |
|
} |
|
function parseSuperExpression() { |
|
var expression = parseTokenNode(); |
|
if (token === 17 /* OpenParenToken */ || token === 21 /* DotToken */ || token === 19 /* OpenBracketToken */) { |
|
return expression; |
|
} |
|
// If we have seen "super" it must be followed by '(' or '.'. |
|
// If it wasn't then just try to parse out a '.' and report an error. |
|
var node = createNode(169 /* PropertyAccessExpression */, expression.pos); |
|
node.expression = expression; |
|
node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); |
|
node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); |
|
return finishNode(node); |
|
} |
|
function tagNamesAreEquivalent(lhs, rhs) { |
|
if (lhs.kind !== rhs.kind) { |
|
return false; |
|
} |
|
if (lhs.kind === 69 /* Identifier */) { |
|
return lhs.text === rhs.text; |
|
} |
|
return lhs.right.text === rhs.right.text && |
|
tagNamesAreEquivalent(lhs.left, rhs.left); |
|
} |
|
function parseJsxElementOrSelfClosingElement(inExpressionContext) { |
|
var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); |
|
var result; |
|
if (opening.kind === 238 /* JsxOpeningElement */) { |
|
var node = createNode(236 /* JsxElement */, opening.pos); |
|
node.openingElement = opening; |
|
node.children = parseJsxChildren(node.openingElement.tagName); |
|
node.closingElement = parseJsxClosingElement(inExpressionContext); |
|
if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { |
|
parseErrorAtPosition(node.closingElement.pos, node.closingElement.end - node.closingElement.pos, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, node.openingElement.tagName)); |
|
} |
|
result = finishNode(node); |
|
} |
|
else { |
|
ts.Debug.assert(opening.kind === 237 /* JsxSelfClosingElement */); |
|
// Nothing else to do for self-closing elements |
|
result = opening; |
|
} |
|
// If the user writes the invalid code '<div></div><div></div>' in an expression context (i.e. not wrapped in |
|
// an enclosing tag), we'll naively try to parse ^ this as a 'less than' operator and the remainder of the tag |
|
// as garbage, which will cause the formatter to badly mangle the JSX. Perform a speculative parse of a JSX |
|
// element if we see a < token so that we can wrap it in a synthetic binary expression so the formatter |
|
// does less damage and we can report a better error. |
|
// Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios |
|
// of one sort or another. |
|
if (inExpressionContext && token === 25 /* LessThanToken */) { |
|
var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); |
|
if (invalidElement) { |
|
parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); |
|
var badNode = createNode(184 /* BinaryExpression */, result.pos); |
|
badNode.end = invalidElement.end; |
|
badNode.left = result; |
|
badNode.right = invalidElement; |
|
badNode.operatorToken = createMissingNode(24 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); |
|
badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; |
|
return badNode; |
|
} |
|
} |
|
return result; |
|
} |
|
function parseJsxText() { |
|
var node = createNode(239 /* JsxText */, scanner.getStartPos()); |
|
token = scanner.scanJsxToken(); |
|
return finishNode(node); |
|
} |
|
function parseJsxChild() { |
|
switch (token) { |
|
case 239 /* JsxText */: |
|
return parseJsxText(); |
|
case 15 /* OpenBraceToken */: |
|
return parseJsxExpression(/*inExpressionContext*/ false); |
|
case 25 /* LessThanToken */: |
|
return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); |
|
} |
|
ts.Debug.fail("Unknown JSX child kind " + token); |
|
} |
|
function parseJsxChildren(openingTagName) { |
|
var result = []; |
|
result.pos = scanner.getStartPos(); |
|
var saveParsingContext = parsingContext; |
|
parsingContext |= 1 << 14 /* JsxChildren */; |
|
while (true) { |
|
token = scanner.reScanJsxToken(); |
|
if (token === 26 /* LessThanSlashToken */) { |
|
// Closing tag |
|
break; |
|
} |
|
else if (token === 1 /* EndOfFileToken */) { |
|
// If we hit EOF, issue the error at the tag that lacks the closing element |
|
// rather than at the end of the file (which is useless) |
|
parseErrorAtPosition(openingTagName.pos, openingTagName.end - openingTagName.pos, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); |
|
break; |
|
} |
|
result.push(parseJsxChild()); |
|
} |
|
result.end = scanner.getTokenPos(); |
|
parsingContext = saveParsingContext; |
|
return result; |
|
} |
|
function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { |
|
var fullStart = scanner.getStartPos(); |
|
parseExpected(25 /* LessThanToken */); |
|
var tagName = parseJsxElementName(); |
|
var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); |
|
var node; |
|
if (token === 27 /* GreaterThanToken */) { |
|
// Closing tag, so scan the immediately-following text with the JSX scanning instead |
|
// of regular scanning to avoid treating illegal characters (e.g. '#') as immediate |
|
// scanning errors |
|
node = createNode(238 /* JsxOpeningElement */, fullStart); |
|
scanJsxText(); |
|
} |
|
else { |
|
parseExpected(39 /* SlashToken */); |
|
if (inExpressionContext) { |
|
parseExpected(27 /* GreaterThanToken */); |
|
} |
|
else { |
|
parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); |
|
scanJsxText(); |
|
} |
|
node = createNode(237 /* JsxSelfClosingElement */, fullStart); |
|
} |
|
node.tagName = tagName; |
|
node.attributes = attributes; |
|
return finishNode(node); |
|
} |
|
function parseJsxElementName() { |
|
scanJsxIdentifier(); |
|
var elementName = parseIdentifierName(); |
|
while (parseOptional(21 /* DotToken */)) { |
|
scanJsxIdentifier(); |
|
var node = createNode(136 /* QualifiedName */, elementName.pos); |
|
node.left = elementName; |
|
node.right = parseIdentifierName(); |
|
elementName = finishNode(node); |
|
} |
|
return elementName; |
|
} |
|
function parseJsxExpression(inExpressionContext) { |
|
var node = createNode(243 /* JsxExpression */); |
|
parseExpected(15 /* OpenBraceToken */); |
|
if (token !== 16 /* CloseBraceToken */) { |
|
node.expression = parseAssignmentExpressionOrHigher(); |
|
} |
|
if (inExpressionContext) { |
|
parseExpected(16 /* CloseBraceToken */); |
|
} |
|
else { |
|
parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); |
|
scanJsxText(); |
|
} |
|
return finishNode(node); |
|
} |
|
function parseJsxAttribute() { |
|
if (token === 15 /* OpenBraceToken */) { |
|
return parseJsxSpreadAttribute(); |
|
} |
|
scanJsxIdentifier(); |
|
var node = createNode(241 /* JsxAttribute */); |
|
node.name = parseIdentifierName(); |
|
if (parseOptional(56 /* EqualsToken */)) { |
|
switch (token) { |
|
case 9 /* StringLiteral */: |
|
node.initializer = parseLiteralNode(); |
|
break; |
|
default: |
|
node.initializer = parseJsxExpression(/*inExpressionContext*/ true); |
|
break; |
|
} |
|
} |
|
return finishNode(node); |
|
} |
|
function parseJsxSpreadAttribute() { |
|
var node = createNode(242 /* JsxSpreadAttribute */); |
|
parseExpected(15 /* OpenBraceToken */); |
|
parseExpected(22 /* DotDotDotToken */); |
|
node.expression = parseExpression(); |
|
parseExpected(16 /* CloseBraceToken */); |
|
return finishNode(node); |
|
} |
|
function parseJsxClosingElement(inExpressionContext) { |
|
var node = createNode(240 /* JsxClosingElement */); |
|
parseExpected(26 /* LessThanSlashToken */); |
|
node.tagName = parseJsxElementName(); |
|
if (inExpressionContext) { |
|
parseExpected(27 /* GreaterThanToken */); |
|
} |
|
else { |
|
parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); |
|
scanJsxText(); |
|
} |
|
return finishNode(node); |
|
} |
|
function parseTypeAssertion() { |
|
var node = createNode(174 /* TypeAssertionExpression */); |
|
parseExpected(25 /* LessThanToken */); |
|
node.type = parseType(); |
|
parseExpected(27 /* GreaterThanToken */); |
|
node.expression = parseSimpleUnaryExpression(); |
|
return finishNode(node); |
|
} |
|
function parseMemberExpressionRest(expression) { |
|
while (true) { |
|
var dotToken = parseOptionalToken(21 /* DotToken */); |
|
if (dotToken) { |
|
var propertyAccess = createNode(169 /* PropertyAccessExpression */, expression.pos); |
|
propertyAccess.expression = expression; |
|
propertyAccess.dotToken = dotToken; |
|
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); |
|
expression = finishNode(propertyAccess); |
|
continue; |
|
} |
|
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName |
|
if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { |
|
var indexedAccess = createNode(170 /* ElementAccessExpression */, expression.pos); |
|
indexedAccess.expression = expression; |
|
// It's not uncommon for a user to write: "new Type[]". |
|
// Check for that common pattern and report a better error message. |
|
if (token !== 20 /* CloseBracketToken */) { |
|
indexedAccess.argumentExpression = allowInAnd(parseExpression); |
|
if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { |
|
var literal = indexedAccess.argumentExpression; |
|
literal.text = internIdentifier(literal.text); |
|
} |
|
} |
|
parseExpected(20 /* CloseBracketToken */); |
|
expression = finishNode(indexedAccess); |
|
continue; |
|
} |
|
if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { |
|
var tagExpression = createNode(173 /* TaggedTemplateExpression */, expression.pos); |
|
tagExpression.tag = expression; |
|
tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ |
|
? parseLiteralNode() |
|
: parseTemplateExpression(); |
|
expression = finishNode(tagExpression); |
|
continue; |
|
} |
|
return expression; |
|
} |
|
} |
|
function parseCallExpressionRest(expression) { |
|
while (true) { |
|
expression = parseMemberExpressionRest(expression); |
|
if (token === 25 /* LessThanToken */) { |
|
// See if this is the start of a generic invocation. If so, consume it and |
|
// keep checking for postfix expressions. Otherwise, it's just a '<' that's |
|
// part of an arithmetic expression. Break out so we consume it higher in the |
|
// stack. |
|
var typeArguments = tryParse(parseTypeArgumentsInExpression); |
|
if (!typeArguments) { |
|
return expression; |
|
} |
|
var callExpr = createNode(171 /* CallExpression */, expression.pos); |
|
callExpr.expression = expression; |
|
callExpr.typeArguments = typeArguments; |
|
callExpr.arguments = parseArgumentList(); |
|
expression = finishNode(callExpr); |
|
continue; |
|
} |
|
else if (token === 17 /* OpenParenToken */) { |
|
var callExpr = createNode(171 /* CallExpression */, expression.pos); |
|
callExpr.expression = expression; |
|
callExpr.arguments = parseArgumentList(); |
|
expression = finishNode(callExpr); |
|
continue; |
|
} |
|
return expression; |
|
} |
|
} |
|
function parseArgumentList() { |
|
parseExpected(17 /* OpenParenToken */); |
|
var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); |
|
parseExpected(18 /* CloseParenToken */); |
|
return result; |
|
} |
|
function parseTypeArgumentsInExpression() { |
|
if (!parseOptional(25 /* LessThanToken */)) { |
|
return undefined; |
|
} |
|
var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); |
|
if (!parseExpected(27 /* GreaterThanToken */)) { |
|
// If it doesn't have the closing > then it's definitely not an type argument list. |
|
return undefined; |
|
} |
|
// If we have a '<', then only parse this as a arugment list if the type arguments |
|
// are complete and we have an open paren. if we don't, rewind and return nothing. |
|
return typeArguments && canFollowTypeArgumentsInExpression() |
|
? typeArguments |
|
: undefined; |
|
} |
|
function canFollowTypeArgumentsInExpression() { |
|
switch (token) { |
|
case 17 /* OpenParenToken */: // foo<x>( |
|
// this case are the only case where this token can legally follow a type argument |
|
// list. So we definitely want to treat this as a type arg list. |
|
case 21 /* DotToken */: // foo<x>. |
|
case 18 /* CloseParenToken */: // foo<x>) |
|
case 20 /* CloseBracketToken */: // foo<x>] |
|
case 54 /* ColonToken */: // foo<x>: |
|
case 23 /* SemicolonToken */: // foo<x>; |
|
case 53 /* QuestionToken */: // foo<x>? |
|
case 30 /* EqualsEqualsToken */: // foo<x> == |
|
case 32 /* EqualsEqualsEqualsToken */: // foo<x> === |
|
case 31 /* ExclamationEqualsToken */: // foo<x> != |
|
case 33 /* ExclamationEqualsEqualsToken */: // foo<x> !== |
|
case 51 /* AmpersandAmpersandToken */: // foo<x> && |
|
case 52 /* BarBarToken */: // foo<x> || |
|
case 48 /* CaretToken */: // foo<x> ^ |
|
case 46 /* AmpersandToken */: // foo<x> & |
|
case 47 /* BarToken */: // foo<x> | |
|
case 16 /* CloseBraceToken */: // foo<x> } |
|
case 1 /* EndOfFileToken */: |
|
// these cases can't legally follow a type arg list. However, they're not legal |
|
// expressions either. The user is probably in the middle of a generic type. So |
|
// treat it as such. |
|
return true; |
|
case 24 /* CommaToken */: // foo<x>, |
|
case 15 /* OpenBraceToken */: // foo<x> { |
|
// We don't want to treat these as type arguments. Otherwise we'll parse this |
|
// as an invocation expression. Instead, we want to parse out the expression |
|
// in isolation from the type arguments. |
|
default: |
|
// Anything else treat as an expression. |
|
return false; |
|
} |
|
} |
|
function parsePrimaryExpression() { |
|
switch (token) { |
|
case 8 /* NumericLiteral */: |
|
case 9 /* StringLiteral */: |
|
case 11 /* NoSubstitutionTemplateLiteral */: |
|
return parseLiteralNode(); |
|
case 97 /* ThisKeyword */: |
|
case 95 /* SuperKeyword */: |
|
case 93 /* NullKeyword */: |
|
case 99 /* TrueKeyword */: |
|
case 84 /* FalseKeyword */: |
|
return parseTokenNode(); |
|
case 17 /* OpenParenToken */: |
|
return parseParenthesizedExpression(); |
|
case 19 /* OpenBracketToken */: |
|
return parseArrayLiteralExpression(); |
|
case 15 /* OpenBraceToken */: |
|
return parseObjectLiteralExpression(); |
|
case 118 /* AsyncKeyword */: |
|
// Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. |
|
// If we encounter `async [no LineTerminator here] function` then this is an async |
|
// function; otherwise, its an identifier. |
|
if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { |
|
break; |
|
} |
|
return parseFunctionExpression(); |
|
case 73 /* ClassKeyword */: |
|
return parseClassExpression(); |
|
case 87 /* FunctionKeyword */: |
|
return parseFunctionExpression(); |
|
case 92 /* NewKeyword */: |
|
return parseNewExpression(); |
|
case 39 /* SlashToken */: |
|
case 61 /* SlashEqualsToken */: |
|
if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { |
|
return parseLiteralNode(); |
|
} |
|
break; |
|
case 12 /* TemplateHead */: |
|
return parseTemplateExpression(); |
|
} |
|
return parseIdentifier(ts.Diagnostics.Expression_expected); |
|
} |
|
function parseParenthesizedExpression() { |
|
var node = createNode(175 /* ParenthesizedExpression */); |
|
parseExpected(17 /* OpenParenToken */); |
|
node.expression = allowInAnd(parseExpression); |
|
parseExpected(18 /* CloseParenToken */); |
|
return finishNode(node); |
|
} |
|
function parseSpreadElement() { |
|
var node = createNode(188 /* SpreadElementExpression */); |
|
parseExpected(22 /* DotDotDotToken */); |
|
node.expression = parseAssignmentExpressionOrHigher(); |
|
return finishNode(node); |
|
} |
|
function parseArgumentOrArrayLiteralElement() { |
|
return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : |
|
token === 24 /* CommaToken */ ? createNode(190 /* OmittedExpression */) : |
|
parseAssignmentExpressionOrHigher(); |
|
} |
|
function parseArgumentExpression() { |
|
return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); |
|
} |
|
function parseArrayLiteralExpression() { |
|
var node = createNode(167 /* ArrayLiteralExpression */); |
|
parseExpected(19 /* OpenBracketToken */); |
|
if (scanner.hasPrecedingLineBreak()) |
|
node.flags |= 1024 /* MultiLine */; |
|
node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); |
|
parseExpected(20 /* CloseBracketToken */); |
|
return finishNode(node); |
|
} |
|
function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { |
|
if (parseContextualModifier(123 /* GetKeyword */)) { |
|
return parseAccessorDeclaration(146 /* GetAccessor */, fullStart, decorators, modifiers); |
|
} |
|
else if (parseContextualModifier(129 /* SetKeyword */)) { |
|
return parseAccessorDeclaration(147 /* SetAccessor */, fullStart, decorators, modifiers); |
|
} |
|
return undefined; |
|
} |
|
function parseObjectLiteralElement() { |
|
var fullStart = scanner.getStartPos(); |
|
var decorators = parseDecorators(); |
|
var modifiers = parseModifiers(); |
|
var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); |
|
if (accessor) { |
|
return accessor; |
|
} |
|
var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); |
|
var tokenIsIdentifier = isIdentifier(); |
|
var propertyName = parsePropertyName(); |
|
// Disallowing of optional property assignments happens in the grammar checker. |
|
var questionToken = parseOptionalToken(53 /* QuestionToken */); |
|
if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { |
|
return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); |
|
} |
|
// check if it is short-hand property assignment or normal property assignment |
|
// NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production |
|
// CoverInitializedName[Yield] : |
|
// IdentifierReference[?Yield] Initializer[In, ?Yield] |
|
// this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern |
|
var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); |
|
if (isShorthandPropertyAssignment) { |
|
var shorthandDeclaration = createNode(249 /* ShorthandPropertyAssignment */, fullStart); |
|
shorthandDeclaration.name = propertyName; |
|
shorthandDeclaration.questionToken = questionToken; |
|
var equalsToken = parseOptionalToken(56 /* EqualsToken */); |
|
if (equalsToken) { |
|
shorthandDeclaration.equalsToken = equalsToken; |
|
shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); |
|
} |
|
return addJSDocComment(finishNode(shorthandDeclaration)); |
|
} |
|
else { |
|
var propertyAssignment = createNode(248 /* PropertyAssignment */, fullStart); |
|
propertyAssignment.modifiers = modifiers; |
|
propertyAssignment.name = propertyName; |
|
propertyAssignment.questionToken = questionToken; |
|
parseExpected(54 /* ColonToken */); |
|
propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); |
|
return addJSDocComment(finishNode(propertyAssignment)); |
|
} |
|
} |
|
function parseObjectLiteralExpression() { |
|
var node = createNode(168 /* ObjectLiteralExpression */); |
|
parseExpected(15 /* OpenBraceToken */); |
|
if (scanner.hasPrecedingLineBreak()) { |
|
node.flags |= 1024 /* MultiLine */; |
|
} |
|
node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); |
|
parseExpected(16 /* CloseBraceToken */); |
|
return finishNode(node); |
|
} |
|
function parseFunctionExpression() { |
|
// GeneratorExpression: |
|
// function* BindingIdentifier [Yield][opt](FormalParameters[Yield]){ GeneratorBody } |
|
// |
|
// FunctionExpression: |
|
// function BindingIdentifier[opt](FormalParameters){ FunctionBody } |
|
var saveDecoratorContext = inDecoratorContext(); |
|
if (saveDecoratorContext) { |
|
setDecoratorContext(/*val*/ false); |
|
} |
|
var node = createNode(176 /* FunctionExpression */); |
|
setModifiers(node, parseModifiers()); |
|
parseExpected(87 /* FunctionKeyword */); |
|
node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); |
|
var isGenerator = !!node.asteriskToken; |
|
var isAsync = !!(node.flags & 256 /* Async */); |
|
node.name = |
|
isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : |
|
isGenerator ? doInYieldContext(parseOptionalIdentifier) : |
|
isAsync ? doInAwaitContext(parseOptionalIdentifier) : |
|
parseOptionalIdentifier(); |
|
fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); |
|
node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); |
|
if (saveDecoratorContext) { |
|
setDecoratorContext(/*val*/ true); |
|
} |
|
return addJSDocComment(finishNode(node)); |
|
} |
|
function parseOptionalIdentifier() { |
|
return isIdentifier() ? parseIdentifier() : undefined; |
|
} |
|
function parseNewExpression() { |
|
var node = createNode(172 /* NewExpression */); |
|
parseExpected(92 /* NewKeyword */); |
|
node.expression = parseMemberExpressionOrHigher(); |
|
node.typeArguments = tryParse(parseTypeArgumentsInExpression); |
|
if (node.typeArguments || token === 17 /* OpenParenToken */) { |
|
node.arguments = parseArgumentList(); |
|
} |
|
return finishNode(node); |
|
} |
|
// STATEMENTS |
|
function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { |
|
var node = createNode(195 /* Block */); |
|
if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { |
|
node.statements = parseList(1 /* BlockStatements */, parseStatement); |
|
parseExpected(16 /* CloseBraceToken */); |
|
} |
|
else { |
|
node.statements = createMissingList(); |
|
} |
|
return finishNode(node); |
|
} |
|
function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { |
|
var savedYieldContext = inYieldContext(); |
|
setYieldContext(allowYield); |
|
var savedAwaitContext = inAwaitContext(); |
|
setAwaitContext(allowAwait); |
|
// We may be in a [Decorator] context when parsing a function expression or |
|
// arrow function. The body of the function is not in [Decorator] context. |
|
var saveDecoratorContext = inDecoratorContext(); |
|
if (saveDecoratorContext) { |
|
setDecoratorContext(/*val*/ false); |
|
} |
|
var block = parseBlock(ignoreMissingOpenBrace, diagnosticMessage); |
|
if (saveDecoratorContext) { |
|
setDecoratorContext(/*val*/ true); |
|
} |
|
setYieldContext(savedYieldContext); |
|
setAwaitContext(savedAwaitContext); |
|
return block; |
|
} |
|
function parseEmptyStatement() { |
|
var node = createNode(197 /* EmptyStatement */); |
|
parseExpected(23 /* SemicolonToken */); |
|
return finishNode(node); |
|
} |
|
function parseIfStatement() { |
|
var node = createNode(199 /* IfStatement */); |
|
parseExpected(88 /* IfKeyword */); |
|
parseExpected(17 /* OpenParenToken */); |
|
node.expression = allowInAnd(parseExpression); |
|
parseExpected(18 /* CloseParenToken */); |
|
node.thenStatement = parseStatement(); |
|
node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; |
|
return finishNode(node); |
|
} |
|
function parseDoStatement() { |
|
var node = createNode(200 /* DoStatement */); |
|
parseExpected(79 /* DoKeyword */); |
|
node.statement = parseStatement(); |
|
parseExpected(104 /* WhileKeyword */); |
|
parseExpected(17 /* OpenParenToken */); |
|
node.expression = allowInAnd(parseExpression); |
|
parseExpected(18 /* CloseParenToken */); |
|
// From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html |
|
// 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in |
|
// spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby |
|
// do;while(0)x will have a semicolon inserted before x. |
|
parseOptional(23 /* SemicolonToken */); |
|
return finishNode(node); |
|
} |
|
function parseWhileStatement() { |
|
var node = createNode(201 /* WhileStatement */); |
|
parseExpected(104 /* WhileKeyword */); |
|
parseExpected(17 /* OpenParenToken */); |
|
node.expression = allowInAnd(parseExpression); |
|
parseExpected(18 /* CloseParenToken */); |
|
node.statement = parseStatement(); |
|
return finishNode(node); |
|
} |
|
function parseForOrForInOrForOfStatement() { |
|
var pos = getNodePos(); |
|
parseExpected(86 /* ForKeyword */); |
|
parseExpected(17 /* OpenParenToken */); |
|
var initializer = undefined; |
|
if (token !== 23 /* SemicolonToken */) { |
|
if (token === 102 /* VarKeyword */ || token === 108 /* LetKeyword */ || token === 74 /* ConstKeyword */) { |
|
initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); |
|
} |
|
else { |
|
initializer = disallowInAnd(parseExpression); |
|
} |
|
} |
|
var forOrForInOrForOfStatement; |
|
if (parseOptional(90 /* InKeyword */)) { |
|
var forInStatement = createNode(203 /* ForInStatement */, pos); |
|
forInStatement.initializer = initializer; |
|
forInStatement.expression = allowInAnd(parseExpression); |
|
parseExpected(18 /* CloseParenToken */); |
|
forOrForInOrForOfStatement = forInStatement; |
|
} |
|
else if (parseOptional(135 /* OfKeyword */)) { |
|
var forOfStatement = createNode(204 /* ForOfStatement */, pos); |
|
forOfStatement.initializer = initializer; |
|
forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); |
|
parseExpected(18 /* CloseParenToken */); |
|
forOrForInOrForOfStatement = forOfStatement; |
|
} |
|
else { |
|
var forStatement = createNode(202 /* ForStatement */, pos); |
|
forStatement.initializer = initializer; |
|
parseExpected(23 /* SemicolonToken */); |
|
if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { |
|
forStatement.condition = allowInAnd(parseExpression); |
|
} |
|
parseExpected(23 /* SemicolonToken */); |
|
if (token !== 18 /* CloseParenToken */) { |
|
forStatement.incrementor = allowInAnd(parseExpression); |
|
} |
|
parseExpected(18 /* CloseParenToken */); |
|
forOrForInOrForOfStatement = forStatement; |
|
} |
|
forOrForInOrForOfStatement.statement = parseStatement(); |
|
return finishNode(forOrForInOrForOfStatement); |
|
} |
|
function parseBreakOrContinueStatement(kind) { |
|
var node = createNode(kind); |
|
parseExpected(kind === 206 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); |
|
if (!canParseSemicolon()) { |
|
node.label = parseIdentifier(); |
|
} |
|
parseSemicolon(); |
|
return finishNode(node); |
|
} |
|
function parseReturnStatement() { |
|
var node = createNode(207 /* ReturnStatement */); |
|
parseExpected(94 /* ReturnKeyword */); |
|
if (!canParseSemicolon()) { |
|
node.expression = allowInAnd(parseExpression); |
|
} |
|
parseSemicolon(); |
|
return finishNode(node); |
|
} |
|
function parseWithStatement() { |
|
var node = createNode(208 /* WithStatement */); |
|
parseExpected(105 /* WithKeyword */); |
|
parseExpected(17 /* OpenParenToken */); |
|
node.expression = allowInAnd(parseExpression); |
|
parseExpected(18 /* CloseParenToken */); |
|
node.statement = parseStatement(); |
|
return finishNode(node); |
|
} |
|
function parseCaseClause() { |
|
var node = createNode(244 /* CaseClause */); |
|
parseExpected(71 /* CaseKeyword */); |
|
node.expression = allowInAnd(parseExpression); |
|
parseExpected(54 /* ColonToken */); |
|
node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); |
|
return finishNode(node); |
|
} |
|
function parseDefaultClause() { |
|
var node = createNode(245 /* DefaultClause */); |
|
parseExpected(77 /* DefaultKeyword */); |
|
parseExpected(54 /* ColonToken */); |
|
node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); |
|
return finishNode(node); |
|
} |
|
function parseCaseOrDefaultClause() { |
|
return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); |
|
} |
|
function parseSwitchStatement() { |
|
var node = createNode(209 /* SwitchStatement */); |
|
parseExpected(96 /* SwitchKeyword */); |
|
parseExpected(17 /* OpenParenToken */); |
|
node.expression = allowInAnd(parseExpression); |
|
parseExpected(18 /* CloseParenToken */); |
|
var caseBlock = createNode(223 /* CaseBlock */, scanner.getStartPos()); |
|
parseExpected(15 /* OpenBraceToken */); |
|
caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); |
|
parseExpected(16 /* CloseBraceToken */); |
|
node.caseBlock = finishNode(caseBlock); |
|
return finishNode(node); |
|
} |
|
function parseThrowStatement() { |
|
// ThrowStatement[Yield] : |
|
// throw [no LineTerminator here]Expression[In, ?Yield]; |
|
// Because of automatic semicolon insertion, we need to report error if this |
|
// throw could be terminated with a semicolon. Note: we can't call 'parseExpression' |
|
// directly as that might consume an expression on the following line. |
|
// We just return 'undefined' in that case. The actual error will be reported in the |
|
// grammar walker. |
|
var node = createNode(211 /* ThrowStatement */); |
|
parseExpected(98 /* ThrowKeyword */); |
|
node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); |
|
parseSemicolon(); |
|
return finishNode(node); |
|
} |
|
// TODO: Review for error recovery |
|
function parseTryStatement() { |
|
var node = createNode(212 /* TryStatement */); |
|
parseExpected(100 /* TryKeyword */); |
|
node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); |
|
node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; |
|
// If we don't have a catch clause, then we must have a finally clause. Try to parse |
|
// one out no matter what. |
|
if (!node.catchClause || token === 85 /* FinallyKeyword */) { |
|
parseExpected(85 /* FinallyKeyword */); |
|
node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); |
|
} |
|
return finishNode(node); |
|
} |
|
function parseCatchClause() { |
|
var result = createNode(247 /* CatchClause */); |
|
parseExpected(72 /* CatchKeyword */); |
|
if (parseExpected(17 /* OpenParenToken */)) { |
|
result.variableDeclaration = parseVariableDeclaration(); |
|
} |
|
parseExpected(18 /* CloseParenToken */); |
|
result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); |
|
return finishNode(result); |
|
} |
|
function parseDebuggerStatement() { |
|
var node = createNode(213 /* DebuggerStatement */); |
|
parseExpected(76 /* DebuggerKeyword */); |
|
parseSemicolon(); |
|
return finishNode(node); |
|
} |
|
function parseExpressionOrLabeledStatement() { |
|
// Avoiding having to do the lookahead for a labeled statement by just trying to parse |
|
// out an expression, seeing if it is identifier and then seeing if it is followed by |
|
// a colon. |
|
var fullStart = scanner.getStartPos(); |
|
var expression = allowInAnd(parseExpression); |
|
if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { |
|
var labeledStatement = createNode(210 /* LabeledStatement */, fullStart); |
|
labeledStatement.label = expression; |
|
labeledStatement.statement = parseStatement(); |
|
return addJSDocComment(finishNode(labeledStatement)); |
|
} |
|
else { |
|
var expressionStatement = createNode(198 /* ExpressionStatement */, fullStart); |
|
expressionStatement.expression = expression; |
|
parseSemicolon(); |
|
return addJSDocComment(finishNode(expressionStatement)); |
|
} |
|
} |
|
function nextTokenIsIdentifierOrKeywordOnSameLine() { |
|
nextToken(); |
|
return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); |
|
} |
|
function nextTokenIsFunctionKeywordOnSameLine() { |
|
nextToken(); |
|
return token === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); |
|
} |
|
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { |
|
nextToken(); |
|
return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); |
|
} |
|
function isDeclaration() { |
|
while (true) { |
|
switch (token) { |
|
case 102 /* VarKeyword */: |
|
case 108 /* LetKeyword */: |
|
case 74 /* ConstKeyword */: |
|
case 87 /* FunctionKeyword */: |
|
case 73 /* ClassKeyword */: |
|
case 81 /* EnumKeyword */: |
|
return true; |
|
// 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; |
|
// however, an identifier cannot be followed by another identifier on the same line. This is what we |
|
// count on to parse out the respective declarations. For instance, we exploit this to say that |
|
// |
|
// namespace n |
|
// |
|
// can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees |
|
// |
|
// namespace |
|
// n |
|
// |
|
// as the identifier 'namespace' on one line followed by the identifier 'n' on another. |
|
// We need to look one token ahead to see if it permissible to try parsing a declaration. |
|
// |
|
// *Note*: 'interface' is actually a strict mode reserved word. So while |
|
// |
|
// "use strict" |
|
// interface |
|
// I {} |
|
// |
|
// could be legal, it would add complexity for very little gain. |
|
case 107 /* InterfaceKeyword */: |
|
case 132 /* TypeKeyword */: |
|
return nextTokenIsIdentifierOnSameLine(); |
|
case 125 /* ModuleKeyword */: |
|
case 126 /* NamespaceKeyword */: |
|
return nextTokenIsIdentifierOrStringLiteralOnSameLine(); |
|
case 115 /* AbstractKeyword */: |
|
case 118 /* AsyncKeyword */: |
|
case 122 /* DeclareKeyword */: |
|
case 110 /* PrivateKeyword */: |
|
case 111 /* ProtectedKeyword */: |
|
case 112 /* PublicKeyword */: |
|
nextToken(); |
|
// ASI takes effect for this modifier. |
|
if (scanner.hasPrecedingLineBreak()) { |
|
return false; |
|
} |
|
continue; |
|
case 134 /* GlobalKeyword */: |
|
return nextToken() === 15 /* OpenBraceToken */; |
|
case 89 /* ImportKeyword */: |
|
nextToken(); |
|
return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || |
|
token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token); |
|
case 82 /* ExportKeyword */: |
|
nextToken(); |
|
if (token === 56 /* EqualsToken */ || token === 37 /* AsteriskToken */ || |
|
token === 15 /* OpenBraceToken */ || token === 77 /* DefaultKeyword */) { |
|
return true; |
|
} |
|
continue; |
|
case 113 /* StaticKeyword */: |
|
nextToken(); |
|
continue; |
|
default: |
|
return false; |
|
} |
|
} |
|
} |
|
function isStartOfDeclaration() { |
|
return lookAhead(isDeclaration); |
|
} |
|
function isStartOfStatement() { |
|
switch (token) { |
|
case 55 /* AtToken */: |
|
case 23 /* SemicolonToken */: |
|
case 15 /* OpenBraceToken */: |
|
case 102 /* VarKeyword */: |
|
case 108 /* LetKeyword */: |
|
case 87 /* FunctionKeyword */: |
|
case 73 /* ClassKeyword */: |
|
case 81 /* EnumKeyword */: |
|
case 88 /* IfKeyword */: |
|
case 79 /* DoKeyword */: |
|
case 104 /* WhileKeyword */: |
|
case 86 /* ForKeyword */: |
|
case 75 /* ContinueKeyword */: |
|
case 70 /* BreakKeyword */: |
|
case 94 /* ReturnKeyword */: |
|
case 105 /* WithKeyword */: |
|
case 96 /* SwitchKeyword */: |
|
case 98 /* ThrowKeyword */: |
|
case 100 /* TryKeyword */: |
|
case 76 /* DebuggerKeyword */: |
|
// 'catch' and 'finally' do not actually indicate that the code is part of a statement, |
|
// however, we say they are here so that we may gracefully parse them and error later. |
|
case 72 /* CatchKeyword */: |
|
case 85 /* FinallyKeyword */: |
|
return true; |
|
case 74 /* ConstKeyword */: |
|
case 82 /* ExportKeyword */: |
|
case 89 /* ImportKeyword */: |
|
return isStartOfDeclaration(); |
|
case 118 /* AsyncKeyword */: |
|
case 122 /* DeclareKeyword */: |
|
case 107 /* InterfaceKeyword */: |
|
case 125 /* ModuleKeyword */: |
|
case 126 /* NamespaceKeyword */: |
|
case 132 /* TypeKeyword */: |
|
case 134 /* GlobalKeyword */: |
|
// When these don't start a declaration, they're an identifier in an expression statement |
|
return true; |
|
case 112 /* PublicKeyword */: |
|
case 110 /* PrivateKeyword */: |
|
case 111 /* ProtectedKeyword */: |
|
case 113 /* StaticKeyword */: |
|
// When these don't start a declaration, they may be the start of a class member if an identifier |
|
// immediately follows. Otherwise they're an identifier in an expression statement. |
|
return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); |
|
default: |
|
return isStartOfExpression(); |
|
} |
|
} |
|
function nextTokenIsIdentifierOrStartOfDestructuring() { |
|
nextToken(); |
|
return isIdentifier() || token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */; |
|
} |
|
function isLetDeclaration() { |
|
// In ES6 'let' always starts a lexical declaration if followed by an identifier or { |
|
// or [. |
|
return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); |
|
} |
|
function parseStatement() { |
|
switch (token) { |
|
case 23 /* SemicolonToken */: |
|
return parseEmptyStatement(); |
|
case 15 /* OpenBraceToken */: |
|
return parseBlock(/*ignoreMissingOpenBrace*/ false); |
|
case 102 /* VarKeyword */: |
|
return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); |
|
case 108 /* LetKeyword */: |
|
if (isLetDeclaration()) { |
|
return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); |
|
} |
|
break; |
|
case 87 /* FunctionKeyword */: |
|
return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); |
|
case 73 /* ClassKeyword */: |
|
return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); |
|
case 88 /* IfKeyword */: |
|
return parseIfStatement(); |
|
case 79 /* DoKeyword */: |
|
return parseDoStatement(); |
|
case 104 /* WhileKeyword */: |
|
return parseWhileStatement(); |
|
case 86 /* ForKeyword */: |
|
return parseForOrForInOrForOfStatement(); |
|
case 75 /* ContinueKeyword */: |
|
return parseBreakOrContinueStatement(205 /* ContinueStatement */); |
|
case 70 /* BreakKeyword */: |
|
return parseBreakOrContinueStatement(206 /* BreakStatement */); |
|
case 94 /* ReturnKeyword */: |
|
return parseReturnStatement(); |
|
case 105 /* WithKeyword */: |
|
return parseWithStatement(); |
|
case 96 /* SwitchKeyword */: |
|
return parseSwitchStatement(); |
|
case 98 /* ThrowKeyword */: |
|
return parseThrowStatement(); |
|
case 100 /* TryKeyword */: |
|
// Include 'catch' and 'finally' for error recovery. |
|
case 72 /* CatchKeyword */: |
|
case 85 /* FinallyKeyword */: |
|
return parseTryStatement(); |
|
case 76 /* DebuggerKeyword */: |
|
return parseDebuggerStatement(); |
|
case 55 /* AtToken */: |
|
return parseDeclaration(); |
|
case 118 /* AsyncKeyword */: |
|
case 107 /* InterfaceKeyword */: |
|
case 132 /* TypeKeyword */: |
|
case 125 /* ModuleKeyword */: |
|
case 126 /* NamespaceKeyword */: |
|
case 122 /* DeclareKeyword */: |
|
case 74 /* ConstKeyword */: |
|
case 81 /* EnumKeyword */: |
|
case 82 /* ExportKeyword */: |
|
case 89 /* ImportKeyword */: |
|
case 110 /* PrivateKeyword */: |
|
case 111 /* ProtectedKeyword */: |
|
case 112 /* PublicKeyword */: |
|
case 115 /* AbstractKeyword */: |
|
case 113 /* StaticKeyword */: |
|
case 134 /* GlobalKeyword */: |
|
if (isStartOfDeclaration()) { |
|
return parseDeclaration(); |
|
} |
|
break; |
|
} |
|
return parseExpressionOrLabeledStatement(); |
|
} |
|
function parseDeclaration() { |
|
var fullStart = getNodePos(); |
|
var decorators = parseDecorators(); |
|
var modifiers = parseModifiers(); |
|
switch (token) { |
|
case 102 /* VarKeyword */: |
|
case 108 /* LetKeyword */: |
|
case 74 /* ConstKeyword */: |
|
return parseVariableStatement(fullStart, decorators, modifiers); |
|
case 87 /* FunctionKeyword */: |
|
return parseFunctionDeclaration(fullStart, decorators, modifiers); |
|
case 73 /* ClassKeyword */: |
|
return parseClassDeclaration(fullStart, decorators, modifiers); |
|
case 107 /* InterfaceKeyword */: |
|
return parseInterfaceDeclaration(fullStart, decorators, modifiers); |
|
case 132 /* TypeKeyword */: |
|
return parseTypeAliasDeclaration(fullStart, decorators, modifiers); |
|
case 81 /* EnumKeyword */: |
|
return parseEnumDeclaration(fullStart, decorators, modifiers); |
|
case 134 /* GlobalKeyword */: |
|
case 125 /* ModuleKeyword */: |
|
case 126 /* NamespaceKeyword */: |
|
return parseModuleDeclaration(fullStart, decorators, modifiers); |
|
case 89 /* ImportKeyword */: |
|
return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); |
|
case 82 /* ExportKeyword */: |
|
nextToken(); |
|
return token === 77 /* DefaultKeyword */ || token === 56 /* EqualsToken */ ? |
|
parseExportAssignment(fullStart, decorators, modifiers) : |
|
parseExportDeclaration(fullStart, decorators, modifiers); |
|
default: |
|
if (decorators || modifiers) { |
|
// We reached this point because we encountered decorators and/or modifiers and assumed a declaration |
|
// would follow. For recovery and error reporting purposes, return an incomplete declaration. |
|
var node = createMissingNode(234 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); |
|
node.pos = fullStart; |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
return finishNode(node); |
|
} |
|
} |
|
} |
|
function nextTokenIsIdentifierOrStringLiteralOnSameLine() { |
|
nextToken(); |
|
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9 /* StringLiteral */); |
|
} |
|
function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { |
|
if (token !== 15 /* OpenBraceToken */ && canParseSemicolon()) { |
|
parseSemicolon(); |
|
return; |
|
} |
|
return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); |
|
} |
|
// DECLARATIONS |
|
function parseArrayBindingElement() { |
|
if (token === 24 /* CommaToken */) { |
|
return createNode(190 /* OmittedExpression */); |
|
} |
|
var node = createNode(166 /* BindingElement */); |
|
node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); |
|
node.name = parseIdentifierOrPattern(); |
|
node.initializer = parseBindingElementInitializer(/*inParameter*/ false); |
|
return finishNode(node); |
|
} |
|
function parseObjectBindingElement() { |
|
var node = createNode(166 /* BindingElement */); |
|
var tokenIsIdentifier = isIdentifier(); |
|
var propertyName = parsePropertyName(); |
|
if (tokenIsIdentifier && token !== 54 /* ColonToken */) { |
|
node.name = propertyName; |
|
} |
|
else { |
|
parseExpected(54 /* ColonToken */); |
|
node.propertyName = propertyName; |
|
node.name = parseIdentifierOrPattern(); |
|
} |
|
node.initializer = parseBindingElementInitializer(/*inParameter*/ false); |
|
return finishNode(node); |
|
} |
|
function parseObjectBindingPattern() { |
|
var node = createNode(164 /* ObjectBindingPattern */); |
|
parseExpected(15 /* OpenBraceToken */); |
|
node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); |
|
parseExpected(16 /* CloseBraceToken */); |
|
return finishNode(node); |
|
} |
|
function parseArrayBindingPattern() { |
|
var node = createNode(165 /* ArrayBindingPattern */); |
|
parseExpected(19 /* OpenBracketToken */); |
|
node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); |
|
parseExpected(20 /* CloseBracketToken */); |
|
return finishNode(node); |
|
} |
|
function isIdentifierOrPattern() { |
|
return token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */ || isIdentifier(); |
|
} |
|
function parseIdentifierOrPattern() { |
|
if (token === 19 /* OpenBracketToken */) { |
|
return parseArrayBindingPattern(); |
|
} |
|
if (token === 15 /* OpenBraceToken */) { |
|
return parseObjectBindingPattern(); |
|
} |
|
return parseIdentifier(); |
|
} |
|
function parseVariableDeclaration() { |
|
var node = createNode(214 /* VariableDeclaration */); |
|
node.name = parseIdentifierOrPattern(); |
|
node.type = parseTypeAnnotation(); |
|
if (!isInOrOfKeyword(token)) { |
|
node.initializer = parseInitializer(/*inParameter*/ false); |
|
} |
|
return finishNode(node); |
|
} |
|
function parseVariableDeclarationList(inForStatementInitializer) { |
|
var node = createNode(215 /* VariableDeclarationList */); |
|
switch (token) { |
|
case 102 /* VarKeyword */: |
|
break; |
|
case 108 /* LetKeyword */: |
|
node.flags |= 8192 /* Let */; |
|
break; |
|
case 74 /* ConstKeyword */: |
|
node.flags |= 16384 /* Const */; |
|
break; |
|
default: |
|
ts.Debug.fail(); |
|
} |
|
nextToken(); |
|
// The user may have written the following: |
|
// |
|
// for (let of X) { } |
|
// |
|
// In this case, we want to parse an empty declaration list, and then parse 'of' |
|
// as a keyword. The reason this is not automatic is that 'of' is a valid identifier. |
|
// So we need to look ahead to determine if 'of' should be treated as a keyword in |
|
// this context. |
|
// The checker will then give an error that there is an empty declaration list. |
|
if (token === 135 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { |
|
node.declarations = createMissingList(); |
|
} |
|
else { |
|
var savedDisallowIn = inDisallowInContext(); |
|
setDisallowInContext(inForStatementInitializer); |
|
node.declarations = parseDelimitedList(8 /* VariableDeclarations */, parseVariableDeclaration); |
|
setDisallowInContext(savedDisallowIn); |
|
} |
|
return finishNode(node); |
|
} |
|
function canFollowContextualOfKeyword() { |
|
return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; |
|
} |
|
function parseVariableStatement(fullStart, decorators, modifiers) { |
|
var node = createNode(196 /* VariableStatement */, fullStart); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); |
|
parseSemicolon(); |
|
return addJSDocComment(finishNode(node)); |
|
} |
|
function parseFunctionDeclaration(fullStart, decorators, modifiers) { |
|
var node = createNode(216 /* FunctionDeclaration */, fullStart); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
parseExpected(87 /* FunctionKeyword */); |
|
node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); |
|
node.name = node.flags & 512 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); |
|
var isGenerator = !!node.asteriskToken; |
|
var isAsync = !!(node.flags & 256 /* Async */); |
|
fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); |
|
node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); |
|
return addJSDocComment(finishNode(node)); |
|
} |
|
function parseConstructorDeclaration(pos, decorators, modifiers) { |
|
var node = createNode(145 /* Constructor */, pos); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
parseExpected(121 /* ConstructorKeyword */); |
|
fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); |
|
node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); |
|
return addJSDocComment(finishNode(node)); |
|
} |
|
function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { |
|
var method = createNode(144 /* MethodDeclaration */, fullStart); |
|
method.decorators = decorators; |
|
setModifiers(method, modifiers); |
|
method.asteriskToken = asteriskToken; |
|
method.name = name; |
|
method.questionToken = questionToken; |
|
var isGenerator = !!asteriskToken; |
|
var isAsync = !!(method.flags & 256 /* Async */); |
|
fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); |
|
method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); |
|
return addJSDocComment(finishNode(method)); |
|
} |
|
function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { |
|
var property = createNode(142 /* PropertyDeclaration */, fullStart); |
|
property.decorators = decorators; |
|
setModifiers(property, modifiers); |
|
property.name = name; |
|
property.questionToken = questionToken; |
|
property.type = parseTypeAnnotation(); |
|
// For instance properties specifically, since they are evaluated inside the constructor, |
|
// we do *not * want to parse yield expressions, so we specifically turn the yield context |
|
// off. The grammar would look something like this: |
|
// |
|
// MemberVariableDeclaration[Yield]: |
|
// AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initialiser_opt[In]; |
|
// AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; |
|
// |
|
// The checker may still error in the static case to explicitly disallow the yield expression. |
|
property.initializer = modifiers && modifiers.flags & 64 /* Static */ |
|
? allowInAnd(parseNonParameterInitializer) |
|
: doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); |
|
parseSemicolon(); |
|
return finishNode(property); |
|
} |
|
function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { |
|
var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); |
|
var name = parsePropertyName(); |
|
// Note: this is not legal as per the grammar. But we allow it in the parser and |
|
// report an error in the grammar checker. |
|
var questionToken = parseOptionalToken(53 /* QuestionToken */); |
|
if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { |
|
return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); |
|
} |
|
else { |
|
return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); |
|
} |
|
} |
|
function parseNonParameterInitializer() { |
|
return parseInitializer(/*inParameter*/ false); |
|
} |
|
function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { |
|
var node = createNode(kind, fullStart); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
node.name = parsePropertyName(); |
|
fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); |
|
node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); |
|
return finishNode(node); |
|
} |
|
function isClassMemberModifier(idToken) { |
|
switch (idToken) { |
|
case 112 /* PublicKeyword */: |
|
case 110 /* PrivateKeyword */: |
|
case 111 /* ProtectedKeyword */: |
|
case 113 /* StaticKeyword */: |
|
return true; |
|
default: |
|
return false; |
|
} |
|
} |
|
function isClassMemberStart() { |
|
var idToken; |
|
if (token === 55 /* AtToken */) { |
|
return true; |
|
} |
|
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier. |
|
while (ts.isModifierKind(token)) { |
|
idToken = token; |
|
// If the idToken is a class modifier (protected, private, public, and static), it is |
|
// certain that we are starting to parse class member. This allows better error recovery |
|
// Example: |
|
// public foo() ... // true |
|
// public @dec blah ... // true; we will then report an error later |
|
// export public ... // true; we will then report an error later |
|
if (isClassMemberModifier(idToken)) { |
|
return true; |
|
} |
|
nextToken(); |
|
} |
|
if (token === 37 /* AsteriskToken */) { |
|
return true; |
|
} |
|
// Try to get the first property-like token following all modifiers. |
|
// This can either be an identifier or the 'get' or 'set' keywords. |
|
if (isLiteralPropertyName()) { |
|
idToken = token; |
|
nextToken(); |
|
} |
|
// Index signatures and computed properties are class members; we can parse. |
|
if (token === 19 /* OpenBracketToken */) { |
|
return true; |
|
} |
|
// If we were able to get any potential identifier... |
|
if (idToken !== undefined) { |
|
// If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. |
|
if (!ts.isKeyword(idToken) || idToken === 129 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { |
|
return true; |
|
} |
|
// If it *is* a keyword, but not an accessor, check a little farther along |
|
// to see if it should actually be parsed as a class member. |
|
switch (token) { |
|
case 17 /* OpenParenToken */: // Method declaration |
|
case 25 /* LessThanToken */: // Generic Method declaration |
|
case 54 /* ColonToken */: // Type Annotation for declaration |
|
case 56 /* EqualsToken */: // Initializer for declaration |
|
case 53 /* QuestionToken */: |
|
return true; |
|
default: |
|
// Covers |
|
// - Semicolons (declaration termination) |
|
// - Closing braces (end-of-class, must be declaration) |
|
// - End-of-files (not valid, but permitted so that it gets caught later on) |
|
// - Line-breaks (enabling *automatic semicolon insertion*) |
|
return canParseSemicolon(); |
|
} |
|
} |
|
return false; |
|
} |
|
function parseDecorators() { |
|
var decorators; |
|
while (true) { |
|
var decoratorStart = getNodePos(); |
|
if (!parseOptional(55 /* AtToken */)) { |
|
break; |
|
} |
|
if (!decorators) { |
|
decorators = []; |
|
decorators.pos = decoratorStart; |
|
} |
|
var decorator = createNode(140 /* Decorator */, decoratorStart); |
|
decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); |
|
decorators.push(finishNode(decorator)); |
|
} |
|
if (decorators) { |
|
decorators.end = getNodeEnd(); |
|
} |
|
return decorators; |
|
} |
|
/* |
|
* There are situations in which a modifier like 'const' will appear unexpectedly, such as on a class member. |
|
* In those situations, if we are entirely sure that 'const' is not valid on its own (such as when ASI takes effect |
|
* and turns it into a standalone declaration), then it is better to parse it and report an error later. |
|
* |
|
* In such situations, 'permitInvalidConstAsModifier' should be set to true. |
|
*/ |
|
function parseModifiers(permitInvalidConstAsModifier) { |
|
var flags = 0; |
|
var modifiers; |
|
while (true) { |
|
var modifierStart = scanner.getStartPos(); |
|
var modifierKind = token; |
|
if (token === 74 /* ConstKeyword */ && permitInvalidConstAsModifier) { |
|
// We need to ensure that any subsequent modifiers appear on the same line |
|
// so that when 'const' is a standalone declaration, we don't issue an error. |
|
if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { |
|
break; |
|
} |
|
} |
|
else { |
|
if (!parseAnyContextualModifier()) { |
|
break; |
|
} |
|
} |
|
if (!modifiers) { |
|
modifiers = []; |
|
modifiers.pos = modifierStart; |
|
} |
|
flags |= ts.modifierToFlag(modifierKind); |
|
modifiers.push(finishNode(createNode(modifierKind, modifierStart))); |
|
} |
|
if (modifiers) { |
|
modifiers.flags = flags; |
|
modifiers.end = scanner.getStartPos(); |
|
} |
|
return modifiers; |
|
} |
|
function parseModifiersForArrowFunction() { |
|
var flags = 0; |
|
var modifiers; |
|
if (token === 118 /* AsyncKeyword */) { |
|
var modifierStart = scanner.getStartPos(); |
|
var modifierKind = token; |
|
nextToken(); |
|
modifiers = []; |
|
modifiers.pos = modifierStart; |
|
flags |= ts.modifierToFlag(modifierKind); |
|
modifiers.push(finishNode(createNode(modifierKind, modifierStart))); |
|
modifiers.flags = flags; |
|
modifiers.end = scanner.getStartPos(); |
|
} |
|
return modifiers; |
|
} |
|
function parseClassElement() { |
|
if (token === 23 /* SemicolonToken */) { |
|
var result = createNode(194 /* SemicolonClassElement */); |
|
nextToken(); |
|
return finishNode(result); |
|
} |
|
var fullStart = getNodePos(); |
|
var decorators = parseDecorators(); |
|
var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); |
|
var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); |
|
if (accessor) { |
|
return accessor; |
|
} |
|
if (token === 121 /* ConstructorKeyword */) { |
|
return parseConstructorDeclaration(fullStart, decorators, modifiers); |
|
} |
|
if (isIndexSignature()) { |
|
return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); |
|
} |
|
// It is very important that we check this *after* checking indexers because |
|
// the [ token can start an index signature or a computed property name |
|
if (ts.tokenIsIdentifierOrKeyword(token) || |
|
token === 9 /* StringLiteral */ || |
|
token === 8 /* NumericLiteral */ || |
|
token === 37 /* AsteriskToken */ || |
|
token === 19 /* OpenBracketToken */) { |
|
return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); |
|
} |
|
if (decorators || modifiers) { |
|
// treat this as a property declaration with a missing name. |
|
var name_7 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); |
|
return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); |
|
} |
|
// 'isClassMemberStart' should have hinted not to attempt parsing. |
|
ts.Debug.fail("Should not have attempted to parse class member declaration."); |
|
} |
|
function parseClassExpression() { |
|
return parseClassDeclarationOrExpression( |
|
/*fullStart*/ scanner.getStartPos(), |
|
/*decorators*/ undefined, |
|
/*modifiers*/ undefined, 189 /* ClassExpression */); |
|
} |
|
function parseClassDeclaration(fullStart, decorators, modifiers) { |
|
return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 217 /* ClassDeclaration */); |
|
} |
|
function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { |
|
var node = createNode(kind, fullStart); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
parseExpected(73 /* ClassKeyword */); |
|
node.name = parseNameOfClassDeclarationOrExpression(); |
|
node.typeParameters = parseTypeParameters(); |
|
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); |
|
if (parseExpected(15 /* OpenBraceToken */)) { |
|
// ClassTail[Yield,Await] : (Modified) See 14.5 |
|
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } |
|
node.members = parseClassMembers(); |
|
parseExpected(16 /* CloseBraceToken */); |
|
} |
|
else { |
|
node.members = createMissingList(); |
|
} |
|
return finishNode(node); |
|
} |
|
function parseNameOfClassDeclarationOrExpression() { |
|
// implements is a future reserved word so |
|
// 'class implements' might mean either |
|
// - class expression with omitted name, 'implements' starts heritage clause |
|
// - class with name 'implements' |
|
// 'isImplementsClause' helps to disambiguate between these two cases |
|
return isIdentifier() && !isImplementsClause() |
|
? parseIdentifier() |
|
: undefined; |
|
} |
|
function isImplementsClause() { |
|
return token === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); |
|
} |
|
function parseHeritageClauses(isClassHeritageClause) { |
|
// ClassTail[Yield,Await] : (Modified) See 14.5 |
|
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } |
|
if (isHeritageClause()) { |
|
return parseList(20 /* HeritageClauses */, parseHeritageClause); |
|
} |
|
return undefined; |
|
} |
|
function parseHeritageClause() { |
|
if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { |
|
var node = createNode(246 /* HeritageClause */); |
|
node.token = token; |
|
nextToken(); |
|
node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); |
|
return finishNode(node); |
|
} |
|
return undefined; |
|
} |
|
function parseExpressionWithTypeArguments() { |
|
var node = createNode(191 /* ExpressionWithTypeArguments */); |
|
node.expression = parseLeftHandSideExpressionOrHigher(); |
|
if (token === 25 /* LessThanToken */) { |
|
node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); |
|
} |
|
return finishNode(node); |
|
} |
|
function isHeritageClause() { |
|
return token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */; |
|
} |
|
function parseClassMembers() { |
|
return parseList(5 /* ClassMembers */, parseClassElement); |
|
} |
|
function parseInterfaceDeclaration(fullStart, decorators, modifiers) { |
|
var node = createNode(218 /* InterfaceDeclaration */, fullStart); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
parseExpected(107 /* InterfaceKeyword */); |
|
node.name = parseIdentifier(); |
|
node.typeParameters = parseTypeParameters(); |
|
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); |
|
node.members = parseObjectTypeMembers(); |
|
return finishNode(node); |
|
} |
|
function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { |
|
var node = createNode(219 /* TypeAliasDeclaration */, fullStart); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
parseExpected(132 /* TypeKeyword */); |
|
node.name = parseIdentifier(); |
|
node.typeParameters = parseTypeParameters(); |
|
parseExpected(56 /* EqualsToken */); |
|
node.type = parseType(); |
|
parseSemicolon(); |
|
return finishNode(node); |
|
} |
|
// In an ambient declaration, the grammar only allows integer literals as initializers. |
|
// In a non-ambient declaration, the grammar allows uninitialized members only in a |
|
// ConstantEnumMemberSection, which starts at the beginning of an enum declaration |
|
// or any time an integer literal initializer is encountered. |
|
function parseEnumMember() { |
|
var node = createNode(250 /* EnumMember */, scanner.getStartPos()); |
|
node.name = parsePropertyName(); |
|
node.initializer = allowInAnd(parseNonParameterInitializer); |
|
return finishNode(node); |
|
} |
|
function parseEnumDeclaration(fullStart, decorators, modifiers) { |
|
var node = createNode(220 /* EnumDeclaration */, fullStart); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
parseExpected(81 /* EnumKeyword */); |
|
node.name = parseIdentifier(); |
|
if (parseExpected(15 /* OpenBraceToken */)) { |
|
node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); |
|
parseExpected(16 /* CloseBraceToken */); |
|
} |
|
else { |
|
node.members = createMissingList(); |
|
} |
|
return finishNode(node); |
|
} |
|
function parseModuleBlock() { |
|
var node = createNode(222 /* ModuleBlock */, scanner.getStartPos()); |
|
if (parseExpected(15 /* OpenBraceToken */)) { |
|
node.statements = parseList(1 /* BlockStatements */, parseStatement); |
|
parseExpected(16 /* CloseBraceToken */); |
|
} |
|
else { |
|
node.statements = createMissingList(); |
|
} |
|
return finishNode(node); |
|
} |
|
function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { |
|
var node = createNode(221 /* ModuleDeclaration */, fullStart); |
|
// If we are parsing a dotted namespace name, we want to |
|
// propagate the 'Namespace' flag across the names if set. |
|
var namespaceFlag = flags & 65536 /* Namespace */; |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
node.flags |= flags; |
|
node.name = parseIdentifier(); |
|
node.body = parseOptional(21 /* DotToken */) |
|
? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 2 /* Export */ | namespaceFlag) |
|
: parseModuleBlock(); |
|
return finishNode(node); |
|
} |
|
function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { |
|
var node = createNode(221 /* ModuleDeclaration */, fullStart); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
if (token === 134 /* GlobalKeyword */) { |
|
// parse 'global' as name of global scope augmentation |
|
node.name = parseIdentifier(); |
|
node.flags |= 2097152 /* GlobalAugmentation */; |
|
} |
|
else { |
|
node.name = parseLiteralNode(/*internName*/ true); |
|
} |
|
node.body = parseModuleBlock(); |
|
return finishNode(node); |
|
} |
|
function parseModuleDeclaration(fullStart, decorators, modifiers) { |
|
var flags = modifiers ? modifiers.flags : 0; |
|
if (token === 134 /* GlobalKeyword */) { |
|
// global augmentation |
|
return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); |
|
} |
|
else if (parseOptional(126 /* NamespaceKeyword */)) { |
|
flags |= 65536 /* Namespace */; |
|
} |
|
else { |
|
parseExpected(125 /* ModuleKeyword */); |
|
if (token === 9 /* StringLiteral */) { |
|
return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); |
|
} |
|
} |
|
return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); |
|
} |
|
function isExternalModuleReference() { |
|
return token === 127 /* RequireKeyword */ && |
|
lookAhead(nextTokenIsOpenParen); |
|
} |
|
function nextTokenIsOpenParen() { |
|
return nextToken() === 17 /* OpenParenToken */; |
|
} |
|
function nextTokenIsSlash() { |
|
return nextToken() === 39 /* SlashToken */; |
|
} |
|
function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { |
|
parseExpected(89 /* ImportKeyword */); |
|
var afterImportPos = scanner.getStartPos(); |
|
var identifier; |
|
if (isIdentifier()) { |
|
identifier = parseIdentifier(); |
|
if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) { |
|
// ImportEquals declaration of type: |
|
// import x = require("mod"); or |
|
// import x = M.x; |
|
var importEqualsDeclaration = createNode(224 /* ImportEqualsDeclaration */, fullStart); |
|
importEqualsDeclaration.decorators = decorators; |
|
setModifiers(importEqualsDeclaration, modifiers); |
|
importEqualsDeclaration.name = identifier; |
|
parseExpected(56 /* EqualsToken */); |
|
importEqualsDeclaration.moduleReference = parseModuleReference(); |
|
parseSemicolon(); |
|
return finishNode(importEqualsDeclaration); |
|
} |
|
} |
|
// Import statement |
|
var importDeclaration = createNode(225 /* ImportDeclaration */, fullStart); |
|
importDeclaration.decorators = decorators; |
|
setModifiers(importDeclaration, modifiers); |
|
// ImportDeclaration: |
|
// import ImportClause from ModuleSpecifier ; |
|
// import ModuleSpecifier; |
|
if (identifier || |
|
token === 37 /* AsteriskToken */ || |
|
token === 15 /* OpenBraceToken */) { |
|
importDeclaration.importClause = parseImportClause(identifier, afterImportPos); |
|
parseExpected(133 /* FromKeyword */); |
|
} |
|
importDeclaration.moduleSpecifier = parseModuleSpecifier(); |
|
parseSemicolon(); |
|
return finishNode(importDeclaration); |
|
} |
|
function parseImportClause(identifier, fullStart) { |
|
// ImportClause: |
|
// ImportedDefaultBinding |
|
// NameSpaceImport |
|
// NamedImports |
|
// ImportedDefaultBinding, NameSpaceImport |
|
// ImportedDefaultBinding, NamedImports |
|
var importClause = createNode(226 /* ImportClause */, fullStart); |
|
if (identifier) { |
|
// ImportedDefaultBinding: |
|
// ImportedBinding |
|
importClause.name = identifier; |
|
} |
|
// If there was no default import or if there is comma token after default import |
|
// parse namespace or named imports |
|
if (!importClause.name || |
|
parseOptional(24 /* CommaToken */)) { |
|
importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(228 /* NamedImports */); |
|
} |
|
return finishNode(importClause); |
|
} |
|
function parseModuleReference() { |
|
return isExternalModuleReference() |
|
? parseExternalModuleReference() |
|
: parseEntityName(/*allowReservedWords*/ false); |
|
} |
|
function parseExternalModuleReference() { |
|
var node = createNode(235 /* ExternalModuleReference */); |
|
parseExpected(127 /* RequireKeyword */); |
|
parseExpected(17 /* OpenParenToken */); |
|
node.expression = parseModuleSpecifier(); |
|
parseExpected(18 /* CloseParenToken */); |
|
return finishNode(node); |
|
} |
|
function parseModuleSpecifier() { |
|
if (token === 9 /* StringLiteral */) { |
|
var result = parseLiteralNode(); |
|
internIdentifier(result.text); |
|
return result; |
|
} |
|
else { |
|
// We allow arbitrary expressions here, even though the grammar only allows string |
|
// literals. We check to ensure that it is only a string literal later in the grammar |
|
// check pass. |
|
return parseExpression(); |
|
} |
|
} |
|
function parseNamespaceImport() { |
|
// NameSpaceImport: |
|
// * as ImportedBinding |
|
var namespaceImport = createNode(227 /* NamespaceImport */); |
|
parseExpected(37 /* AsteriskToken */); |
|
parseExpected(116 /* AsKeyword */); |
|
namespaceImport.name = parseIdentifier(); |
|
return finishNode(namespaceImport); |
|
} |
|
function parseNamedImportsOrExports(kind) { |
|
var node = createNode(kind); |
|
// NamedImports: |
|
// { } |
|
// { ImportsList } |
|
// { ImportsList, } |
|
// ImportsList: |
|
// ImportSpecifier |
|
// ImportsList, ImportSpecifier |
|
node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 228 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); |
|
return finishNode(node); |
|
} |
|
function parseExportSpecifier() { |
|
return parseImportOrExportSpecifier(233 /* ExportSpecifier */); |
|
} |
|
function parseImportSpecifier() { |
|
return parseImportOrExportSpecifier(229 /* ImportSpecifier */); |
|
} |
|
function parseImportOrExportSpecifier(kind) { |
|
var node = createNode(kind); |
|
// ImportSpecifier: |
|
// BindingIdentifier |
|
// IdentifierName as BindingIdentifier |
|
// ExportSpecififer: |
|
// IdentifierName |
|
// IdentifierName as IdentifierName |
|
var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); |
|
var checkIdentifierStart = scanner.getTokenPos(); |
|
var checkIdentifierEnd = scanner.getTextPos(); |
|
var identifierName = parseIdentifierName(); |
|
if (token === 116 /* AsKeyword */) { |
|
node.propertyName = identifierName; |
|
parseExpected(116 /* AsKeyword */); |
|
checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); |
|
checkIdentifierStart = scanner.getTokenPos(); |
|
checkIdentifierEnd = scanner.getTextPos(); |
|
node.name = parseIdentifierName(); |
|
} |
|
else { |
|
node.name = identifierName; |
|
} |
|
if (kind === 229 /* ImportSpecifier */ && checkIdentifierIsKeyword) { |
|
// Report error identifier expected |
|
parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); |
|
} |
|
return finishNode(node); |
|
} |
|
function parseExportDeclaration(fullStart, decorators, modifiers) { |
|
var node = createNode(231 /* ExportDeclaration */, fullStart); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
if (parseOptional(37 /* AsteriskToken */)) { |
|
parseExpected(133 /* FromKeyword */); |
|
node.moduleSpecifier = parseModuleSpecifier(); |
|
} |
|
else { |
|
node.exportClause = parseNamedImportsOrExports(232 /* NamedExports */); |
|
// It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, |
|
// the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) |
|
// If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. |
|
if (token === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { |
|
parseExpected(133 /* FromKeyword */); |
|
node.moduleSpecifier = parseModuleSpecifier(); |
|
} |
|
} |
|
parseSemicolon(); |
|
return finishNode(node); |
|
} |
|
function parseExportAssignment(fullStart, decorators, modifiers) { |
|
var node = createNode(230 /* ExportAssignment */, fullStart); |
|
node.decorators = decorators; |
|
setModifiers(node, modifiers); |
|
if (parseOptional(56 /* EqualsToken */)) { |
|
node.isExportEquals = true; |
|
} |
|
else { |
|
parseExpected(77 /* DefaultKeyword */); |
|
} |
|
node.expression = parseAssignmentExpressionOrHigher(); |
|
parseSemicolon(); |
|
return finishNode(node); |
|
} |
|
function processReferenceComments(sourceFile) { |
|
var triviaScanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText); |
|
var referencedFiles = []; |
|
var amdDependencies = []; |
|
var amdModuleName; |
|
// Keep scanning all the leading trivia in the file until we get to something that |
|
// isn't trivia. Any single line comment will be analyzed to see if it is a |
|
// reference comment. |
|
while (true) { |
|
var kind = triviaScanner.scan(); |
|
if (kind !== 2 /* SingleLineCommentTrivia */) { |
|
if (ts.isTrivia(kind)) { |
|
continue; |
|
} |
|
else { |
|
break; |
|
} |
|
} |
|
var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; |
|
var comment = sourceText.substring(range.pos, range.end); |
|
var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); |
|
if (referencePathMatchResult) { |
|
var fileReference = referencePathMatchResult.fileReference; |
|
sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; |
|
var diagnosticMessage = referencePathMatchResult.diagnosticMessage; |
|
if (fileReference) { |
|
referencedFiles.push(fileReference); |
|
} |
|
if (diagnosticMessage) { |
|
parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); |
|
} |
|
} |
|
else { |
|
var amdModuleNameRegEx = /^\/\/\/\s*<amd-module\s+name\s*=\s*('|")(.+?)\1/gim; |
|
var amdModuleNameMatchResult = amdModuleNameRegEx.exec(comment); |
|
if (amdModuleNameMatchResult) { |
|
if (amdModuleName) { |
|
parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments)); |
|
} |
|
amdModuleName = amdModuleNameMatchResult[2]; |
|
} |
|
var amdDependencyRegEx = /^\/\/\/\s*<amd-dependency\s/gim; |
|
var pathRegex = /\spath\s*=\s*('|")(.+?)\1/gim; |
|
var nameRegex = /\sname\s*=\s*('|")(.+?)\1/gim; |
|
var amdDependencyMatchResult = amdDependencyRegEx.exec(comment); |
|
if (amdDependencyMatchResult) { |
|
var pathMatchResult = pathRegex.exec(comment); |
|
var nameMatchResult = nameRegex.exec(comment); |
|
if (pathMatchResult) { |
|
var amdDependency = { path: pathMatchResult[2], name: nameMatchResult ? nameMatchResult[2] : undefined }; |
|
amdDependencies.push(amdDependency); |
|
} |
|
} |
|
} |
|
} |
|
sourceFile.referencedFiles = referencedFiles; |
|
sourceFile.amdDependencies = amdDependencies; |
|
sourceFile.moduleName = amdModuleName; |
|
} |
|
function setExternalModuleIndicator(sourceFile) { |
|
sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { |
|
return node.flags & 2 /* Export */ |
|
|| node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 235 /* ExternalModuleReference */ |
|
|| node.kind === 225 /* ImportDeclaration */ |
|
|| node.kind === 230 /* ExportAssignment */ |
|
|| node.kind === 231 /* ExportDeclaration */ |
|
? node |
|
: undefined; |
|
}); |
|
} |
|
var ParsingContext; |
|
(function (ParsingContext) { |
|
ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; |
|
ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; |
|
ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; |
|
ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; |
|
ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; |
|
ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; |
|
ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; |
|
ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; |
|
ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; |
|
ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; |
|
ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; |
|
ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; |
|
ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; |
|
ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; |
|
ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; |
|
ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; |
|
ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; |
|
ParsingContext[ParsingContext["TypeParameters"] = 17] = "TypeParameters"; |
|
ParsingContext[ParsingContext["TypeArguments"] = 18] = "TypeArguments"; |
|
ParsingContext[ParsingContext["TupleElementTypes"] = 19] = "TupleElementTypes"; |
|
ParsingContext[ParsingContext["HeritageClauses"] = 20] = "HeritageClauses"; |
|
ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 21] = "ImportOrExportSpecifiers"; |
|
ParsingContext[ParsingContext["JSDocFunctionParameters"] = 22] = "JSDocFunctionParameters"; |
|
ParsingContext[ParsingContext["JSDocTypeArguments"] = 23] = "JSDocTypeArguments"; |
|
ParsingContext[ParsingContext["JSDocRecordMembers"] = 24] = "JSDocRecordMembers"; |
|
ParsingContext[ParsingContext["JSDocTupleTypes"] = 25] = "JSDocTupleTypes"; |
|
ParsingContext[ParsingContext["Count"] = 26] = "Count"; // Number of parsing contexts |
|
})(ParsingContext || (ParsingContext = {})); |
|
var Tristate; |
|
(function (Tristate) { |
|
Tristate[Tristate["False"] = 0] = "False"; |
|
Tristate[Tristate["True"] = 1] = "True"; |
|
Tristate[Tristate["Unknown"] = 2] = "Unknown"; |
|
})(Tristate || (Tristate = {})); |
|
var JSDocParser; |
|
(function (JSDocParser) { |
|
function isJSDocType() { |
|
switch (token) { |
|
case 37 /* AsteriskToken */: |
|
case 53 /* QuestionToken */: |
|
case 17 /* OpenParenToken */: |
|
case 19 /* OpenBracketToken */: |
|
case 49 /* ExclamationToken */: |
|
case 15 /* OpenBraceToken */: |
|
case 87 /* FunctionKeyword */: |
|
case 22 /* DotDotDotToken */: |
|
case 92 /* NewKeyword */: |
|
case 97 /* ThisKeyword */: |
|
return true; |
|
} |
|
return ts.tokenIsIdentifierOrKeyword(token); |
|
} |
|
JSDocParser.isJSDocType = isJSDocType; |
|
function parseJSDocTypeExpressionForTests(content, start, length) { |
|
initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); |
|
scanner.setText(content, start, length); |
|
token = scanner.scan(); |
|
var jsDocTypeExpression = parseJSDocTypeExpression(); |
|
var diagnostics = parseDiagnostics; |
|
clearState(); |
|
return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined; |
|
} |
|
JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; |
|
// Parses out a JSDoc type expression. |
|
/* @internal */ |
|
function parseJSDocTypeExpression() { |
|
var result = createNode(252 /* JSDocTypeExpression */, scanner.getTokenPos()); |
|
parseExpected(15 /* OpenBraceToken */); |
|
result.type = parseJSDocTopLevelType(); |
|
parseExpected(16 /* CloseBraceToken */); |
|
fixupParentReferences(result); |
|
return finishNode(result); |
|
} |
|
JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; |
|
function parseJSDocTopLevelType() { |
|
var type = parseJSDocType(); |
|
if (token === 47 /* BarToken */) { |
|
var unionType = createNode(256 /* JSDocUnionType */, type.pos); |
|
unionType.types = parseJSDocTypeList(type); |
|
type = finishNode(unionType); |
|
} |
|
if (token === 56 /* EqualsToken */) { |
|
var optionalType = createNode(263 /* JSDocOptionalType */, type.pos); |
|
nextToken(); |
|
optionalType.type = type; |
|
type = finishNode(optionalType); |
|
} |
|
return type; |
|
} |
|
function parseJSDocType() { |
|
var type = parseBasicTypeExpression(); |
|
while (true) { |
|
if (token === 19 /* OpenBracketToken */) { |
|
var arrayType = createNode(255 /* JSDocArrayType */, type.pos); |
|
arrayType.elementType = type; |
|
nextToken(); |
|
parseExpected(20 /* CloseBracketToken */); |
|
type = finishNode(arrayType); |
|
} |
|
else if (token === 53 /* QuestionToken */) { |
|
var nullableType = createNode(258 /* JSDocNullableType */, type.pos); |
|
nullableType.type = type; |
|
nextToken(); |
|
type = finishNode(nullableType); |
|
} |
|
else if (token === 49 /* ExclamationToken */) { |
|
var nonNullableType = createNode(259 /* JSDocNonNullableType */, type.pos); |
|
nonNullableType.type = type; |
|
nextToken(); |
|
type = finishNode(nonNullableType); |
|
} |
|
else { |
|
break; |
|
} |
|
} |
|
return type; |
|
} |
|
function parseBasicTypeExpression() { |
|
switch (token) { |
|
case 37 /* AsteriskToken */: |
|
return parseJSDocAllType(); |
|
case 53 /* QuestionToken */: |
|
return parseJSDocUnknownOrNullableType(); |
|
case 17 /* OpenParenToken */: |
|
return parseJSDocUnionType(); |
|
case 19 /* OpenBracketToken */: |
|
return parseJSDocTupleType(); |
|
case 49 /* ExclamationToken */: |
|
return parseJSDocNonNullableType(); |
|
case 15 /* OpenBraceToken */: |
|
return parseJSDocRecordType(); |
|
case 87 /* FunctionKeyword */: |
|
return parseJSDocFunctionType(); |
|
case 22 /* DotDotDotToken */: |
|
return parseJSDocVariadicType(); |
|
case 92 /* NewKeyword */: |
|
return parseJSDocConstructorType(); |
|
case 97 /* ThisKeyword */: |
|
return parseJSDocThisType(); |
|
case 117 /* AnyKeyword */: |
|
case 130 /* StringKeyword */: |
|
case 128 /* NumberKeyword */: |
|
case 120 /* BooleanKeyword */: |
|
case 131 /* SymbolKeyword */: |
|
case 103 /* VoidKeyword */: |
|
return parseTokenNode(); |
|
} |
|
// TODO (drosen): Parse string literal types in JSDoc as well. |
|
return parseJSDocTypeReference(); |
|
} |
|
function parseJSDocThisType() { |
|
var result = createNode(267 /* JSDocThisType */); |
|
nextToken(); |
|
parseExpected(54 /* ColonToken */); |
|
result.type = parseJSDocType(); |
|
return finishNode(result); |
|
} |
|
function parseJSDocConstructorType() { |
|
var result = createNode(266 /* JSDocConstructorType */); |
|
nextToken(); |
|
parseExpected(54 /* ColonToken */); |
|
result.type = parseJSDocType(); |
|
return finishNode(result); |
|
} |
|
function parseJSDocVariadicType() { |
|
var result = createNode(265 /* JSDocVariadicType */); |
|
nextToken(); |
|
result.type = parseJSDocType(); |
|
return finishNode(result); |
|
} |
|
function parseJSDocFunctionType() { |
|
var result = createNode(264 /* JSDocFunctionType */); |
|
nextToken(); |
|
parseExpected(17 /* OpenParenToken */); |
|
result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); |
|
checkForTrailingComma(result.parameters); |
|
parseExpected(18 /* CloseParenToken */); |
|
if (token === 54 /* ColonToken */) { |
|
nextToken(); |
|
result.type = parseJSDocType(); |
|
} |
|
return finishNode(result); |
|
} |
|
function parseJSDocParameter() { |
|
var parameter = createNode(139 /* Parameter */); |
|
parameter.type = parseJSDocType(); |
|
if (parseOptional(56 /* EqualsToken */)) { |
|
parameter.questionToken = createNode(56 /* EqualsToken */); |
|
} |
|
return finishNode(parameter); |
|
} |
|
function parseJSDocTypeReference() { |
|
var result = createNode(262 /* JSDocTypeReference */); |
|
result.name = parseSimplePropertyName(); |
|
if (token === 25 /* LessThanToken */) { |
|
result.typeArguments = parseTypeArguments(); |
|
} |
|
else { |
|
while (parseOptional(21 /* DotToken */)) { |
|
if (token === 25 /* LessThanToken */) { |
|
result.typeArguments = parseTypeArguments(); |
|
break; |
|
} |
|
else { |
|
result.name = parseQualifiedName(result.name); |
|
} |
|
} |
|
} |
|
return finishNode(result); |
|
} |
|
function parseTypeArguments() { |
|
// Move past the < |
|
nextToken(); |
|
var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); |
|
checkForTrailingComma(typeArguments); |
|
checkForEmptyTypeArgumentList(typeArguments); |
|
parseExpected(27 /* GreaterThanToken */); |
|
return typeArguments; |
|
} |
|
function checkForEmptyTypeArgumentList(typeArguments) { |
|
if (parseDiagnostics.length === 0 && typeArguments && typeArguments.length === 0) { |
|
var start = typeArguments.pos - "<".length; |
|
var end = ts.skipTrivia(sourceText, typeArguments.end) + ">".length; |
|
return parseErrorAtPosition(start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); |
|
} |
|
} |
|
function parseQualifiedName(left) { |
|
var result = createNode(136 /* QualifiedName */, left.pos); |
|
result.left = left; |
|
result.right = parseIdentifierName(); |
|
return finishNode(result); |
|
} |
|
function parseJSDocRecordType() { |
|
var result = createNode(260 /* JSDocRecordType */); |
|
nextToken(); |
|
result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); |
|
checkForTrailingComma(result.members); |
|
parseExpected(16 /* CloseBraceToken */); |
|
return finishNode(result); |
|
} |
|
function parseJSDocRecordMember() { |
|
var result = createNode(261 /* JSDocRecordMember */); |
|
result.name = parseSimplePropertyName(); |
|
if (token === 54 /* ColonToken */) { |
|
nextToken(); |
|
result.type = parseJSDocType(); |
|
} |
|
return finishNode(result); |
|
} |
|
function parseJSDocNonNullableType() { |
|
var result = createNode(259 /* JSDocNonNullableType */); |
|
nextToken(); |
|
result.type = parseJSDocType(); |
|
return finishNode(result); |
|
} |
|
function parseJSDocTupleType() { |
|
var result = createNode(257 /* JSDocTupleType */); |
|
nextToken(); |
|
result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); |
|
checkForTrailingComma(result.types); |
|
parseExpected(20 /* CloseBracketToken */); |
|
return finishNode(result); |
|
} |
|
function checkForTrailingComma(list) { |
|
if (parseDiagnostics.length === 0 && list.hasTrailingComma) { |
|
var start = list.end - ",".length; |
|
parseErrorAtPosition(start, ",".length, ts.Diagnostics.Trailing_comma_not_allowed); |
|
} |
|
} |
|
function parseJSDocUnionType() { |
|
var result = createNode(256 /* JSDocUnionType */); |
|
nextToken(); |
|
result.types = parseJSDocTypeList(parseJSDocType()); |
|
parseExpected(18 /* CloseParenToken */); |
|
return finishNode(result); |
|
} |
|
function parseJSDocTypeList(firstType) { |
|
ts.Debug.assert(!!firstType); |
|
var types = []; |
|
types.pos = firstType.pos; |
|
types.push(firstType); |
|
while (parseOptional(47 /* BarToken */)) { |
|
types.push(parseJSDocType()); |
|
} |
|
types.end = scanner.getStartPos(); |
|
return types; |
|
} |
|
function parseJSDocAllType() { |
|
var result = createNode(253 /* JSDocAllType */); |
|
nextToken(); |
|
return finishNode(result); |
|
} |
|
function parseJSDocUnknownOrNullableType() { |
|
var pos = scanner.getStartPos(); |
|
// skip the ? |
|
nextToken(); |
|
// Need to lookahead to decide if this is a nullable or unknown type. |
|
// Here are cases where we'll pick the unknown type: |
|
// |
|
// Foo(?, |
|
// { a: ? } |
|
// Foo(?) |
|
// Foo<?> |
|
// Foo(?= |
|
// (?| |
|
if (token === 24 /* CommaToken */ || |
|
token === 16 /* CloseBraceToken */ || |
|
token === 18 /* CloseParenToken */ || |
|
token === 27 /* GreaterThanToken */ || |
|
token === 56 /* EqualsToken */ || |
|
token === 47 /* BarToken */) { |
|
var result = createNode(254 /* JSDocUnknownType */, pos); |
|
return finishNode(result); |
|
} |
|
else { |
|
var result = createNode(258 /* JSDocNullableType */, pos); |
|
result.type = parseJSDocType(); |
|
return finishNode(result); |
|
} |
|
} |
|
function parseIsolatedJSDocComment(content, start, length) { |
|
initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); |
|
sourceFile = { languageVariant: 0 /* Standard */, text: content }; |
|
var jsDocComment = parseJSDocCommentWorker(start, length); |
|
var diagnostics = parseDiagnostics; |
|
clearState(); |
|
return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; |
|
} |
|
JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; |
|
function parseJSDocComment(parent, start, length) { |
|
var saveToken = token; |
|
var saveParseDiagnosticsLength = parseDiagnostics.length; |
|
var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; |
|
var comment = parseJSDocCommentWorker(start, length); |
|
if (comment) { |
|
comment.parent = parent; |
|
} |
|
token = saveToken; |
|
parseDiagnostics.length = saveParseDiagnosticsLength; |
|
parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; |
|
return comment; |
|
} |
|
JSDocParser.parseJSDocComment = parseJSDocComment; |
|
function parseJSDocCommentWorker(start, length) { |
|
var content = sourceText; |
|
start = start || 0; |
|
var end = length === undefined ? content.length : start + length; |
|
length = end - start; |
|
ts.Debug.assert(start >= 0); |
|
ts.Debug.assert(start <= end); |
|
ts.Debug.assert(end <= content.length); |
|
var tags; |
|
var result; |
|
// Check for /** (JSDoc opening part) |
|
if (content.charCodeAt(start) === 47 /* slash */ && |
|
content.charCodeAt(start + 1) === 42 /* asterisk */ && |
|
content.charCodeAt(start + 2) === 42 /* asterisk */ && |
|
content.charCodeAt(start + 3) !== 42 /* asterisk */) { |
|
// + 3 for leading /**, - 5 in total for /** */ |
|
scanner.scanRange(start + 3, length - 5, function () { |
|
// Initially we can parse out a tag. We also have seen a starting asterisk. |
|
// This is so that /** * @type */ doesn't parse. |
|
var canParseTag = true; |
|
var seenAsterisk = true; |
|
nextJSDocToken(); |
|
while (token !== 1 /* EndOfFileToken */) { |
|
switch (token) { |
|
case 55 /* AtToken */: |
|
if (canParseTag) { |
|
parseTag(); |
|
} |
|
// This will take us to the end of the line, so it's OK to parse a tag on the next pass through the loop |
|
seenAsterisk = false; |
|
break; |
|
case 4 /* NewLineTrivia */: |
|
// After a line break, we can parse a tag, and we haven't seen an asterisk on the next line yet |
|
canParseTag = true; |
|
seenAsterisk = false; |
|
break; |
|
case 37 /* AsteriskToken */: |
|
if (seenAsterisk) { |
|
// If we've already seen an asterisk, then we can no longer parse a tag on this line |
|
canParseTag = false; |
|
} |
|
// Ignore the first asterisk on a line |
|
seenAsterisk = true; |
|
break; |
|
case 69 /* Identifier */: |
|
// Anything else is doc comment text. We can't do anything with it. Because it |
|
// wasn't a tag, we can no longer parse a tag on this line until we hit the next |
|
// line break. |
|
canParseTag = false; |
|
break; |
|
case 1 /* EndOfFileToken */: |
|
break; |
|
} |
|
nextJSDocToken(); |
|
} |
|
result = createJSDocComment(); |
|
}); |
|
} |
|
return result; |
|
function createJSDocComment() { |
|
if (!tags) { |
|
return undefined; |
|
} |
|
var result = createNode(268 /* JSDocComment */, start); |
|
result.tags = tags; |
|
return finishNode(result, end); |
|
} |
|
function skipWhitespace() { |
|
while (token === 5 /* WhitespaceTrivia */ || token === 4 /* NewLineTrivia */) { |
|
nextJSDocToken(); |
|
} |
|
} |
|
function parseTag() { |
|
ts.Debug.assert(token === 55 /* AtToken */); |
|
var atToken = createNode(55 /* AtToken */, scanner.getTokenPos()); |
|
atToken.end = scanner.getTextPos(); |
|
nextJSDocToken(); |
|
var tagName = parseJSDocIdentifier(); |
|
if (!tagName) { |
|
return; |
|
} |
|
var tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); |
|
addTag(tag); |
|
} |
|
function handleTag(atToken, tagName) { |
|
if (tagName) { |
|
switch (tagName.text) { |
|
case "param": |
|
return handleParamTag(atToken, tagName); |
|
case "return": |
|
case "returns": |
|
return handleReturnTag(atToken, tagName); |
|
case "template": |
|
return handleTemplateTag(atToken, tagName); |
|
case "type": |
|
return handleTypeTag(atToken, tagName); |
|
} |
|
} |
|
return undefined; |
|
} |
|
function handleUnknownTag(atToken, tagName) { |
|
var result = createNode(269 /* JSDocTag */, atToken.pos); |
|
result.atToken = atToken; |
|
result.tagName = tagName; |
|
return finishNode(result); |
|
} |
|
function addTag(tag) { |
|
if (tag) { |
|
if (!tags) { |
|
tags = []; |
|
tags.pos = tag.pos; |
|
} |
|
tags.push(tag); |
|
tags.end = tag.end; |
|
} |
|
} |
|
function tryParseTypeExpression() { |
|
if (token !== 15 /* OpenBraceToken */) { |
|
return undefined; |
|
} |
|
var typeExpression = parseJSDocTypeExpression(); |
|
return typeExpression; |
|
} |
|
function handleParamTag(atToken, tagName) { |
|
var typeExpression = tryParseTypeExpression(); |
|
skipWhitespace(); |
|
var name; |
|
var isBracketed; |
|
// Looking for something like '[foo]' or 'foo' |
|
if (parseOptionalToken(19 /* OpenBracketToken */)) { |
|
name = parseJSDocIdentifier(); |
|
isBracketed = true; |
|
// May have an optional default, e.g. '[foo = 42]' |
|
if (parseOptionalToken(56 /* EqualsToken */)) { |
|
parseExpression(); |
|
} |
|
parseExpected(20 /* CloseBracketToken */); |
|
} |
|
else if (token === 69 /* Identifier */) { |
|
name = parseJSDocIdentifier(); |
|
} |
|
if (!name) { |
|
parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); |
|
return undefined; |
|
} |
|
var preName, postName; |
|
if (typeExpression) { |
|
postName = name; |
|
} |
|
else { |
|
preName = name; |
|
} |
|
if (!typeExpression) { |
|
typeExpression = tryParseTypeExpression(); |
|
} |
|
var result = createNode(270 /* JSDocParameterTag */, atToken.pos); |
|
result.atToken = atToken; |
|
result.tagName = tagName; |
|
result.preParameterName = preName; |
|
result.typeExpression = typeExpression; |
|
result.postParameterName = postName; |
|
result.isBracketed = isBracketed; |
|
return finishNode(result); |
|
} |
|
function handleReturnTag(atToken, tagName) { |
|
if (ts.forEach(tags, function (t) { return t.kind === 271 /* JSDocReturnTag */; })) { |
|
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); |
|
} |
|
var result = createNode(271 /* JSDocReturnTag */, atToken.pos); |
|
result.atToken = atToken; |
|
result.tagName = tagName; |
|
result.typeExpression = tryParseTypeExpression(); |
|
return finishNode(result); |
|
} |
|
function handleTypeTag(atToken, tagName) { |
|
if (ts.forEach(tags, function (t) { return t.kind === 272 /* JSDocTypeTag */; })) { |
|
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); |
|
} |
|
var result = createNode(272 /* JSDocTypeTag */, atToken.pos); |
|
result.atToken = atToken; |
|
result.tagName = tagName; |
|
result.typeExpression = tryParseTypeExpression(); |
|
return finishNode(result); |
|
} |
|
function handleTemplateTag(atToken, tagName) { |
|
if (ts.forEach(tags, function (t) { return t.kind === 273 /* JSDocTemplateTag */; })) { |
|
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); |
|
} |
|
// Type parameter list looks like '@template T,U,V' |
|
var typeParameters = []; |
|
typeParameters.pos = scanner.getStartPos(); |
|
while (true) { |
|
var name_8 = parseJSDocIdentifier(); |
|
if (!name_8) { |
|
parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); |
|
return undefined; |
|
} |
|
var typeParameter = createNode(138 /* TypeParameter */, name_8.pos); |
|
typeParameter.name = name_8; |
|
finishNode(typeParameter); |
|
typeParameters.push(typeParameter); |
|
if (token === 24 /* CommaToken */) { |
|
nextJSDocToken(); |
|
} |
|
else { |
|
break; |
|
} |
|
} |
|
var result = createNode(273 /* JSDocTemplateTag */, atToken.pos); |
|
result.atToken = atToken; |
|
result.tagName = tagName; |
|
result.typeParameters = typeParameters; |
|
finishNode(result); |
|
typeParameters.end = result.end; |
|
return result; |
|
} |
|
function nextJSDocToken() { |
|
return token = scanner.scanJSDocToken(); |
|
} |
|
function parseJSDocIdentifier() { |
|
if (token !== 69 /* Identifier */) { |
|
parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); |
|
return undefined; |
|
} |
|
var pos = scanner.getTokenPos(); |
|
var end = scanner.getTextPos(); |
|
var result = createNode(69 /* Identifier */, pos); |
|
result.text = content.substring(pos, end); |
|
finishNode(result, end); |
|
nextJSDocToken(); |
|
return result; |
|
} |
|
} |
|
JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; |
|
})(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); |
|
})(Parser || (Parser = {})); |
|
var IncrementalParser; |
|
(function (IncrementalParser) { |
|
function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { |
|
aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); |
|
checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); |
|
if (ts.textChangeRangeIsUnchanged(textChangeRange)) { |
|
// if the text didn't change, then we can just return our current source file as-is. |
|
return sourceFile; |
|
} |
|
if (sourceFile.statements.length === 0) { |
|
// If we don't have any statements in the current source file, then there's no real |
|
// way to incrementally parse. So just do a full parse instead. |
|
return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind); |
|
} |
|
// Make sure we're not trying to incrementally update a source file more than once. Once |
|
// we do an update the original source file is considered unusbale from that point onwards. |
|
// |
|
// This is because we do incremental parsing in-place. i.e. we take nodes from the old |
|
// tree and give them new positions and parents. From that point on, trusting the old |
|
// tree at all is not possible as far too much of it may violate invariants. |
|
var incrementalSourceFile = sourceFile; |
|
ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); |
|
incrementalSourceFile.hasBeenIncrementallyParsed = true; |
|
var oldText = sourceFile.text; |
|
var syntaxCursor = createSyntaxCursor(sourceFile); |
|
// Make the actual change larger so that we know to reparse anything whose lookahead |
|
// might have intersected the change. |
|
var changeRange = extendToAffectedRange(sourceFile, textChangeRange); |
|
checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks); |
|
// Ensure that extending the affected range only moved the start of the change range |
|
// earlier in the file. |
|
ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start); |
|
ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span)); |
|
ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange))); |
|
// The is the amount the nodes after the edit range need to be adjusted. It can be |
|
// positive (if the edit added characters), negative (if the edit deleted characters) |
|
// or zero (if this was a pure overwrite with nothing added/removed). |
|
var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length; |
|
// If we added or removed characters during the edit, then we need to go and adjust all |
|
// the nodes after the edit. Those nodes may move forward (if we inserted chars) or they |
|
// may move backward (if we deleted chars). |
|
// |
|
// Doing this helps us out in two ways. First, it means that any nodes/tokens we want |
|
// to reuse are already at the appropriate position in the new text. That way when we |
|
// reuse them, we don't have to figure out if they need to be adjusted. Second, it makes |
|
// it very easy to determine if we can reuse a node. If the node's position is at where |
|
// we are in the text, then we can reuse it. Otherwise we can't. If the node's position |
|
// is ahead of us, then we'll need to rescan tokens. If the node's position is behind |
|
// us, then we'll need to skip it or crumble it as appropriate |
|
// |
|
// We will also adjust the positions of nodes that intersect the change range as well. |
|
// By doing this, we ensure that all the positions in the old tree are consistent, not |
|
// just the positions of nodes entirely before/after the change range. By being |
|
// consistent, we can then easily map from positions to nodes in the old tree easily. |
|
// |
|
// Also, mark any syntax elements that intersect the changed span. We know, up front, |
|
// that we cannot reuse these elements. |
|
updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks); |
|
// Now that we've set up our internal incremental state just proceed and parse the |
|
// source file in the normal fashion. When possible the parser will retrieve and |
|
// reuse nodes from the old tree. |
|
// |
|
// Note: passing in 'true' for setNodeParents is very important. When incrementally |
|
// parsing, we will be reusing nodes from the old tree, and placing it into new |
|
// parents. If we don't set the parents now, we'll end up with an observably |
|
// inconsistent tree. Setting the parents on the new tree should be very fast. We |
|
// will immediately bail out of walking any subtrees when we can see that their parents |
|
// are already correct. |
|
var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind); |
|
return result; |
|
} |
|
IncrementalParser.updateSourceFile = updateSourceFile; |
|
function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) { |
|
if (isArray) { |
|
visitArray(element); |
|
} |
|
else { |
|
visitNode(element); |
|
} |
|
return; |
|
function visitNode(node) { |
|
var text = ""; |
|
if (aggressiveChecks && shouldCheckNode(node)) { |
|
text = oldText.substring(node.pos, node.end); |
|
} |
|
// Ditch any existing LS children we may have created. This way we can avoid |
|
// moving them forward. |
|
if (node._children) { |
|
node._children = undefined; |
|
} |
|
if (node.jsDocComment) { |
|
node.jsDocComment = undefined; |
|
} |
|
node.pos += delta; |
|
node.end += delta; |
|
if (aggressiveChecks && shouldCheckNode(node)) { |
|
ts.Debug.assert(text === newText.substring(node.pos, node.end)); |
|
} |
|
forEachChild(node, visitNode, visitArray); |
|
checkNodePositions(node, aggressiveChecks); |
|
} |
|
function visitArray(array) { |
|
array._children = undefined; |
|
array.pos += delta; |
|
array.end += delta; |
|
for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { |
|
var node = array_7[_i]; |
|
visitNode(node); |
|
} |
|
} |
|
} |
|
function shouldCheckNode(node) { |
|
switch (node.kind) { |
|
case 9 /* StringLiteral */: |
|
case 8 /* NumericLiteral */: |
|
case 69 /* Identifier */: |
|
return true; |
|
} |
|
return false; |
|
} |
|
function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) { |
|
ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range"); |
|
ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range"); |
|
ts.Debug.assert(element.pos <= element.end); |
|
// We have an element that intersects the change range in some way. It may have its |
|
// start, or its end (or both) in the changed range. We want to adjust any part |
|
// that intersects such that the final tree is in a consistent state. i.e. all |
|
// chlidren have spans within the span of their parent, and all siblings are ordered |
|
// properly. |
|
// We may need to update both the 'pos' and the 'end' of the element. |
|
// If the 'pos' is before the start of the change, then we don't need to touch it. |
|
// If it isn't, then the 'pos' must be inside the change. How we update it will |
|
// depend if delta is positive or negative. If delta is positive then we have |
|
// something like: |
|
// |
|
// -------------------AAA----------------- |
|
// -------------------BBBCCCCCCC----------------- |
|
// |
|
// In this case, we consider any node that started in the change range to still be |
|
// starting at the same position. |
|
// |
|
// however, if the delta is negative, then we instead have something like this: |
|
// |
|
// -------------------XXXYYYYYYY----------------- |
|
// -------------------ZZZ----------------- |
|
// |
|
// In this case, any element that started in the 'X' range will keep its position. |
|
// However any element htat started after that will have their pos adjusted to be |
|
// at the end of the new range. i.e. any node that started in the 'Y' range will |
|
// be adjusted to have their start at the end of the 'Z' range. |
|
// |
|
// The element will keep its position if possible. Or Move backward to the new-end |
|
// if it's in the 'Y' range. |
|
element.pos = Math.min(element.pos, changeRangeNewEnd); |
|
// If the 'end' is after the change range, then we always adjust it by the delta |
|
// amount. However, if the end is in the change range, then how we adjust it |
|
// will depend on if delta is positive or negative. If delta is positive then we |
|
// have something like: |
|
// |
|
// -------------------AAA----------------- |
|
// -------------------BBBCCCCCCC----------------- |
|
// |
|
// In this case, we consider any node that ended inside the change range to keep its |
|
// end position. |
|
// |
|
// however, if the delta is negative, then we instead have something like this: |
|
// |
|
// -------------------XXXYYYYYYY----------------- |
|
// -------------------ZZZ----------------- |
|
// |
|
// In this case, any element that ended in the 'X' range will keep its position. |
|
// However any element htat ended after that will have their pos adjusted to be |
|
// at the end of the new range. i.e. any node that ended in the 'Y' range will |
|
// be adjusted to have their end at the end of the 'Z' range. |
|
if (element.end >= changeRangeOldEnd) { |
|
// Element ends after the change range. Always adjust the end pos. |
|
element.end += delta; |
|
} |
|
else { |
|
// Element ends in the change range. The element will keep its position if |
|
// possible. Or Move backward to the new-end if it's in the 'Y' range. |
|
element.end = Math.min(element.end, changeRangeNewEnd); |
|
} |
|
ts.Debug.assert(element.pos <= element.end); |
|
if (element.parent) { |
|
ts.Debug.assert(element.pos >= element.parent.pos); |
|
ts.Debug.assert(element.end <= element.parent.end); |
|
} |
|
} |
|
function checkNodePositions(node, aggressiveChecks) { |
|
if (aggressiveChecks) { |
|
var pos_2 = node.pos; |
|
forEachChild(node, function (child) { |
|
ts.Debug.assert(child.pos >= pos_2); |
|
pos_2 = child.end; |
|
}); |
|
ts.Debug.assert(pos_2 <= node.end); |
|
} |
|
} |
|
function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { |
|
visitNode(sourceFile); |
|
return; |
|
function visitNode(child) { |
|
ts.Debug.assert(child.pos <= child.end); |
|
if (child.pos > changeRangeOldEnd) { |
|
// Node is entirely past the change range. We need to move both its pos and |
|
// end, forward or backward appropriately. |
|
moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks); |
|
return; |
|
} |
|
// Check if the element intersects the change range. If it does, then it is not |
|
// reusable. Also, we'll need to recurse to see what constituent portions we may |
|
// be able to use. |
|
var fullEnd = child.end; |
|
if (fullEnd >= changeStart) { |
|
child.intersectsChange = true; |
|
child._children = undefined; |
|
// Adjust the pos or end (or both) of the intersecting element accordingly. |
|
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); |
|
forEachChild(child, visitNode, visitArray); |
|
checkNodePositions(child, aggressiveChecks); |
|
return; |
|
} |
|
// Otherwise, the node is entirely before the change range. No need to do anything with it. |
|
ts.Debug.assert(fullEnd < changeStart); |
|
} |
|
function visitArray(array) { |
|
ts.Debug.assert(array.pos <= array.end); |
|
if (array.pos > changeRangeOldEnd) { |
|
// Array is entirely after the change range. We need to move it, and move any of |
|
// its children. |
|
moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks); |
|
return; |
|
} |
|
// Check if the element intersects the change range. If it does, then it is not |
|
// reusable. Also, we'll need to recurse to see what constituent portions we may |
|
// be able to use. |
|
var fullEnd = array.end; |
|
if (fullEnd >= changeStart) { |
|
array.intersectsChange = true; |
|
array._children = undefined; |
|
// Adjust the pos or end (or both) of the intersecting array accordingly. |
|
adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); |
|
for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { |
|
var node = array_8[_i]; |
|
visitNode(node); |
|
} |
|
return; |
|
} |
|
// Otherwise, the array is entirely before the change range. No need to do anything with it. |
|
ts.Debug.assert(fullEnd < changeStart); |
|
} |
|
} |
|
function extendToAffectedRange(sourceFile, changeRange) { |
|
// Consider the following code: |
|
// void foo() { /; } |
|
// |
|
// If the text changes with an insertion of / just before the semicolon then we end up with: |
|
// void foo() { //; } |
|
// |
|
// If we were to just use the changeRange a is, then we would not rescan the { token |
|
// (as it does not intersect the actual original change range). Because an edit may |
|
// change the token touching it, we actually need to look back *at least* one token so |
|
// that the prior token sees that change. |
|
var maxLookahead = 1; |
|
var start = changeRange.span.start; |
|
// the first iteration aligns us with the change start. subsequent iteration move us to |
|
// the left by maxLookahead tokens. We only need to do this as long as we're not at the |
|
// start of the tree. |
|
for (var i = 0; start > 0 && i <= maxLookahead; i++) { |
|
var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start); |
|
ts.Debug.assert(nearestNode.pos <= start); |
|
var position = nearestNode.pos; |
|
start = Math.max(0, position - 1); |
|
} |
|
var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span)); |
|
var finalLength = changeRange.newLength + (changeRange.span.start - start); |
|
return ts.createTextChangeRange(finalSpan, finalLength); |
|
} |
|
function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) { |
|
var bestResult = sourceFile; |
|
var lastNodeEntirelyBeforePosition; |
|
forEachChild(sourceFile, visit); |
|
if (lastNodeEntirelyBeforePosition) { |
|
var lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition); |
|
if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) { |
|
bestResult = lastChildOfLastEntireNodeBeforePosition; |
|
} |
|
} |
|
return bestResult; |
|
function getLastChild(node) { |
|
while (true) { |
|
var lastChild = getLastChildWorker(node); |
|
if (lastChild) { |
|
node = lastChild; |
|
} |
|
else { |
|
return node; |
|
} |
|
} |
|
} |
|
function getLastChildWorker(node) { |
|
var last = undefined; |
|
forEachChild(node, function (child) { |
|
if (ts.nodeIsPresent(child)) { |
|
last = child; |
|
} |
|
}); |
|
return last; |
|
} |
|
function visit(child) { |
|
if (ts.nodeIsMissing(child)) { |
|
// Missing nodes are effectively invisible to us. We never even consider them |
|
// When trying to find the nearest node before us. |
|
return; |
|
} |
|
// If the child intersects this position, then this node is currently the nearest |
|
// node that starts before the position. |
|
if (child.pos <= position) { |
|
if (child.pos >= bestResult.pos) { |
|
// This node starts before the position, and is closer to the position than |
|
// the previous best node we found. It is now the new best node. |
|
bestResult = child; |
|
} |
|
// Now, the node may overlap the position, or it may end entirely before the |
|
// position. If it overlaps with the position, then either it, or one of its |
|
// children must be the nearest node before the position. So we can just |
|
// recurse into this child to see if we can find something better. |
|
if (position < child.end) { |
|
// The nearest node is either this child, or one of the children inside |
|
// of it. We've already marked this child as the best so far. Recurse |
|
// in case one of the children is better. |
|
forEachChild(child, visit); |
|
// Once we look at the children of this node, then there's no need to |
|
// continue any further. |
|
return true; |
|
} |
|
else { |
|
ts.Debug.assert(child.end <= position); |
|
// The child ends entirely before this position. Say you have the following |
|
// (where $ is the position) |
|
// |
|
// <complex expr 1> ? <complex expr 2> $ : <...> <...> |
|
// |
|
// We would want to find the nearest preceding node in "complex expr 2". |
|
// To support that, we keep track of this node, and once we're done searching |
|
// for a best node, we recurse down this node to see if we can find a good |
|
// result in it. |
|
// |
|
// This approach allows us to quickly skip over nodes that are entirely |
|
// before the position, while still allowing us to find any nodes in the |
|
// last one that might be what we want. |
|
lastNodeEntirelyBeforePosition = child; |
|
} |
|
} |
|
else { |
|
ts.Debug.assert(child.pos > position); |
|
// We're now at a node that is entirely past the position we're searching for. |
|
// This node (and all following nodes) could never contribute to the result, |
|
// so just skip them by returning 'true' here. |
|
return true; |
|
} |
|
} |
|
} |
|
function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) { |
|
var oldText = sourceFile.text; |
|
if (textChangeRange) { |
|
ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); |
|
if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { |
|
var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); |
|
var newTextPrefix = newText.substr(0, textChangeRange.span.start); |
|
ts.Debug.assert(oldTextPrefix === newTextPrefix); |
|
var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length); |
|
var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length); |
|
ts.Debug.assert(oldTextSuffix === newTextSuffix); |
|
} |
|
} |
|
} |
|
function createSyntaxCursor(sourceFile) { |
|
var currentArray = sourceFile.statements; |
|
var currentArrayIndex = 0; |
|
ts.Debug.assert(currentArrayIndex < currentArray.length); |
|
var current = currentArray[currentArrayIndex]; |
|
var lastQueriedPosition = -1 /* Value */; |
|
return { |
|
currentNode: function (position) { |
|
// Only compute the current node if the position is different than the last time |
|
// we were asked. The parser commonly asks for the node at the same position |
|
// twice. Once to know if can read an appropriate list element at a certain point, |
|
// and then to actually read and consume the node. |
|
if (position !== lastQueriedPosition) { |
|
// Much of the time the parser will need the very next node in the array that |
|
// we just returned a node from.So just simply check for that case and move |
|
// forward in the array instead of searching for the node again. |
|
if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) { |
|
currentArrayIndex++; |
|
current = currentArray[currentArrayIndex]; |
|
} |
|
// If we don't have a node, or the node we have isn't in the right position, |
|
// then try to find a viable node at the position requested. |
|
if (!current || current.pos !== position) { |
|
findHighestListElementThatStartsAtPosition(position); |
|
} |
|
} |
|
// Cache this query so that we don't do any extra work if the parser calls back |
|
// into us. Note: this is very common as the parser will make pairs of calls like |
|
// 'isListElement -> parseListElement'. If we were unable to find a node when |
|
// called with 'isListElement', we don't want to redo the work when parseListElement |
|
// is called immediately after. |
|
lastQueriedPosition = position; |
|
// Either we don'd have a node, or we have a node at the position being asked for. |
|
ts.Debug.assert(!current || current.pos === position); |
|
return current; |
|
} |
|
}; |
|
// Finds the highest element in the tree we can find that starts at the provided position. |
|
// The element must be a direct child of some node list in the tree. This way after we |
|
// return it, we can easily return its next sibling in the list. |
|
function findHighestListElementThatStartsAtPosition(position) { |
|
// Clear out any cached state about the last node we found. |
|
currentArray = undefined; |
|
currentArrayIndex = -1 /* Value */; |
|
current = undefined; |
|
// Recurse into the source file to find the highest node at this position. |
|
forEachChild(sourceFile, visitNode, visitArray); |
|
return; |
|
function visitNode(node) { |
|
if (position >= node.pos && position < node.end) { |
|
// Position was within this node. Keep searching deeper to find the node. |
|
forEachChild(node, visitNode, visitArray); |
|
// don't procede any futher in the search. |
|
return true; |
|
} |
|
// position wasn't in this node, have to keep searching. |
|
return false; |
|
} |
|
function visitArray(array) { |
|
if (position >= array.pos && position < array.end) { |
|
// position was in this array. Search through this array to see if we find a |
|
// viable element. |
|
for (var i = 0, n = array.length; i < n; i++) { |
|
var child = array[i]; |
|
if (child) { |
|
if (child.pos === position) { |
|
// Found the right node. We're done. |
|
currentArray = array; |
|
currentArrayIndex = i; |
|
current = child; |
|
return true; |
|
} |
|
else { |
|
if (child.pos < position && position < child.end) { |
|
// Position in somewhere within this child. Search in it and |
|
// stop searching in this array. |
|
forEachChild(child, visitNode, visitArray); |
|
return true; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
// position wasn't in this array, have to keep searching. |
|
return false; |
|
} |
|
} |
|
} |
|
var InvalidPosition; |
|
(function (InvalidPosition) { |
|
InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; |
|
})(InvalidPosition || (InvalidPosition = {})); |
|
})(IncrementalParser || (IncrementalParser = {})); |
|
})(ts || (ts = {})); |
|
/// <reference path="utilities.ts"/> |
|
/// <reference path="parser.ts"/> |
|
/* @internal */ |
|
var ts; |
|
(function (ts) { |
|
ts.bindTime = 0; |
|
(function (ModuleInstanceState) { |
|
ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; |
|
ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; |
|
ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; |
|
})(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); |
|
var ModuleInstanceState = ts.ModuleInstanceState; |
|
var Reachability; |
|
(function (Reachability) { |
|
Reachability[Reachability["Unintialized"] = 1] = "Unintialized"; |
|
Reachability[Reachability["Reachable"] = 2] = "Reachable"; |
|
Reachability[Reachability["Unreachable"] = 4] = "Unreachable"; |
|
Reachability[Reachability["ReportedUnreachable"] = 8] = "ReportedUnreachable"; |
|
})(Reachability || (Reachability = {})); |
|
function or(state1, state2) { |
|
return (state1 | state2) & 2 /* Reachable */ |
|
? 2 /* Reachable */ |
|
: (state1 & state2) & 8 /* ReportedUnreachable */ |
|
? 8 /* ReportedUnreachable */ |
|
: 4 /* Unreachable */; |
|
} |
|
function getModuleInstanceState(node) { |
|
// A module is uninstantiated if it contains only |
|
// 1. interface declarations, type alias declarations |
|
if (node.kind === 218 /* InterfaceDeclaration */ || node.kind === 219 /* TypeAliasDeclaration */) { |
|
return 0 /* NonInstantiated */; |
|
} |
|
else if (ts.isConstEnumDeclaration(node)) { |
|
return 2 /* ConstEnumOnly */; |
|
} |
|
else if ((node.kind === 225 /* ImportDeclaration */ || node.kind === 224 /* ImportEqualsDeclaration */) && !(node.flags & 2 /* Export */)) { |
|
return 0 /* NonInstantiated */; |
|
} |
|
else if (node.kind === 222 /* ModuleBlock */) { |
|
var state_1 = 0 /* NonInstantiated */; |
|
ts.forEachChild(node, function (n) { |
|
switch (getModuleInstanceState(n)) { |
|
case 0 /* NonInstantiated */: |
|
// child is non-instantiated - continue searching |
|
return false; |
|
case 2 /* ConstEnumOnly */: |
|
// child is const enum only - record state and continue searching |
|
state_1 = 2 /* ConstEnumOnly */; |
|
return false; |
|
case 1 /* Instantiated */: |
|
// child is instantiated - record state and stop |
|
state_1 = 1 /* Instantiated */; |
|
return true; |
|
} |
|
}); |
|
return state_1; |
|
} |
|
else if (node.kind === 221 /* ModuleDeclaration */) { |
|
return getModuleInstanceState(node.body); |
|
} |
|
else { |
|
return 1 /* Instantiated */; |
|
} |
|
} |
|
ts.getModuleInstanceState = getModuleInstanceState; |
|
var ContainerFlags; |
|
(function (ContainerFlags) { |
|
// The current node is not a container, and no container manipulation should happen before |
|
// recursing into it. |
|
ContainerFlags[ContainerFlags["None"] = 0] = "None"; |
|
// The current node is a container. It should be set as the current container (and block- |
|
// container) before recursing into it. The current node does not have locals. Examples: |
|
// |
|
// Classes, ObjectLiterals, TypeLiterals, Interfaces... |
|
ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; |
|
// The current node is a block-scoped-container. It should be set as the current block- |
|
// container before recursing into it. Examples: |
|
// |
|
// Blocks (when not parented by functions), Catch clauses, For/For-in/For-of statements... |
|
ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; |
|
ContainerFlags[ContainerFlags["HasLocals"] = 4] = "HasLocals"; |
|
// If the current node is a container that also container that also contains locals. Examples: |
|
// |
|
// Functions, Methods, Modules, Source-files. |
|
ContainerFlags[ContainerFlags["IsContainerWithLocals"] = 5] = "IsContainerWithLocals"; |
|
})(ContainerFlags || (ContainerFlags = {})); |
|
var binder = createBinder(); |
|
function bindSourceFile(file, options) { |
|
var start = new Date().getTime(); |
|
binder(file, options); |
|
ts.bindTime += new Date().getTime() - start; |
|
} |
|
ts.bindSourceFile = bindSourceFile; |
|
function createBinder() { |
|
var file; |
|
var options; |
|
var parent; |
|
var container; |
|
var blockScopeContainer; |
|
var lastContainer; |
|
var seenThisKeyword; |
|
// state used by reachability checks |
|
var hasExplicitReturn; |
|
var currentReachabilityState; |
|
var labelStack; |
|
var labelIndexMap; |
|
var implicitLabels; |
|
// state used for emit helpers |
|
var hasClassExtends; |
|
var hasAsyncFunctions; |
|
var hasDecorators; |
|
var hasParameterDecorators; |
|
var hasJsxSpreadAttribute; |
|
// If this file is an external module, then it is automatically in strict-mode according to |
|
// ES6. If it is not an external module, then we'll determine if it is in strict mode or |
|
// not depending on if we see "use strict" in certain places (or if we hit a class/namespace). |
|
var inStrictMode; |
|
var symbolCount = 0; |
|
var Symbol; |
|
var classifiableNames; |
|
function bindSourceFile(f, opts) { |
|
file = f; |
|
options = opts; |
|
inStrictMode = !!file.externalModuleIndicator; |
|
classifiableNames = {}; |
|
Symbol = ts.objectAllocator.getSymbolConstructor(); |
|
if (!file.locals) { |
|
bind(file); |
|
file.symbolCount = symbolCount; |
|
file.classifiableNames = classifiableNames; |
|
} |
|
file = undefined; |
|
options = undefined; |
|
parent = undefined; |
|
container = undefined; |
|
blockScopeContainer = undefined; |
|
lastContainer = undefined; |
|
seenThisKeyword = false; |
|
hasExplicitReturn = false; |
|
labelStack = undefined; |
|
labelIndexMap = undefined; |
|
implicitLabels = undefined; |
|
hasClassExtends = false; |
|
hasAsyncFunctions = false; |
|
hasDecorators = false; |
|
hasParameterDecorators = false; |
|
hasJsxSpreadAttribute = false; |
|
} |
|
return bindSourceFile; |
|
function createSymbol(flags, name) { |
|
symbolCount++; |
|
return new Symbol(flags, name); |
|
} |
|
function addDeclarationToSymbol(symbol, node, symbolFlags) { |
|
symbol.flags |= symbolFlags; |
|
node.symbol = symbol; |
|
if (!symbol.declarations) { |
|
symbol.declarations = []; |
|
} |
|
symbol.declarations.push(node); |
|
if (symbolFlags & 1952 /* HasExports */ && !symbol.exports) { |
|
symbol.exports = {}; |
|
} |
|
if (symbolFlags & 6240 /* HasMembers */ && !symbol.members) { |
|
symbol.members = {}; |
|
} |
|
if (symbolFlags & 107455 /* Value */) { |
|
var valueDeclaration = symbol.valueDeclaration; |
|
if (!valueDeclaration || |
|
(valueDeclaration.kind !== node.kind && valueDeclaration.kind === 221 /* ModuleDeclaration */)) { |
|
// other kinds of value declarations take precedence over modules |
|
symbol.valueDeclaration = node; |
|
} |
|
} |
|
} |
|
// Should not be called on a declaration with a computed property name, |
|
// unless it is a well known Symbol. |
|
function getDeclarationName(node) { |
|
if (node.name) { |
|
if (ts.isAmbientModule(node)) { |
|
return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; |
|
} |
|
if (node.name.kind === 137 /* ComputedPropertyName */) { |
|
var nameExpression = node.name.expression; |
|
// treat computed property names where expression is string/numeric literal as just string/numeric literal |
|
if (ts.isStringOrNumericLiteral(nameExpression.kind)) { |
|
return nameExpression.text; |
|
} |
|
ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); |
|
return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); |
|
} |
|
return node.name.text; |
|
} |
|
switch (node.kind) { |
|
case 145 /* Constructor */: |
|
return "__constructor"; |
|
case 153 /* FunctionType */: |
|
case 148 /* CallSignature */: |
|
return "__call"; |
|
case 154 /* ConstructorType */: |
|
case 149 /* ConstructSignature */: |
|
return "__new"; |
|
case 150 /* IndexSignature */: |
|
return "__index"; |
|
case 231 /* ExportDeclaration */: |
|
return "__export"; |
|
case 230 /* ExportAssignment */: |
|
return node.isExportEquals ? "export=" : "default"; |
|
case 184 /* BinaryExpression */: |
|
switch (ts.getSpecialPropertyAssignmentKind(node)) { |
|
case 2 /* ModuleExports */: |
|
// module.exports = ... |
|
return "export="; |
|
case 1 /* ExportsProperty */: |
|
case 4 /* ThisProperty */: |
|
// exports.x = ... or this.y = ... |
|
return node.left.name.text; |
|
case 3 /* PrototypeProperty */: |
|
// className.prototype.methodName = ... |
|
return node.left.expression.name.text; |
|
} |
|
ts.Debug.fail("Unknown binary declaration kind"); |
|
break; |
|
case 216 /* FunctionDeclaration */: |
|
case 217 /* ClassDeclaration */: |
|
return node.flags & 512 /* Default */ ? "default" : undefined; |
|
case 264 /* JSDocFunctionType */: |
|
return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; |
|
case 139 /* Parameter */: |
|
// Parameters with names are handled at the top of this function. Parameters |
|
// without names can only come from JSDocFunctionTypes. |
|
ts.Debug.assert(node.parent.kind === 264 /* JSDocFunctionType */); |
|
var functionType = node.parent; |
|
var index = ts.indexOf(functionType.parameters, node); |
|
return "p" + index; |
|
} |
|
} |
|
function getDisplayName(node) { |
|
return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); |
|
} |
|
/** |
|
* Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. |
|
* @param symbolTable - The symbol table which node will be added to. |
|
* @param parent - node's parent declaration. |
|
* @param node - The declaration to be added to the symbol table |
|
* @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.) |
|
* @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations. |
|
*/ |
|
function declareSymbol(symbolTable, parent, node, includes, excludes) { |
|
ts.Debug.assert(!ts.hasDynamicName(node)); |
|
var isDefaultExport = node.flags & 512 /* Default */; |
|
// The exported symbol for an export default function/class node is always named "default" |
|
var name = isDefaultExport && parent ? "default" : getDeclarationName(node); |
|
var symbol; |
|
if (name !== undefined) { |
|
// Check and see if the symbol table already has a symbol with this name. If not, |
|
// create a new symbol with this name and add it to the table. Note that we don't |
|
// give the new symbol any flags *yet*. This ensures that it will not conflict |
|
// with the 'excludes' flags we pass in. |
|
// |
|
// If we do get an existing symbol, see if it conflicts with the new symbol we're |
|
// creating. For example, a 'var' symbol and a 'class' symbol will conflict within |
|
// the same symbol table. If we have a conflict, report the issue on each |
|
// declaration we have for this symbol, and then create a new symbol for this |
|
// declaration. |
|
// |
|
// If we created a new symbol, either because we didn't have a symbol with this name |
|
// in the symbol table, or we conflicted with an existing symbol, then just add this |
|
// node as the sole declaration of the new symbol. |
|
// |
|
// Otherwise, we'll be merging into a compatible existing symbol (for example when |
|
// you have multiple 'vars' with the same name in the same container). In this case |
|
// just add this node into the declarations list of the symbol. |
|
symbol = ts.hasProperty(symbolTable, name) |
|
? symbolTable[name] |
|
: (symbolTable[name] = createSymbol(0 /* None */, name)); |
|
if (name && (includes & 788448 /* Classifiable */)) { |
|
classifiableNames[name] = name; |
|
} |
|
if (symbol.flags & excludes) { |
|
if (node.name) { |
|
node.name.parent = node; |
|
} |
|
// Report errors every position with duplicate declaration |
|
// Report errors on previous encountered declarations |
|
var message_1 = symbol.flags & 2 /* BlockScopedVariable */ |
|
? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 |
|
: ts.Diagnostics.Duplicate_identifier_0; |
|
ts.forEach(symbol.declarations, function (declaration) { |
|
if (declaration.flags & 512 /* Default */) { |
|
message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; |
|
} |
|
}); |
|
ts.forEach(symbol.declarations, function (declaration) { |
|
file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message_1, getDisplayName(declaration))); |
|
}); |
|
file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message_1, getDisplayName(node))); |
|
symbol = createSymbol(0 /* None */, name); |
|
} |
|
} |
|
else { |
|
symbol = createSymbol(0 /* None */, "__missing"); |
|
} |
|
addDeclarationToSymbol(symbol, node, includes); |
|
symbol.parent = parent; |
|
return symbol; |
|
} |
|
function declareModuleMember(node, symbolFlags, symbolExcludes) { |
|
var hasExportModifier = ts.getCombinedNodeFlags(node) & 2 /* Export */; |
|
if (symbolFlags & 8388608 /* Alias */) { |
|
if (node.kind === 233 /* ExportSpecifier */ || (node.kind === 224 /* ImportEqualsDeclaration */ && hasExportModifier)) { |
|
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); |
|
} |
|
else { |
|
return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); |
|
} |
|
} |
|
else { |
|
// Exported module members are given 2 symbols: A local symbol that is classified with an ExportValue, |
|
// ExportType, or ExportContainer flag, and an associated export symbol with all the correct flags set |
|
// on it. There are 2 main reasons: |
|
// |
|
// 1. We treat locals and exports of the same name as mutually exclusive within a container. |
|
// That means the binder will issue a Duplicate Identifier error if you mix locals and exports |
|
// with the same name in the same container. |
|
// TODO: Make this a more specific error and decouple it from the exclusion logic. |
|
// 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol, |
|
// but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way |
|
// when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. |
|
// NOTE: Nested ambient modules always should go to to 'locals' table to prevent their automatic merge |
|
// during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation |
|
// and this case is specially handled. Module augmentations should only be merged with original module definition |
|
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. |
|
if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 131072 /* ExportContext */)) { |
|
var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | |
|
(symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | |
|
(symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); |
|
var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); |
|
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); |
|
node.localSymbol = local; |
|
return local; |
|
} |
|
else { |
|
return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); |
|
} |
|
} |
|
} |
|
// All container nodes are kept on a linked list in declaration order. This list is used by |
|
// the getLocalNameOfContainer function in the type checker to validate that the local name |
|
// used for a container is unique. |
|
function bindChildren(node) { |
|
// Before we recurse into a node's chilren, we first save the existing parent, container |
|
// and block-container. Then after we pop out of processing the children, we restore |
|
// these saved values. |
|
var saveParent = parent; |
|
var saveContainer = container; |
|
var savedBlockScopeContainer = blockScopeContainer; |
|
// This node will now be set as the parent of all of its children as we recurse into them. |
|
parent = node; |
|
// Depending on what kind of node this is, we may have to adjust the current container |
|
// and block-container. If the current node is a container, then it is automatically |
|
// considered the current block-container as well. Also, for containers that we know |
|
// may contain locals, we proactively initialize the .locals field. We do this because |
|
// it's highly likely that the .locals will be needed to place some child in (for example, |
|
// a parameter, or variable declaration). |
|
// |
|
// However, we do not proactively create the .locals for block-containers because it's |
|
// totally normal and common for block-containers to never actually have a block-scoped |
|
// variable in them. We don't want to end up allocating an object for every 'block' we |
|
// run into when most of them won't be necessary. |
|
// |
|
// Finally, if this is a block-container, then we clear out any existing .locals object |
|
// it may contain within it. This happens in incremental scenarios. Because we can be |
|
// reusing a node from a previous compilation, that node may have had 'locals' created |
|
// for it. We must clear this so we don't accidently move any stale data forward from |
|
// a previous compilation. |
|
var containerFlags = getContainerFlags(node); |
|
if (containerFlags & 1 /* IsContainer */) { |
|
container = blockScopeContainer = node; |
|
if (containerFlags & 4 /* HasLocals */) { |
|
container.locals = {}; |
|
} |
|
addToContainerChain(container); |
|
} |
|
else if (containerFlags & 2 /* IsBlockScopedContainer */) { |
|
blockScopeContainer = node; |
|
blockScopeContainer.locals = undefined; |
|
} |
|
var savedReachabilityState; |
|
var savedLabelStack; |
|
var savedLabels; |
|
var savedImplicitLabels; |
|
var savedHasExplicitReturn; |
|
var kind = node.kind; |
|
var flags = node.flags; |
|
// reset all reachability check related flags on node (for incremental scenarios) |
|
flags &= ~1572864 /* ReachabilityCheckFlags */; |
|
// reset all emit helper flags on node (for incremental scenarios) |
|
flags &= ~62914560 /* EmitHelperFlags */; |
|
if (kind === 218 /* InterfaceDeclaration */) { |
|
seenThisKeyword = false; |
|
} |
|
var saveState = kind === 251 /* SourceFile */ || kind === 222 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); |
|
if (saveState) { |
|
savedReachabilityState = currentReachabilityState; |
|
savedLabelStack = labelStack; |
|
savedLabels = labelIndexMap; |
|
savedImplicitLabels = implicitLabels; |
|
savedHasExplicitReturn = hasExplicitReturn; |
|
currentReachabilityState = 2 /* Reachable */; |
|
hasExplicitReturn = false; |
|
labelStack = labelIndexMap = implicitLabels = undefined; |
|
} |
|
if (ts.isInJavaScriptFile(node) && node.jsDocComment) { |
|
bind(node.jsDocComment); |
|
} |
|
bindReachableStatement(node); |
|
if (currentReachabilityState === 2 /* Reachable */ && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { |
|
flags |= 524288 /* HasImplicitReturn */; |
|
if (hasExplicitReturn) { |
|
flags |= 1048576 /* HasExplicitReturn */; |
|
} |
|
} |
|
if (kind === 218 /* InterfaceDeclaration */) { |
|
flags = seenThisKeyword ? flags | 262144 /* ContainsThis */ : flags & ~262144 /* ContainsThis */; |
|
} |
|
if (kind === 251 /* SourceFile */) { |
|
if (hasClassExtends) { |
|
flags |= 4194304 /* HasClassExtends */; |
|
} |
|
if (hasDecorators) { |
|
flags |= 8388608 /* HasDecorators */; |
|
} |
|
if (hasParameterDecorators) { |
|
flags |= 16777216 /* HasParamDecorators */; |
|
} |
|
if (hasAsyncFunctions) { |
|
flags |= 33554432 /* HasAsyncFunctions */; |
|
} |
|
if (hasJsxSpreadAttribute) { |
|
flags |= 1073741824 /* HasJsxSpreadAttribute */; |
|
} |
|
} |
|
node.flags = flags; |
|
if (saveState) { |
|
hasExplicitReturn = savedHasExplicitReturn; |
|
currentReachabilityState = savedReachabilityState; |
|
labelStack = savedLabelStack; |
|
labelIndexMap = savedLabels; |
|
implicitLabels = savedImplicitLabels; |
|
} |
|
container = saveContainer; |
|
parent = saveParent; |
|
blockScopeContainer = savedBlockScopeContainer; |
|
} |
|
/** |
|
* Returns true if node and its subnodes were successfully traversed. |
|
* Returning false means that node was not examined and caller needs to dive into the node himself. |
|
*/ |
|
function bindReachableStatement(node) { |
|
if (checkUnreachable(node)) { |
|
ts.forEachChild(node, bind); |
|
return; |
|
} |
|
switch (node.kind) { |
|
case 201 /* WhileStatement */: |
|
bindWhileStatement(node); |
|
break; |
|
case 200 /* DoStatement */: |
|
bindDoStatement(node); |
|
break; |
|
case 202 /* ForStatement */: |
|
bindForStatement(node); |
|
break; |
|
case 203 /* ForInStatement */: |
|
case 204 /* ForOfStatement */: |
|
bindForInOrForOfStatement(node); |
|
break; |
|
case 199 /* IfStatement */: |
|
bindIfStatement(node); |
|
break; |
|
case 207 /* ReturnStatement */: |
|
case 211 /* ThrowStatement */: |
|
bindReturnOrThrow(node); |
|
break; |
|
case 206 /* BreakStatement */: |
|
case 205 /* ContinueStatement */: |
|
bindBreakOrContinueStatement(node); |
|
break; |
|
case 212 /* TryStatement */: |
|
bindTryStatement(node); |
|
break; |
|
case 209 /* SwitchStatement */: |
|
bindSwitchStatement(node); |
|
break; |
|
case 223 /* CaseBlock */: |
|
bindCaseBlock(node); |
|
break; |
|
case 210 /* LabeledStatement */: |
|
bindLabeledStatement(node); |
|
break; |
|
default: |
|
ts.forEachChild(node, bind); |
|
break; |
|
} |
|
} |
|
function bindWhileStatement(n) { |
|
var preWhileState = n.expression.kind === 84 /* FalseKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; |
|
var postWhileState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; |
|
// bind expressions (don't affect reachability) |
|
bind(n.expression); |
|
currentReachabilityState = preWhileState; |
|
var postWhileLabel = pushImplicitLabel(); |
|
bind(n.statement); |
|
popImplicitLabel(postWhileLabel, postWhileState); |
|
} |
|
function bindDoStatement(n) { |
|
var preDoState = currentReachabilityState; |
|
var postDoLabel = pushImplicitLabel(); |
|
bind(n.statement); |
|
var postDoState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : preDoState; |
|
popImplicitLabel(postDoLabel, postDoState); |
|
// bind expressions (don't affect reachability) |
|
bind(n.expression); |
|
} |
|
function bindForStatement(n) { |
|
var preForState = currentReachabilityState; |
|
var postForLabel = pushImplicitLabel(); |
|
// bind expressions (don't affect reachability) |
|
bind(n.initializer); |
|
bind(n.condition); |
|
bind(n.incrementor); |
|
bind(n.statement); |
|
// for statement is considered infinite when it condition is either omitted or is true keyword |
|
// - for(..;;..) |
|
// - for(..;true;..) |
|
var isInfiniteLoop = (!n.condition || n.condition.kind === 99 /* TrueKeyword */); |
|
var postForState = isInfiniteLoop ? 4 /* Unreachable */ : preForState; |
|
popImplicitLabel(postForLabel, postForState); |
|
} |
|
function bindForInOrForOfStatement(n) { |
|
var preStatementState = currentReachabilityState; |
|
var postStatementLabel = pushImplicitLabel(); |
|
// bind expressions (don't affect reachability) |
|
bind(n.initializer); |
|
bind(n.expression); |
|
bind(n.statement); |
|
popImplicitLabel(postStatementLabel, preStatementState); |
|
} |
|
function bindIfStatement(n) { |
|
// denotes reachability state when entering 'thenStatement' part of the if statement: |
|
// i.e. if condition is false then thenStatement is unreachable |
|
var ifTrueState = n.expression.kind === 84 /* FalseKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; |
|
// denotes reachability state when entering 'elseStatement': |
|
// i.e. if condition is true then elseStatement is unreachable |
|
var ifFalseState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; |
|
currentReachabilityState = ifTrueState; |
|
// bind expression (don't affect reachability) |
|
bind(n.expression); |
|
bind(n.thenStatement); |
|
if (n.elseStatement) { |
|
var preElseState = currentReachabilityState; |
|
currentReachabilityState = ifFalseState; |
|
bind(n.elseStatement); |
|
currentReachabilityState = or(currentReachabilityState, preElseState); |
|
} |
|
else { |
|
currentReachabilityState = or(currentReachabilityState, ifFalseState); |
|
} |
|
} |
|
function bindReturnOrThrow(n) { |
|
// bind expression (don't affect reachability) |
|
bind(n.expression); |
|
if (n.kind === 207 /* ReturnStatement */) { |
|
hasExplicitReturn = true; |
|
} |
|
currentReachabilityState = 4 /* Unreachable */; |
|
} |
|
function bindBreakOrContinueStatement(n) { |
|
// call bind on label (don't affect reachability) |
|
bind(n.label); |
|
// for continue case touch label so it will be marked a used |
|
var isValidJump = jumpToLabel(n.label, n.kind === 206 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); |
|
if (isValidJump) { |
|
currentReachabilityState = 4 /* Unreachable */; |
|
} |
|
} |
|
function bindTryStatement(n) { |
|
// catch\finally blocks has the same reachability as try block |
|
var preTryState = currentReachabilityState; |
|
bind(n.tryBlock); |
|
var postTryState = currentReachabilityState; |
|
currentReachabilityState = preTryState; |
|
bind(n.catchClause); |
|
var postCatchState = currentReachabilityState; |
|
currentReachabilityState = preTryState; |
|
bind(n.finallyBlock); |
|
// post catch/finally state is reachable if |
|
// - post try state is reachable - control flow can fall out of try block |
|
// - post catch state is reachable - control flow can fall out of catch block |
|
currentReachabilityState = or(postTryState, postCatchState); |
|
} |
|
function bindSwitchStatement(n) { |
|
var preSwitchState = currentReachabilityState; |
|
var postSwitchLabel = pushImplicitLabel(); |
|
// bind expression (don't affect reachability) |
|
bind(n.expression); |
|
bind(n.caseBlock); |
|
var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 245 /* DefaultClause */; }); |
|
// post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case |
|
var postSwitchState = hasDefault && currentReachabilityState !== 2 /* Reachable */ ? 4 /* Unreachable */ : preSwitchState; |
|
popImplicitLabel(postSwitchLabel, postSwitchState); |
|
} |
|
function bindCaseBlock(n) { |
|
var startState = currentReachabilityState; |
|
for (var _i = 0, _a = n.clauses; _i < _a.length; _i++) { |
|
var clause = _a[_i]; |
|
currentReachabilityState = startState; |
|
bind(clause); |
|
if (clause.statements.length && currentReachabilityState === 2 /* Reachable */ && options.noFallthroughCasesInSwitch) { |
|
errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); |
|
} |
|
} |
|
} |
|
function bindLabeledStatement(n) { |
|
// call bind on label (don't affect reachability) |
|
bind(n.label); |
|
var ok = pushNamedLabel(n.label); |
|
bind(n.statement); |
|
if (ok) { |
|
popNamedLabel(n.label, currentReachabilityState); |
|
} |
|
} |
|
function getContainerFlags(node) { |
|
switch (node.kind) { |
|
case 189 /* ClassExpression */: |
|
case 217 /* ClassDeclaration */: |
|
case 218 /* InterfaceDeclaration */: |
|
case 220 /* EnumDeclaration */: |
|
case 168 /* ObjectLiteralExpression */: |
|
case 156 /* TypeLiteral */: |
|
case 260 /* JSDocRecordType */: |
|
return 1 /* IsContainer */; |
|
case 148 /* CallSignature */: |
|
case 149 /* ConstructSignature */: |
|
case 150 /* IndexSignature */: |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
case 216 /* FunctionDeclaration */: |
|
case 145 /* Constructor */: |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
case 153 /* FunctionType */: |
|
case 264 /* JSDocFunctionType */: |
|
case 154 /* ConstructorType */: |
|
case 176 /* FunctionExpression */: |
|
case 177 /* ArrowFunction */: |
|
case 221 /* ModuleDeclaration */: |
|
case 251 /* SourceFile */: |
|
case 219 /* TypeAliasDeclaration */: |
|
return 5 /* IsContainerWithLocals */; |
|
case 247 /* CatchClause */: |
|
case 202 /* ForStatement */: |
|
case 203 /* ForInStatement */: |
|
case 204 /* ForOfStatement */: |
|
case 223 /* CaseBlock */: |
|
return 2 /* IsBlockScopedContainer */; |
|
case 195 /* Block */: |
|
// do not treat blocks directly inside a function as a block-scoped-container. |
|
// Locals that reside in this block should go to the function locals. Othewise 'x' |
|
// would not appear to be a redeclaration of a block scoped local in the following |
|
// example: |
|
// |
|
// function foo() { |
|
// var x; |
|
// let x; |
|
// } |
|
// |
|
// If we placed 'var x' into the function locals and 'let x' into the locals of |
|
// the block, then there would be no collision. |
|
// |
|
// By not creating a new block-scoped-container here, we ensure that both 'var x' |
|
// and 'let x' go into the Function-container's locals, and we do get a collision |
|
// conflict. |
|
return ts.isFunctionLike(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; |
|
} |
|
return 0 /* None */; |
|
} |
|
function addToContainerChain(next) { |
|
if (lastContainer) { |
|
lastContainer.nextContainer = next; |
|
} |
|
lastContainer = next; |
|
} |
|
function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { |
|
// Just call this directly so that the return type of this function stays "void". |
|
declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); |
|
} |
|
function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { |
|
switch (container.kind) { |
|
// Modules, source files, and classes need specialized handling for how their |
|
// members are declared (for example, a member of a class will go into a specific |
|
// symbol table depending on if it is static or not). We defer to specialized |
|
// handlers to take care of declaring these child members. |
|
case 221 /* ModuleDeclaration */: |
|
return declareModuleMember(node, symbolFlags, symbolExcludes); |
|
case 251 /* SourceFile */: |
|
return declareSourceFileMember(node, symbolFlags, symbolExcludes); |
|
case 189 /* ClassExpression */: |
|
case 217 /* ClassDeclaration */: |
|
return declareClassMember(node, symbolFlags, symbolExcludes); |
|
case 220 /* EnumDeclaration */: |
|
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); |
|
case 156 /* TypeLiteral */: |
|
case 168 /* ObjectLiteralExpression */: |
|
case 218 /* InterfaceDeclaration */: |
|
case 260 /* JSDocRecordType */: |
|
// Interface/Object-types always have their children added to the 'members' of |
|
// their container. They are only accessible through an instance of their |
|
// container, and are never in scope otherwise (even inside the body of the |
|
// object / type / interface declaring them). An exception is type parameters, |
|
// which are in scope without qualification (similar to 'locals'). |
|
return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); |
|
case 153 /* FunctionType */: |
|
case 154 /* ConstructorType */: |
|
case 148 /* CallSignature */: |
|
case 149 /* ConstructSignature */: |
|
case 150 /* IndexSignature */: |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
case 145 /* Constructor */: |
|
case 146 /* GetAccessor */: |
|
case 147 /* SetAccessor */: |
|
case 216 /* FunctionDeclaration */: |
|
case 176 /* FunctionExpression */: |
|
case 177 /* ArrowFunction */: |
|
case 264 /* JSDocFunctionType */: |
|
case 219 /* TypeAliasDeclaration */: |
|
// All the children of these container types are never visible through another |
|
// symbol (i.e. through another symbol's 'exports' or 'members'). Instead, |
|
// they're only accessed 'lexically' (i.e. from code that exists underneath |
|
// their container in the tree. To accomplish this, we simply add their declared |
|
// symbol to the 'locals' of the container. These symbols can then be found as |
|
// the type checker walks up the containers, checking them for matching names. |
|
return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); |
|
} |
|
} |
|
function declareClassMember(node, symbolFlags, symbolExcludes) { |
|
return node.flags & 64 /* Static */ |
|
? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) |
|
: declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); |
|
} |
|
function declareSourceFileMember(node, symbolFlags, symbolExcludes) { |
|
return ts.isExternalModule(file) |
|
? declareModuleMember(node, symbolFlags, symbolExcludes) |
|
: declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); |
|
} |
|
function hasExportDeclarations(node) { |
|
var body = node.kind === 251 /* SourceFile */ ? node : node.body; |
|
if (body.kind === 251 /* SourceFile */ || body.kind === 222 /* ModuleBlock */) { |
|
for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { |
|
var stat = _a[_i]; |
|
if (stat.kind === 231 /* ExportDeclaration */ || stat.kind === 230 /* ExportAssignment */) { |
|
return true; |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
function setExportContextFlag(node) { |
|
// A declaration source file or ambient module declaration that contains no export declarations (but possibly regular |
|
// declarations with export modifiers) is an export context in which declarations are implicitly exported. |
|
if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { |
|
node.flags |= 131072 /* ExportContext */; |
|
} |
|
else { |
|
node.flags &= ~131072 /* ExportContext */; |
|
} |
|
} |
|
function bindModuleDeclaration(node) { |
|
setExportContextFlag(node); |
|
if (ts.isAmbientModule(node)) { |
|
if (node.flags & 2 /* Export */) { |
|
errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); |
|
} |
|
declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); |
|
} |
|
else { |
|
var state = getModuleInstanceState(node); |
|
if (state === 0 /* NonInstantiated */) { |
|
declareSymbolAndAddToSymbolTable(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */); |
|
} |
|
else { |
|
declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); |
|
if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)) { |
|
// if module was already merged with some function, class or non-const enum |
|
// treat is a non-const-enum-only |
|
node.symbol.constEnumOnlyModule = false; |
|
} |
|
else { |
|
var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; |
|
if (node.symbol.constEnumOnlyModule === undefined) { |
|
// non-merged case - use the current state |
|
node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; |
|
} |
|
else { |
|
// merged case: module is const enum only if all its pieces are non-instantiated or const enum |
|
node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
function bindFunctionOrConstructorType(node) { |
|
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical |
|
// to the one we would get for: { <...>(...): T } |
|
// |
|
// We do that by making an anonymous type literal symbol, and then setting the function |
|
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable |
|
// from an actual type literal symbol you would have gotten had you used the long form. |
|
var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); |
|
addDeclarationToSymbol(symbol, node, 131072 /* Signature */); |
|
var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); |
|
addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); |
|
typeLiteralSymbol.members = (_a = {}, _a[symbol.name] = symbol, _a); |
|
var _a; |
|
} |
|
function bindObjectLiteralExpression(node) { |
|
var ElementKind; |
|
(function (ElementKind) { |
|
ElementKind[ElementKind["Property"] = 1] = "Property"; |
|
ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; |
|
})(ElementKind || (ElementKind = {})); |
|
if (inStrictMode) { |
|
var seen = {}; |
|
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { |
|
var prop = _a[_i]; |
|
if (prop.name.kind !== 69 /* Identifier */) { |
|
continue; |
|
} |
|
var identifier = prop.name; |
|
// ECMA-262 11.1.5 Object Initialiser |
|
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true |
|
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and |
|
// IsDataDescriptor(propId.descriptor) is true. |
|
// b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. |
|
// c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. |
|
// d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true |
|
// and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields |
|
var currentKind = prop.kind === 248 /* PropertyAssignment */ || prop.kind === 249 /* ShorthandPropertyAssignment */ || prop.kind === 144 /* MethodDeclaration */ |
|
? 1 /* Property */ |
|
: 2 /* Accessor */; |
|
var existingKind = seen[identifier.text]; |
|
if (!existingKind) { |
|
seen[identifier.text] = currentKind; |
|
continue; |
|
} |
|
if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { |
|
var span = ts.getErrorSpanForNode(file, identifier); |
|
file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); |
|
} |
|
} |
|
} |
|
return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object"); |
|
} |
|
function bindAnonymousDeclaration(node, symbolFlags, name) { |
|
var symbol = createSymbol(symbolFlags, name); |
|
addDeclarationToSymbol(symbol, node, symbolFlags); |
|
} |
|
function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { |
|
switch (blockScopeContainer.kind) { |
|
case 221 /* ModuleDeclaration */: |
|
declareModuleMember(node, symbolFlags, symbolExcludes); |
|
break; |
|
case 251 /* SourceFile */: |
|
if (ts.isExternalModule(container)) { |
|
declareModuleMember(node, symbolFlags, symbolExcludes); |
|
break; |
|
} |
|
// fall through. |
|
default: |
|
if (!blockScopeContainer.locals) { |
|
blockScopeContainer.locals = {}; |
|
addToContainerChain(blockScopeContainer); |
|
} |
|
declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); |
|
} |
|
} |
|
function bindBlockScopedVariableDeclaration(node) { |
|
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); |
|
} |
|
// The binder visits every node in the syntax tree so it is a convenient place to perform a single localized |
|
// check for reserved words used as identifiers in strict mode code. |
|
function checkStrictModeIdentifier(node) { |
|
if (inStrictMode && |
|
node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && |
|
node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && |
|
!ts.isIdentifierName(node)) { |
|
// Report error only if there are no parse errors in file |
|
if (!file.parseDiagnostics.length) { |
|
file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); |
|
} |
|
} |
|
} |
|
function getStrictModeIdentifierMessage(node) { |
|
// Provide specialized messages to help the user understand why we think they're in |
|
// strict mode. |
|
if (ts.getContainingClass(node)) { |
|
return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; |
|
} |
|
if (file.externalModuleIndicator) { |
|
return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; |
|
} |
|
return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; |
|
} |
|
function checkStrictModeBinaryExpression(node) { |
|
if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) { |
|
// ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an |
|
// Assignment operator(11.13) or of a PostfixExpression(11.3) |
|
checkStrictModeEvalOrArguments(node, node.left); |
|
} |
|
} |
|
function checkStrictModeCatchClause(node) { |
|
// It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the |
|
// Catch production is eval or arguments |
|
if (inStrictMode && node.variableDeclaration) { |
|
checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); |
|
} |
|
} |
|
function checkStrictModeDeleteExpression(node) { |
|
// Grammar checking |
|
if (inStrictMode && node.expression.kind === 69 /* Identifier */) { |
|
// When a delete operator occurs within strict mode code, a SyntaxError is thrown if its |
|
// UnaryExpression is a direct reference to a variable, function argument, or function name |
|
var span = ts.getErrorSpanForNode(file, node.expression); |
|
file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); |
|
} |
|
} |
|
function isEvalOrArgumentsIdentifier(node) { |
|
return node.kind === 69 /* Identifier */ && |
|
(node.text === "eval" || node.text === "arguments"); |
|
} |
|
function checkStrictModeEvalOrArguments(contextNode, name) { |
|
if (name && name.kind === 69 /* Identifier */) { |
|
var identifier = name; |
|
if (isEvalOrArgumentsIdentifier(identifier)) { |
|
// We check first if the name is inside class declaration or class expression; if so give explicit message |
|
// otherwise report generic error message. |
|
var span = ts.getErrorSpanForNode(file, name); |
|
file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); |
|
} |
|
} |
|
} |
|
function getStrictModeEvalOrArgumentsMessage(node) { |
|
// Provide specialized messages to help the user understand why we think they're in |
|
// strict mode. |
|
if (ts.getContainingClass(node)) { |
|
return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; |
|
} |
|
if (file.externalModuleIndicator) { |
|
return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; |
|
} |
|
return ts.Diagnostics.Invalid_use_of_0_in_strict_mode; |
|
} |
|
function checkStrictModeFunctionName(node) { |
|
if (inStrictMode) { |
|
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) |
|
checkStrictModeEvalOrArguments(node, node.name); |
|
} |
|
} |
|
function checkStrictModeNumericLiteral(node) { |
|
if (inStrictMode && node.flags & 32768 /* OctalLiteral */) { |
|
file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); |
|
} |
|
} |
|
function checkStrictModePostfixUnaryExpression(node) { |
|
// Grammar checking |
|
// The identifier eval or arguments may not appear as the LeftHandSideExpression of an |
|
// Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression |
|
// operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. |
|
if (inStrictMode) { |
|
checkStrictModeEvalOrArguments(node, node.operand); |
|
} |
|
} |
|
function checkStrictModePrefixUnaryExpression(node) { |
|
// Grammar checking |
|
if (inStrictMode) { |
|
if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { |
|
checkStrictModeEvalOrArguments(node, node.operand); |
|
} |
|
} |
|
} |
|
function checkStrictModeWithStatement(node) { |
|
// Grammar checking for withStatement |
|
if (inStrictMode) { |
|
errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); |
|
} |
|
} |
|
function errorOnFirstToken(node, message, arg0, arg1, arg2) { |
|
var span = ts.getSpanOfTokenAtPosition(file, node.pos); |
|
file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); |
|
} |
|
function getDestructuringParameterName(node) { |
|
return "__" + ts.indexOf(node.parent.parameters, node); |
|
} |
|
function bind(node) { |
|
if (!node) { |
|
return; |
|
} |
|
node.parent = parent; |
|
var savedInStrictMode = inStrictMode; |
|
if (!savedInStrictMode) { |
|
updateStrictMode(node); |
|
} |
|
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol |
|
// and then potentially add the symbol to an appropriate symbol table. Possible |
|
// destination symbol tables are: |
|
// |
|
// 1) The 'exports' table of the current container's symbol. |
|
// 2) The 'members' table of the current container's symbol. |
|
// 3) The 'locals' table of the current container. |
|
// |
|
// However, not all symbols will end up in any of these tables. 'Anonymous' symbols |
|
// (like TypeLiterals for example) will not be put in any table. |
|
bindWorker(node); |
|
// Then we recurse into the children of the node to bind them as well. For certain |
|
// symbols we do specialized work when we recurse. For example, we'll keep track of |
|
// the current 'container' node when it changes. This helps us know which symbol table |
|
// a local should go into for example. |
|
bindChildren(node); |
|
inStrictMode = savedInStrictMode; |
|
} |
|
function updateStrictMode(node) { |
|
switch (node.kind) { |
|
case 251 /* SourceFile */: |
|
case 222 /* ModuleBlock */: |
|
updateStrictModeStatementList(node.statements); |
|
return; |
|
case 195 /* Block */: |
|
if (ts.isFunctionLike(node.parent)) { |
|
updateStrictModeStatementList(node.statements); |
|
} |
|
return; |
|
case 217 /* ClassDeclaration */: |
|
case 189 /* ClassExpression */: |
|
// All classes are automatically in strict mode in ES6. |
|
inStrictMode = true; |
|
return; |
|
} |
|
} |
|
function updateStrictModeStatementList(statements) { |
|
for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { |
|
var statement = statements_1[_i]; |
|
if (!ts.isPrologueDirective(statement)) { |
|
return; |
|
} |
|
if (isUseStrictPrologueDirective(statement)) { |
|
inStrictMode = true; |
|
return; |
|
} |
|
} |
|
} |
|
/// Should be called only on prologue directives (isPrologueDirective(node) should be true) |
|
function isUseStrictPrologueDirective(node) { |
|
var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); |
|
// Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the |
|
// string to contain unicode escapes (as per ES5). |
|
return nodeText === "\"use strict\"" || nodeText === "'use strict'"; |
|
} |
|
function bindWorker(node) { |
|
switch (node.kind) { |
|
/* Strict mode checks */ |
|
case 69 /* Identifier */: |
|
return checkStrictModeIdentifier(node); |
|
case 184 /* BinaryExpression */: |
|
if (ts.isInJavaScriptFile(node)) { |
|
var specialKind = ts.getSpecialPropertyAssignmentKind(node); |
|
switch (specialKind) { |
|
case 1 /* ExportsProperty */: |
|
bindExportsPropertyAssignment(node); |
|
break; |
|
case 2 /* ModuleExports */: |
|
bindModuleExportsAssignment(node); |
|
break; |
|
case 3 /* PrototypeProperty */: |
|
bindPrototypePropertyAssignment(node); |
|
break; |
|
case 4 /* ThisProperty */: |
|
bindThisPropertyAssignment(node); |
|
break; |
|
case 0 /* None */: |
|
// Nothing to do |
|
break; |
|
default: |
|
ts.Debug.fail("Unknown special property assignment kind"); |
|
} |
|
} |
|
return checkStrictModeBinaryExpression(node); |
|
case 247 /* CatchClause */: |
|
return checkStrictModeCatchClause(node); |
|
case 178 /* DeleteExpression */: |
|
return checkStrictModeDeleteExpression(node); |
|
case 8 /* NumericLiteral */: |
|
return checkStrictModeNumericLiteral(node); |
|
case 183 /* PostfixUnaryExpression */: |
|
return checkStrictModePostfixUnaryExpression(node); |
|
case 182 /* PrefixUnaryExpression */: |
|
return checkStrictModePrefixUnaryExpression(node); |
|
case 208 /* WithStatement */: |
|
return checkStrictModeWithStatement(node); |
|
case 162 /* ThisType */: |
|
seenThisKeyword = true; |
|
return; |
|
case 151 /* TypePredicate */: |
|
return checkTypePredicate(node); |
|
case 138 /* TypeParameter */: |
|
return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); |
|
case 139 /* Parameter */: |
|
return bindParameter(node); |
|
case 214 /* VariableDeclaration */: |
|
case 166 /* BindingElement */: |
|
return bindVariableDeclarationOrBindingElement(node); |
|
case 142 /* PropertyDeclaration */: |
|
case 141 /* PropertySignature */: |
|
case 261 /* JSDocRecordMember */: |
|
return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); |
|
case 248 /* PropertyAssignment */: |
|
case 249 /* ShorthandPropertyAssignment */: |
|
return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); |
|
case 250 /* EnumMember */: |
|
return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); |
|
case 242 /* JsxSpreadAttribute */: |
|
hasJsxSpreadAttribute = true; |
|
return; |
|
case 148 /* CallSignature */: |
|
case 149 /* ConstructSignature */: |
|
case 150 /* IndexSignature */: |
|
return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); |
|
case 144 /* MethodDeclaration */: |
|
case 143 /* MethodSignature */: |
|
// If this is an ObjectLiteralExpression method, then it sits in the same space |
|
// as other properties in the object literal. So we use SymbolFlags.PropertyExcludes |
|
// so that it will conflict with any other object literal members with the same |
|
// name. |
|
return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); |
|
case 216 /* FunctionDeclaration */: |
|
return bindFunctionDeclaration(node); |
|
case 145 /* Constructor */: |
|
return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); |
|
case 146 /* GetAccessor */: |
|
return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); |
|
case 147 /* SetAccessor */: |
|
return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); |
|
case 153 /* FunctionType */: |
|
case 154 /* ConstructorType */: |
|
case 264 /* JSDocFunctionType */: |
|
return bindFunctionOrConstructorType(node); |
|
case 156 /* TypeLiteral */: |
|
case 260 /* JSDocRecordType */: |
|
return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); |
|
case 168 /* ObjectLiteralExpression */: |
|
return bindObjectLiteralExpression(node); |
|
case 176 /* FunctionExpression */: |
|
case 177 /* ArrowFunction */: |
|
return bindFunctionExpression(node); |
|
case 171 /* CallExpression */: |
|
if (ts.isInJavaScriptFile(node)) { |
|
bindCallExpression(node); |
|
} |
|
break; |
|
// Members of classes, interfaces, and modules |
|
case 189 /* ClassExpression */: |
|
case 217 /* ClassDeclaration */: |
|
return bindClassLikeDeclaration(node); |
|
case 218 /* InterfaceDeclaration */: |
|
return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); |
|
case 219 /* TypeAliasDeclaration */: |
|
return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); |
|
case 220 /* EnumDeclaration */: |
|
return bindEnumDeclaration(node); |
|
case 221 /* ModuleDeclaration */: |
|
return bindModuleDeclaration(node); |
|
// Imports and exports |
|
case 224 /* ImportEqualsDeclaration */: |
|
case 227 /* NamespaceImport */: |
|
case 229 /* ImportSpecifier */: |
|
case 233 /* ExportSpecifier */: |
|
return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); |
|
case 226 /* ImportClause */: |
|
return bindImportClause(node); |
|
case 231 /* ExportDeclaration */: |
|
return bindExportDeclaration(node); |
|
case 230 /* ExportAssignment */: |
|
return bindExportAssignment(node); |
|
case 251 /* SourceFile */: |
|
return bindSourceFileIfExternalModule(); |
|
} |
|
} |
|
function checkTypePredicate(node) { |
|
var parameterName = node.parameterName, type = node.type; |
|
if (parameterName && parameterName.kind === 69 /* Identifier */) { |
|
checkStrictModeIdentifier(parameterName); |
|
} |
|
if (parameterName && parameterName.kind === 162 /* ThisType */) { |
|
seenThisKeyword = true; |
|
} |
|
bind(type); |
|
} |
|
function bindSourceFileIfExternalModule() { |
|
setExportContextFlag(file); |
|
if (ts.isExternalModule(file)) { |
|
bindSourceFileAsExternalModule(); |
|
} |
|
} |
|
function bindSourceFileAsExternalModule() { |
|
bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); |
|
} |
|
function bindExportAssignment(node) { |
|
var boundExpression = node.kind === 230 /* ExportAssignment */ ? node.expression : node.right; |
|
if (!container.symbol || !container.symbol.exports) { |
|
// Export assignment in some sort of block construct |
|
bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); |
|
} |
|
else if (boundExpression.kind === 69 /* Identifier */ && node.kind === 230 /* ExportAssignment */) { |
|
// An export default clause with an identifier exports all meanings of that identifier |
|
declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); |
|
} |
|
else { |
|
// An export default clause with an expression exports a value |
|
declareSymbol(container.symbol.exports, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); |
|
} |
|
} |
|
function bindExportDeclaration(node) { |
|
if (!container.symbol || !container.symbol.exports) { |
|
// Export * in some sort of block construct |
|
bindAnonymousDeclaration(node, 1073741824 /* ExportStar */, getDeclarationName(node)); |
|
} |
|
else if (!node.exportClause) { |
|
// All export * declarations are collected in an __export symbol |
|
declareSymbol(container.symbol.exports, container.symbol, node, 1073741824 /* ExportStar */, 0 /* None */); |
|
} |
|
} |
|
function bindImportClause(node) { |
|
if (node.name) { |
|
declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); |
|
} |
|
} |
|
function setCommonJsModuleIndicator(node) { |
|
if (!file.commonJsModuleIndicator) { |
|
file.commonJsModuleIndicator = node; |
|
bindSourceFileAsExternalModule(); |
|
} |
|
} |
|
function bindExportsPropertyAssignment(node) { |
|
// When we create a property via 'exports.foo = bar', the 'exports.foo' property access |
|
// expression is the declaration |
|
setCommonJsModuleIndicator(node); |
|
declareSymbol(file.symbol.exports, file.symbol, node.left, 4 /* Property */ | 7340032 /* Export */, 0 /* None */); |
|
} |
|
function bindModuleExportsAssignment(node) { |
|
// 'module.exports = expr' assignment |
|
setCommonJsModuleIndicator(node); |
|
declareSymbol(file.symbol.exports, file.symbol, node, 4 /* Property */ | 7340032 /* Export */ | 512 /* ValueModule */, 0 /* None */); |
|
} |
|
function bindThisPropertyAssignment(node) { |
|
// Declare a 'member' in case it turns out the container was an ES5 class |
|
if (container.kind === 176 /* FunctionExpression */ || container.kind === 216 /* FunctionDeclaration */) { |
|
container.symbol.members = container.symbol.members || {}; |
|
// It's acceptable for multiple 'this' assignments of the same identifier to occur |
|
declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */ & ~4 /* Property */); |
|
} |
|
} |
|
function bindPrototypePropertyAssignment(node) { |
|
// We saw a node of the form 'x.prototype.y = z'. Declare a 'member' y on x if x was a function. |
|
// Look up the function in the local scope, since prototype assignments should |
|
// follow the function declaration |
|
var leftSideOfAssignment = node.left; |
|
var classPrototype = leftSideOfAssignment.expression; |
|
var constructorFunction = classPrototype.expression; |
|
// Fix up parent pointers since we're going to use these nodes before we bind into them |
|
leftSideOfAssignment.parent = node; |
|
constructorFunction.parent = classPrototype; |
|
classPrototype.parent = leftSideOfAssignment; |
|
var funcSymbol = container.locals[constructorFunction.text]; |
|
if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */)) { |
|
return; |
|
} |
|
// Set up the members collection if it doesn't exist already |
|
if (!funcSymbol.members) { |
|
funcSymbol.members = {}; |
|
} |
|
// Declare the method/property |
|
// It's acceptable for multiple prototype property assignments of the same identifier to occur |
|
declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4 /* Property */, 107455 /* PropertyExcludes */ & ~4 /* Property */); |
|
} |
|
function bindCallExpression(node) { |
|
// We're only inspecting call expressions to detect CommonJS modules, so we can skip |
|
// this check if we've already seen the module indicator |
|
if (!file.commonJsModuleIndicator && ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ false)) { |
|
setCommonJsModuleIndicator(node); |
|
} |
|
} |
|
function bindClassLikeDeclaration(node) { |
|
if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { |
|
if (ts.getClassExtendsHeritageClauseElement(node) !== undefined) { |
|
hasClassExtends = true; |
|
} |
|
if (ts.nodeIsDecorated(node)) { |
|
hasDecorators = true; |
|
} |
|
} |
|
if (node.kind === 217 /* ClassDeclaration */) { |
|
bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); |
|
} |
|
else { |
|
var bindingName = node.name ? node.name.text : "__class"; |
|
bindAnonymousDeclaration(node, 32 /* Class */, bindingName); |
|
// Add name of class expression into the map for semantic classifier |
|
if (node.name) { |
|
classifiableNames[node.name.text] = node.name.text; |
|
} |
|
} |
|
var symbol = node.symbol; |
|
// TypeScript 1.0 spec (April 2014): 8.4 |
|
// Every class automatically contains a static property member named 'prototype', the |
|
// type of which is an instantiation of the class type with type Any supplied as a type |
|
// argument for each type parameter. It is an error to explicitly declare a static |
|
// property member with the name 'prototype'. |
|
// |
|
// Note: we check for this here because this class may be merging into a module. The |
|
// module might have an exported variable called 'prototype'. We can't allow that as |
|
// that would clash with the built-in 'prototype' for the class. |
|
var prototypeSymbol = createSymbol(4 /* Property */ | 134217728 /* Prototype */, "prototype"); |
|
if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { |
|
if (node.name) { |
|
node.name.parent = node; |
|
} |
|
file.bindDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); |
|
} |
|
symbol.exports[prototypeSymbol.name] = prototypeSymbol; |
|
prototypeSymbol.parent = symbol; |
|
} |
|
function bindEnumDeclaration(node) { |
|
return ts.isConst(node) |
|
? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) |
|
: bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); |
|
} |
|
function bindVariableDeclarationOrBindingElement(node) { |
|
if (inStrictMode) { |
|
checkStrictModeEvalOrArguments(node, node.name); |
|
} |
|
if (!ts.isBindingPattern(node.name)) { |
|
if (ts.isBlockOrCatchScoped(node)) { |
|
bindBlockScopedVariableDeclaration(node); |
|
} |
|
else if (ts.isParameterDeclaration(node)) { |
|
// It is safe to walk up parent chain to find whether the node is a destructing parameter declaration |
|
// because its parent chain has already been set up, since parents are set before descending into children. |
|
// |
|
// If node is a binding element in parameter declaration, we need to use ParameterExcludes. |
|
// Using ParameterExcludes flag allows the compiler to report an error on duplicate identifiers in Parameter Declaration |
|
// For example: |
|
// function foo([a,a]) {} // Duplicate Identifier error |
|
// function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter |
|
// // which correctly set excluded symbols |
|
declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); |
|
} |
|
else { |
|
declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */); |
|
} |
|
} |
|
} |
|
function bindParameter(node) { |
|
if (!ts.isDeclarationFile(file) && |
|
!ts.isInAmbientContext(node) && |
|
ts.nodeIsDecorated(node)) { |
|
hasDecorators = true; |
|
hasParameterDecorators = true; |
|
} |
|
if (inStrictMode) { |
|
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a |
|
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1) |
|
checkStrictModeEvalOrArguments(node, node.name); |
|
} |
|
if (ts.isBindingPattern(node.name)) { |
|
bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, getDestructuringParameterName(node)); |
|
} |
|
else { |
|
declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); |
|
} |
|
// If this is a property-parameter, then also declare the property symbol into the |
|
// containing class. |
|
if (ts.isParameterPropertyDeclaration(node)) { |
|
var classDeclaration = node.parent.parent; |
|
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); |
|
} |
|
} |
|
function bindFunctionDeclaration(node) { |
|
if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { |
|
if (ts.isAsyncFunctionLike(node)) { |
|
hasAsyncFunctions = true; |
|
} |
|
} |
|
checkStrictModeFunctionName(node); |
|
return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); |
|
} |
|
function bindFunctionExpression(node) { |
|
if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { |
|
if (ts.isAsyncFunctionLike(node)) { |
|
hasAsyncFunctions = true; |
|
} |
|
} |
|
checkStrictModeFunctionName(node); |
|
var bindingName = node.name ? node.name.text : "__function"; |
|
return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); |
|
} |
|
function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { |
|
if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { |
|
if (ts.isAsyncFunctionLike(node)) { |
|
hasAsyncFunctions = true; |
|
} |
|
if (ts.nodeIsDecorated(node)) { |
|
hasDecorators = true; |
|
} |
|
} |
|
return ts.hasDynamicName(node) |
|
? bindAnonymousDeclaration(node, symbolFlags, "__computed") |
|
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); |
|
} |
|
// reachability checks |
|
function pushNamedLabel(name) { |
|
initializeReachabilityStateIfNecessary(); |
|
if (ts.hasProperty(labelIndexMap, name.text)) { |
|
return false; |
|
} |
|
labelIndexMap[name.text] = labelStack.push(1 /* Unintialized */) - 1; |
|
return true; |
|
} |
|
function pushImplicitLabel() { |
|
initializeReachabilityStateIfNecessary(); |
|
var index = labelStack.push(1 /* Unintialized */) - 1; |
|
implicitLabels.push(index); |
|
return index; |
|
} |
|
function popNamedLabel(label, outerState) { |
|
var index = labelIndexMap[label.text]; |
|
ts.Debug.assert(index !== undefined); |
|
ts.Debug.assert(labelStack.length == index + 1); |
|
labelIndexMap[label.text] = undefined; |
|
setCurrentStateAtLabel(labelStack.pop(), outerState, label); |
|
} |
|
function popImplicitLabel(implicitLabelIndex, outerState) { |
|
if (labelStack.length !== implicitLabelIndex + 1) { |
|
ts.Debug.assert(false, "Label stack: " + labelStack.length + ", index:" + implicitLabelIndex); |
|
} |
|
var i = implicitLabels.pop(); |
|
if (implicitLabelIndex !== i) { |
|
ts.Debug.assert(false, "i: " + i + ", index: " + implicitLabelIndex); |
|
} |
|
setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined); |
|
} |
|
function setCurrentStateAtLabel(innerMergedState, outerState, label) { |
|
if (innerMergedState === 1 /* Unintialized */) { |
|
if (label && !options.allowUnusedLabels) { |
|
file.bindDiagnostics.push(ts.createDiagnosticForNode(label, ts.Diagnostics.Unused_label)); |
|
} |
|
currentReachabilityState = outerState; |
|
} |
|
else { |
|
currentReachabilityState = or(innerMergedState, outerState); |
|
} |
|
} |
|
function jumpToLabel(label, outerState) { |
|
initializeReachabilityStateIfNecessary(); |
|
var index = label ? labelIndexMap[label.text] : ts.lastOrUndefined(implicitLabels); |
|
if (index === undefined) { |
|
// reference to unknown label or |
|
// break/continue used outside of loops |
|
return false; |
|
} |
|
var stateAtLabel = labelStack[index]; |
|
labelStack[index] = stateAtLabel === 1 /* Unintialized */ ? outerState : or(stateAtLabel, outerState); |
|
return true; |
|
} |
|
function checkUnreachable(node) { |
|
switch (currentReachabilityState) { |
|
case 4 /* Unreachable */: |
|
var reportError = |
|
// report error on all statements except empty ones |
|
(ts.isStatement(node) && node.kind !== 197 /* EmptyStatement */) || |
|
// report error on class declarations |
|
node.kind === 217 /* ClassDeclaration */ || |
|
// report error on instantiated modules or const-enums only modules if preserveConstEnums is set |
|
(node.kind === 221 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || |
|
// report error on regular enums and const enums if preserveConstEnums is set |
|
(node.kind === 220 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); |
|
if (reportError) { |
|
currentReachabilityState = 8 /* ReportedUnreachable */; |
|
// unreachable code is reported if |
|
// - user has explicitly asked about it AND |
|
// - statement is in not ambient context (statements in ambient context is already an error |
|
// so we should not report extras) AND |
|
// - node is not variable statement OR |
|
// - node is block scoped variable statement OR |
|
// - node is not block scoped variable statement and at least one variable declaration has initializer |
|
// Rationale: we don't want to report errors on non-initialized var's since they are hoisted |
|
// On the other side we do want to report errors on non-initialized 'lets' because of TDZ |
|
var reportUnreachableCode = !options.allowUnreachableCode && |
|
!ts.isInAmbientContext(node) && |
|
(node.kind !== 196 /* VariableStatement */ || |
|
ts.getCombinedNodeFlags(node.declarationList) & 24576 /* BlockScoped */ || |
|
ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); |
|
if (reportUnreachableCode) { |
|
errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); |
|
} |
|
} |
|
case 8 /* ReportedUnreachable */: |
|
return true; |
|
default: |
|
return false; |
|
} |
|
function shouldReportErrorOnModuleDeclaration(node) { |
|
var instanceState = getModuleInstanceState(node); |
|
return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && options.preserveConstEnums); |
|
} |
|
} |
|
function initializeReachabilityStateIfNecessary() { |
|
if (labelIndexMap) { |
|
return; |
|
} |
|
currentReachabilityState = 2 /* Reachable */; |
|
labelIndexMap = {}; |
|
labelStack = []; |
|
implicitLabels = []; |
|
} |
|
} |
|
})(ts || (ts = {})); |
|
/// <reference path="binder.ts"/> |
|
/* @internal */ |
|
var ts; |
|
(function (ts) { |
|
var nextSymbolId = 1; |
|
var nextNodeId = 1; |
|
var nextMergeId = 1; |
|
function getNodeId(node) { |
|
if (!node.id) { |
|
node.id = nextNodeId; |
|
nextNodeId++; |
|
} |
|
return node.id; |
|
} |
|
ts.getNodeId = getNodeId; |
|
ts.checkTime = 0; |
|
function getSymbolId(symbol) { |
|
if (!symbol.id) { |
|
symbol.id = nextSymbolId; |
|
nextSymbolId++; |
|
} |
|
return symbol.id; |
|
} |
|
ts.getSymbolId = getSymbolId; |
|
function createTypeChecker(host, produceDiagnostics) { |
|
// Cancellation that controls whether or not we can cancel in the middle of type checking. |
|
// In general cancelling is *not* safe for the type checker. We might be in the middle of |
|
// computing something, and we will leave our internals in an inconsistent state. Callers |
|
// who set the cancellation token should catch if a cancellation exception occurs, and |
|
// should throw away and create a new TypeChecker. |
|
// |
|
// Currently we only support setting the cancellation token when getting diagnostics. This |
|
// is because diagnostics can be quite expensive, and we want to allow hosts to bail out if |
|
// they no longer need the information (for example, if the user started editing again). |
|
var cancellationToken; |
|
var Symbol = ts.objectAllocator.getSymbolConstructor(); |
|
var Type = ts.objectAllocator.getTypeConstructor(); |
|
var Signature = ts.objectAllocator.getSignatureConstructor(); |
|
var typeCount = 0; |
|
var symbolCount = 0; |
|
var emptyArray = []; |
|
var emptySymbols = {}; |
|
var compilerOptions = host.getCompilerOptions(); |
|
var languageVersion = compilerOptions.target || 0 /* ES3 */; |
|
var modulekind = ts.getEmitModuleKind(compilerOptions); |
|
var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === 4 /* System */; |
|
var emitResolver = createResolver(); |
|
var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); |
|
undefinedSymbol.declarations = []; |
|
var argumentsSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "arguments"); |
|
var checker = { |
|
getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, |
|
getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, |
|
getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, |
|
getTypeCount: function () { return typeCount; }, |
|
isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, |
|
isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, |
|
isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; }, |
|
getDiagnostics: getDiagnostics, |
|
getGlobalDiagnostics: getGlobalDiagnostics, |
|
// The language service will always care about the narrowed type of a symbol, because that is |
|
// the type the language says the symbol should have. |
|
getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, |
|
getSymbolsOfParameterPropertyDeclaration: getSymbolsOfParameterPropertyDeclaration, |
|
getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, |
|
getPropertiesOfType: getPropertiesOfType, |
|
getPropertyOfType: getPropertyOfType, |
|
getSignaturesOfType: getSignaturesOfType, |
|
getIndexTypeOfType: getIndexTypeOfType, |
|
getBaseTypes: getBaseTypes, |
|
getReturnTypeOfSignature: getReturnTypeOfSignature, |
|
getSymbolsInScope: getSymbolsInScope, |
|
getSymbolAtLocation: getSymbolAtLocation, |
|
getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, |
|
getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, |
|
getTypeAtLocation: getTypeOfNode, |
|
typeToString: typeToString, |
|
getSymbolDisplayBuilder: getSymbolDisplayBuilder, |
|
symbolToString: symbolToString, |
|
getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, |
|
getRootSymbols: getRootSymbols, |
|
getContextualType: getContextualType, |
|
getFullyQualifiedName: getFullyQualifiedName, |
|
getResolvedSignature: getResolvedSignature, |
|
getConstantValue: getConstantValue, |
|
isValidPropertyAccess: isValidPropertyAccess, |
|
getSignatureFromDeclaration: getSignatureFromDeclaration, |
|
isImplementationOfOverload: isImplementationOfOverload, |
|
getAliasedSymbol: resolveAlias, |
|
getEmitResolver: getEmitResolver, |
|
getExportsOfModule: getExportsOfModuleAsArray, |
|
getJsxElementAttributesType: getJsxElementAttributesType, |
|
getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, |
|
isOptionalParameter: isOptionalParameter |
|
}; |
|
var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); |
|
var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); |
|
var anyType = createIntrinsicType(1 /* Any */, "any"); |
|
var stringType = createIntrinsicType(2 /* String */, "string"); |
|
var numberType = createIntrinsicType(4 /* Number */, "number"); |
|
var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); |
|
var esSymbolType = createIntrinsicType(16777216 /* ESSymbol */, "symbol"); |
|
var voidType = createIntrinsicType(16 /* Void */, "void"); |
|
var undefinedType = createIntrinsicType(32 /* Undefined */ | 2097152 /* ContainsUndefinedOrNull */, "undefined"); |
|
var nullType = createIntrinsicType(64 /* Null */ | 2097152 /* ContainsUndefinedOrNull */, "null"); |
|
var unknownType = createIntrinsicType(1 /* Any */, "unknown"); |
|
var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); |
|
var emptyUnionType = emptyObjectType; |
|
var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); |
|
emptyGenericType.instantiations = {}; |
|
var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); |
|
// The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated |
|
// in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. |
|
anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; |
|
var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); |
|
var anySignature = createSignature(undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); |
|
var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); |
|
var globals = {}; |
|
var globalESSymbolConstructorSymbol; |
|
var getGlobalPromiseConstructorSymbol; |
|
var globalObjectType; |
|
var globalFunctionType; |
|
var globalArrayType; |
|
var globalStringType; |
|
var globalNumberType; |
|
var globalBooleanType; |
|
var globalRegExpType; |
|
var globalTemplateStringsArrayType; |
|
var globalESSymbolType; |
|
var globalIterableType; |
|
var globalIteratorType; |
|
var globalIterableIteratorType; |
|
var anyArrayType; |
|
var getGlobalClassDecoratorType; |
|
var getGlobalParameterDecoratorType; |
|
var getGlobalPropertyDecoratorType; |
|
var getGlobalMethodDecoratorType; |
|
var getGlobalTypedPropertyDescriptorType; |
|
var getGlobalPromiseType; |
|
var tryGetGlobalPromiseType; |
|
var getGlobalPromiseLikeType; |
|
var getInstantiatedGlobalPromiseLikeType; |
|
var getGlobalPromiseConstructorLikeType; |
|
var getGlobalThenableType; |
|
var jsxElementClassType; |
|
var deferredNodes; |
|
var tupleTypes = {}; |
|
var unionTypes = {}; |
|
var intersectionTypes = {}; |
|
var stringLiteralTypes = {}; |
|
var resolutionTargets = []; |
|
var resolutionResults = []; |
|
var resolutionPropertyNames = []; |
|
var mergedSymbols = []; |
|
var symbolLinks = []; |
|
var nodeLinks = []; |
|
var potentialThisCollisions = []; |
|
var awaitedTypeStack = []; |
|
var diagnostics = ts.createDiagnosticCollection(); |
|
var primitiveTypeInfo = { |
|
"string": { |
|
type: stringType, |
|
flags: 258 /* StringLike */ |
|
}, |
|
"number": { |
|
type: numberType, |
|
flags: 132 /* NumberLike */ |
|
}, |
|
"boolean": { |
|
type: booleanType, |
|
flags: 8 /* Boolean */ |
|
}, |
|
"symbol": { |
|
type: esSymbolType, |
|
flags: 16777216 /* ESSymbol */ |
|
}, |
|
"undefined": { |
|
type: undefinedType, |
|
flags: 2097152 /* ContainsUndefinedOrNull */ |
|
} |
|
}; |
|
var jsxElementType; |
|
/** Things we lazy load from the JSX namespace */ |
|
var jsxTypes = {}; |
|
var JsxNames = { |
|
JSX: "JSX", |
|
IntrinsicElements: "IntrinsicElements", |
|
ElementClass: "ElementClass", |
|
ElementAttributesPropertyNameContainer: "ElementAttributesProperty", |
|
Element: "Element", |
|
IntrinsicAttributes: "IntrinsicAttributes", |
|
IntrinsicClassAttributes: "IntrinsicClassAttributes" |
|
}; |
|
var subtypeRelation = {}; |
|
var assignableRelation = {}; |
|
var identityRelation = {}; |
|
// This is for caching the result of getSymbolDisplayBuilder. Do not access directly. |
|
var _displayBuilder; |
|
var TypeSystemPropertyName; |
|
(function (TypeSystemPropertyName) { |
|
TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; |
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; |
|
TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; |
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; |
|
})(TypeSystemPropertyName || (TypeSystemPropertyName = {})); |
|
var builtinGlobals = (_a = {}, |