diff --git a/tools/typescript.js b/tools/typescript.js
index ac27b61ba..1b65cf9af 100644
--- a/tools/typescript.js
+++ b/tools/typescript.js
@@ -1,4 +1,5 @@
-// typescript v1.6.2
+//typescript 1.7.3
+
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -63,279 +64,281 @@ var ts;
SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken";
SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken";
SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken";
- SyntaxKind[SyntaxKind["SlashToken"] = 38] = "SlashToken";
- SyntaxKind[SyntaxKind["PercentToken"] = 39] = "PercentToken";
- SyntaxKind[SyntaxKind["PlusPlusToken"] = 40] = "PlusPlusToken";
- SyntaxKind[SyntaxKind["MinusMinusToken"] = 41] = "MinusMinusToken";
- SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 42] = "LessThanLessThanToken";
- SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanToken";
- SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanGreaterThanToken";
- SyntaxKind[SyntaxKind["AmpersandToken"] = 45] = "AmpersandToken";
- SyntaxKind[SyntaxKind["BarToken"] = 46] = "BarToken";
- SyntaxKind[SyntaxKind["CaretToken"] = 47] = "CaretToken";
- SyntaxKind[SyntaxKind["ExclamationToken"] = 48] = "ExclamationToken";
- SyntaxKind[SyntaxKind["TildeToken"] = 49] = "TildeToken";
- SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 50] = "AmpersandAmpersandToken";
- SyntaxKind[SyntaxKind["BarBarToken"] = 51] = "BarBarToken";
- SyntaxKind[SyntaxKind["QuestionToken"] = 52] = "QuestionToken";
- SyntaxKind[SyntaxKind["ColonToken"] = 53] = "ColonToken";
- SyntaxKind[SyntaxKind["AtToken"] = 54] = "AtToken";
+ 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"] = 55] = "EqualsToken";
- SyntaxKind[SyntaxKind["PlusEqualsToken"] = 56] = "PlusEqualsToken";
- SyntaxKind[SyntaxKind["MinusEqualsToken"] = 57] = "MinusEqualsToken";
- SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 58] = "AsteriskEqualsToken";
- SyntaxKind[SyntaxKind["SlashEqualsToken"] = 59] = "SlashEqualsToken";
- SyntaxKind[SyntaxKind["PercentEqualsToken"] = 60] = "PercentEqualsToken";
- SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 61] = "LessThanLessThanEqualsToken";
- SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanEqualsToken";
- SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 63] = "GreaterThanGreaterThanGreaterThanEqualsToken";
- SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 64] = "AmpersandEqualsToken";
- SyntaxKind[SyntaxKind["BarEqualsToken"] = 65] = "BarEqualsToken";
- SyntaxKind[SyntaxKind["CaretEqualsToken"] = 66] = "CaretEqualsToken";
+ 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"] = 67] = "Identifier";
+ SyntaxKind[SyntaxKind["Identifier"] = 69] = "Identifier";
// Reserved words
- SyntaxKind[SyntaxKind["BreakKeyword"] = 68] = "BreakKeyword";
- SyntaxKind[SyntaxKind["CaseKeyword"] = 69] = "CaseKeyword";
- SyntaxKind[SyntaxKind["CatchKeyword"] = 70] = "CatchKeyword";
- SyntaxKind[SyntaxKind["ClassKeyword"] = 71] = "ClassKeyword";
- SyntaxKind[SyntaxKind["ConstKeyword"] = 72] = "ConstKeyword";
- SyntaxKind[SyntaxKind["ContinueKeyword"] = 73] = "ContinueKeyword";
- SyntaxKind[SyntaxKind["DebuggerKeyword"] = 74] = "DebuggerKeyword";
- SyntaxKind[SyntaxKind["DefaultKeyword"] = 75] = "DefaultKeyword";
- SyntaxKind[SyntaxKind["DeleteKeyword"] = 76] = "DeleteKeyword";
- SyntaxKind[SyntaxKind["DoKeyword"] = 77] = "DoKeyword";
- SyntaxKind[SyntaxKind["ElseKeyword"] = 78] = "ElseKeyword";
- SyntaxKind[SyntaxKind["EnumKeyword"] = 79] = "EnumKeyword";
- SyntaxKind[SyntaxKind["ExportKeyword"] = 80] = "ExportKeyword";
- SyntaxKind[SyntaxKind["ExtendsKeyword"] = 81] = "ExtendsKeyword";
- SyntaxKind[SyntaxKind["FalseKeyword"] = 82] = "FalseKeyword";
- SyntaxKind[SyntaxKind["FinallyKeyword"] = 83] = "FinallyKeyword";
- SyntaxKind[SyntaxKind["ForKeyword"] = 84] = "ForKeyword";
- SyntaxKind[SyntaxKind["FunctionKeyword"] = 85] = "FunctionKeyword";
- SyntaxKind[SyntaxKind["IfKeyword"] = 86] = "IfKeyword";
- SyntaxKind[SyntaxKind["ImportKeyword"] = 87] = "ImportKeyword";
- SyntaxKind[SyntaxKind["InKeyword"] = 88] = "InKeyword";
- SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 89] = "InstanceOfKeyword";
- SyntaxKind[SyntaxKind["NewKeyword"] = 90] = "NewKeyword";
- SyntaxKind[SyntaxKind["NullKeyword"] = 91] = "NullKeyword";
- SyntaxKind[SyntaxKind["ReturnKeyword"] = 92] = "ReturnKeyword";
- SyntaxKind[SyntaxKind["SuperKeyword"] = 93] = "SuperKeyword";
- SyntaxKind[SyntaxKind["SwitchKeyword"] = 94] = "SwitchKeyword";
- SyntaxKind[SyntaxKind["ThisKeyword"] = 95] = "ThisKeyword";
- SyntaxKind[SyntaxKind["ThrowKeyword"] = 96] = "ThrowKeyword";
- SyntaxKind[SyntaxKind["TrueKeyword"] = 97] = "TrueKeyword";
- SyntaxKind[SyntaxKind["TryKeyword"] = 98] = "TryKeyword";
- SyntaxKind[SyntaxKind["TypeOfKeyword"] = 99] = "TypeOfKeyword";
- SyntaxKind[SyntaxKind["VarKeyword"] = 100] = "VarKeyword";
- SyntaxKind[SyntaxKind["VoidKeyword"] = 101] = "VoidKeyword";
- SyntaxKind[SyntaxKind["WhileKeyword"] = 102] = "WhileKeyword";
- SyntaxKind[SyntaxKind["WithKeyword"] = 103] = "WithKeyword";
+ 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"] = 104] = "ImplementsKeyword";
- SyntaxKind[SyntaxKind["InterfaceKeyword"] = 105] = "InterfaceKeyword";
- SyntaxKind[SyntaxKind["LetKeyword"] = 106] = "LetKeyword";
- SyntaxKind[SyntaxKind["PackageKeyword"] = 107] = "PackageKeyword";
- SyntaxKind[SyntaxKind["PrivateKeyword"] = 108] = "PrivateKeyword";
- SyntaxKind[SyntaxKind["ProtectedKeyword"] = 109] = "ProtectedKeyword";
- SyntaxKind[SyntaxKind["PublicKeyword"] = 110] = "PublicKeyword";
- SyntaxKind[SyntaxKind["StaticKeyword"] = 111] = "StaticKeyword";
- SyntaxKind[SyntaxKind["YieldKeyword"] = 112] = "YieldKeyword";
+ 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"] = 113] = "AbstractKeyword";
- SyntaxKind[SyntaxKind["AsKeyword"] = 114] = "AsKeyword";
- SyntaxKind[SyntaxKind["AnyKeyword"] = 115] = "AnyKeyword";
- SyntaxKind[SyntaxKind["AsyncKeyword"] = 116] = "AsyncKeyword";
- SyntaxKind[SyntaxKind["AwaitKeyword"] = 117] = "AwaitKeyword";
- SyntaxKind[SyntaxKind["BooleanKeyword"] = 118] = "BooleanKeyword";
- SyntaxKind[SyntaxKind["ConstructorKeyword"] = 119] = "ConstructorKeyword";
- SyntaxKind[SyntaxKind["DeclareKeyword"] = 120] = "DeclareKeyword";
- SyntaxKind[SyntaxKind["GetKeyword"] = 121] = "GetKeyword";
- SyntaxKind[SyntaxKind["IsKeyword"] = 122] = "IsKeyword";
- SyntaxKind[SyntaxKind["ModuleKeyword"] = 123] = "ModuleKeyword";
- SyntaxKind[SyntaxKind["NamespaceKeyword"] = 124] = "NamespaceKeyword";
- SyntaxKind[SyntaxKind["RequireKeyword"] = 125] = "RequireKeyword";
- SyntaxKind[SyntaxKind["NumberKeyword"] = 126] = "NumberKeyword";
- SyntaxKind[SyntaxKind["SetKeyword"] = 127] = "SetKeyword";
- SyntaxKind[SyntaxKind["StringKeyword"] = 128] = "StringKeyword";
- SyntaxKind[SyntaxKind["SymbolKeyword"] = 129] = "SymbolKeyword";
- SyntaxKind[SyntaxKind["TypeKeyword"] = 130] = "TypeKeyword";
- SyntaxKind[SyntaxKind["FromKeyword"] = 131] = "FromKeyword";
- SyntaxKind[SyntaxKind["OfKeyword"] = 132] = "OfKeyword";
+ 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["OfKeyword"] = 134] = "OfKeyword";
// Parse tree nodes
// Names
- SyntaxKind[SyntaxKind["QualifiedName"] = 133] = "QualifiedName";
- SyntaxKind[SyntaxKind["ComputedPropertyName"] = 134] = "ComputedPropertyName";
+ SyntaxKind[SyntaxKind["QualifiedName"] = 135] = "QualifiedName";
+ SyntaxKind[SyntaxKind["ComputedPropertyName"] = 136] = "ComputedPropertyName";
// Signature elements
- SyntaxKind[SyntaxKind["TypeParameter"] = 135] = "TypeParameter";
- SyntaxKind[SyntaxKind["Parameter"] = 136] = "Parameter";
- SyntaxKind[SyntaxKind["Decorator"] = 137] = "Decorator";
+ SyntaxKind[SyntaxKind["TypeParameter"] = 137] = "TypeParameter";
+ SyntaxKind[SyntaxKind["Parameter"] = 138] = "Parameter";
+ SyntaxKind[SyntaxKind["Decorator"] = 139] = "Decorator";
// TypeMember
- SyntaxKind[SyntaxKind["PropertySignature"] = 138] = "PropertySignature";
- SyntaxKind[SyntaxKind["PropertyDeclaration"] = 139] = "PropertyDeclaration";
- SyntaxKind[SyntaxKind["MethodSignature"] = 140] = "MethodSignature";
- SyntaxKind[SyntaxKind["MethodDeclaration"] = 141] = "MethodDeclaration";
- SyntaxKind[SyntaxKind["Constructor"] = 142] = "Constructor";
- SyntaxKind[SyntaxKind["GetAccessor"] = 143] = "GetAccessor";
- SyntaxKind[SyntaxKind["SetAccessor"] = 144] = "SetAccessor";
- SyntaxKind[SyntaxKind["CallSignature"] = 145] = "CallSignature";
- SyntaxKind[SyntaxKind["ConstructSignature"] = 146] = "ConstructSignature";
- SyntaxKind[SyntaxKind["IndexSignature"] = 147] = "IndexSignature";
+ SyntaxKind[SyntaxKind["PropertySignature"] = 140] = "PropertySignature";
+ SyntaxKind[SyntaxKind["PropertyDeclaration"] = 141] = "PropertyDeclaration";
+ SyntaxKind[SyntaxKind["MethodSignature"] = 142] = "MethodSignature";
+ SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration";
+ SyntaxKind[SyntaxKind["Constructor"] = 144] = "Constructor";
+ SyntaxKind[SyntaxKind["GetAccessor"] = 145] = "GetAccessor";
+ SyntaxKind[SyntaxKind["SetAccessor"] = 146] = "SetAccessor";
+ SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature";
+ SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature";
+ SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature";
// Type
- SyntaxKind[SyntaxKind["TypePredicate"] = 148] = "TypePredicate";
- SyntaxKind[SyntaxKind["TypeReference"] = 149] = "TypeReference";
- SyntaxKind[SyntaxKind["FunctionType"] = 150] = "FunctionType";
- SyntaxKind[SyntaxKind["ConstructorType"] = 151] = "ConstructorType";
- SyntaxKind[SyntaxKind["TypeQuery"] = 152] = "TypeQuery";
- SyntaxKind[SyntaxKind["TypeLiteral"] = 153] = "TypeLiteral";
- SyntaxKind[SyntaxKind["ArrayType"] = 154] = "ArrayType";
- SyntaxKind[SyntaxKind["TupleType"] = 155] = "TupleType";
- SyntaxKind[SyntaxKind["UnionType"] = 156] = "UnionType";
- SyntaxKind[SyntaxKind["IntersectionType"] = 157] = "IntersectionType";
- SyntaxKind[SyntaxKind["ParenthesizedType"] = 158] = "ParenthesizedType";
+ SyntaxKind[SyntaxKind["TypePredicate"] = 150] = "TypePredicate";
+ SyntaxKind[SyntaxKind["TypeReference"] = 151] = "TypeReference";
+ SyntaxKind[SyntaxKind["FunctionType"] = 152] = "FunctionType";
+ SyntaxKind[SyntaxKind["ConstructorType"] = 153] = "ConstructorType";
+ SyntaxKind[SyntaxKind["TypeQuery"] = 154] = "TypeQuery";
+ SyntaxKind[SyntaxKind["TypeLiteral"] = 155] = "TypeLiteral";
+ SyntaxKind[SyntaxKind["ArrayType"] = 156] = "ArrayType";
+ SyntaxKind[SyntaxKind["TupleType"] = 157] = "TupleType";
+ SyntaxKind[SyntaxKind["UnionType"] = 158] = "UnionType";
+ SyntaxKind[SyntaxKind["IntersectionType"] = 159] = "IntersectionType";
+ SyntaxKind[SyntaxKind["ParenthesizedType"] = 160] = "ParenthesizedType";
// Binding patterns
- SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 159] = "ObjectBindingPattern";
- SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 160] = "ArrayBindingPattern";
- SyntaxKind[SyntaxKind["BindingElement"] = 161] = "BindingElement";
+ SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 161] = "ObjectBindingPattern";
+ SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 162] = "ArrayBindingPattern";
+ SyntaxKind[SyntaxKind["BindingElement"] = 163] = "BindingElement";
// Expression
- SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 162] = "ArrayLiteralExpression";
- SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 163] = "ObjectLiteralExpression";
- SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 164] = "PropertyAccessExpression";
- SyntaxKind[SyntaxKind["ElementAccessExpression"] = 165] = "ElementAccessExpression";
- SyntaxKind[SyntaxKind["CallExpression"] = 166] = "CallExpression";
- SyntaxKind[SyntaxKind["NewExpression"] = 167] = "NewExpression";
- SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 168] = "TaggedTemplateExpression";
- SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 169] = "TypeAssertionExpression";
- SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 170] = "ParenthesizedExpression";
- SyntaxKind[SyntaxKind["FunctionExpression"] = 171] = "FunctionExpression";
- SyntaxKind[SyntaxKind["ArrowFunction"] = 172] = "ArrowFunction";
- SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression";
- SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression";
- SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression";
- SyntaxKind[SyntaxKind["AwaitExpression"] = 176] = "AwaitExpression";
- SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 177] = "PrefixUnaryExpression";
- SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression";
- SyntaxKind[SyntaxKind["BinaryExpression"] = 179] = "BinaryExpression";
- SyntaxKind[SyntaxKind["ConditionalExpression"] = 180] = "ConditionalExpression";
- SyntaxKind[SyntaxKind["TemplateExpression"] = 181] = "TemplateExpression";
- SyntaxKind[SyntaxKind["YieldExpression"] = 182] = "YieldExpression";
- SyntaxKind[SyntaxKind["SpreadElementExpression"] = 183] = "SpreadElementExpression";
- SyntaxKind[SyntaxKind["ClassExpression"] = 184] = "ClassExpression";
- SyntaxKind[SyntaxKind["OmittedExpression"] = 185] = "OmittedExpression";
- SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 186] = "ExpressionWithTypeArguments";
- SyntaxKind[SyntaxKind["AsExpression"] = 187] = "AsExpression";
+ SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 164] = "ArrayLiteralExpression";
+ SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 165] = "ObjectLiteralExpression";
+ SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 166] = "PropertyAccessExpression";
+ SyntaxKind[SyntaxKind["ElementAccessExpression"] = 167] = "ElementAccessExpression";
+ SyntaxKind[SyntaxKind["CallExpression"] = 168] = "CallExpression";
+ SyntaxKind[SyntaxKind["NewExpression"] = 169] = "NewExpression";
+ SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 170] = "TaggedTemplateExpression";
+ SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 171] = "TypeAssertionExpression";
+ SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 172] = "ParenthesizedExpression";
+ SyntaxKind[SyntaxKind["FunctionExpression"] = 173] = "FunctionExpression";
+ SyntaxKind[SyntaxKind["ArrowFunction"] = 174] = "ArrowFunction";
+ SyntaxKind[SyntaxKind["DeleteExpression"] = 175] = "DeleteExpression";
+ SyntaxKind[SyntaxKind["TypeOfExpression"] = 176] = "TypeOfExpression";
+ SyntaxKind[SyntaxKind["VoidExpression"] = 177] = "VoidExpression";
+ SyntaxKind[SyntaxKind["AwaitExpression"] = 178] = "AwaitExpression";
+ SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 179] = "PrefixUnaryExpression";
+ SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 180] = "PostfixUnaryExpression";
+ SyntaxKind[SyntaxKind["BinaryExpression"] = 181] = "BinaryExpression";
+ SyntaxKind[SyntaxKind["ConditionalExpression"] = 182] = "ConditionalExpression";
+ SyntaxKind[SyntaxKind["TemplateExpression"] = 183] = "TemplateExpression";
+ SyntaxKind[SyntaxKind["YieldExpression"] = 184] = "YieldExpression";
+ SyntaxKind[SyntaxKind["SpreadElementExpression"] = 185] = "SpreadElementExpression";
+ SyntaxKind[SyntaxKind["ClassExpression"] = 186] = "ClassExpression";
+ SyntaxKind[SyntaxKind["OmittedExpression"] = 187] = "OmittedExpression";
+ SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 188] = "ExpressionWithTypeArguments";
+ SyntaxKind[SyntaxKind["AsExpression"] = 189] = "AsExpression";
// Misc
- SyntaxKind[SyntaxKind["TemplateSpan"] = 188] = "TemplateSpan";
- SyntaxKind[SyntaxKind["SemicolonClassElement"] = 189] = "SemicolonClassElement";
+ SyntaxKind[SyntaxKind["TemplateSpan"] = 190] = "TemplateSpan";
+ SyntaxKind[SyntaxKind["SemicolonClassElement"] = 191] = "SemicolonClassElement";
// Element
- SyntaxKind[SyntaxKind["Block"] = 190] = "Block";
- SyntaxKind[SyntaxKind["VariableStatement"] = 191] = "VariableStatement";
- SyntaxKind[SyntaxKind["EmptyStatement"] = 192] = "EmptyStatement";
- SyntaxKind[SyntaxKind["ExpressionStatement"] = 193] = "ExpressionStatement";
- SyntaxKind[SyntaxKind["IfStatement"] = 194] = "IfStatement";
- SyntaxKind[SyntaxKind["DoStatement"] = 195] = "DoStatement";
- SyntaxKind[SyntaxKind["WhileStatement"] = 196] = "WhileStatement";
- SyntaxKind[SyntaxKind["ForStatement"] = 197] = "ForStatement";
- SyntaxKind[SyntaxKind["ForInStatement"] = 198] = "ForInStatement";
- SyntaxKind[SyntaxKind["ForOfStatement"] = 199] = "ForOfStatement";
- SyntaxKind[SyntaxKind["ContinueStatement"] = 200] = "ContinueStatement";
- SyntaxKind[SyntaxKind["BreakStatement"] = 201] = "BreakStatement";
- SyntaxKind[SyntaxKind["ReturnStatement"] = 202] = "ReturnStatement";
- SyntaxKind[SyntaxKind["WithStatement"] = 203] = "WithStatement";
- SyntaxKind[SyntaxKind["SwitchStatement"] = 204] = "SwitchStatement";
- SyntaxKind[SyntaxKind["LabeledStatement"] = 205] = "LabeledStatement";
- SyntaxKind[SyntaxKind["ThrowStatement"] = 206] = "ThrowStatement";
- SyntaxKind[SyntaxKind["TryStatement"] = 207] = "TryStatement";
- SyntaxKind[SyntaxKind["DebuggerStatement"] = 208] = "DebuggerStatement";
- SyntaxKind[SyntaxKind["VariableDeclaration"] = 209] = "VariableDeclaration";
- SyntaxKind[SyntaxKind["VariableDeclarationList"] = 210] = "VariableDeclarationList";
- SyntaxKind[SyntaxKind["FunctionDeclaration"] = 211] = "FunctionDeclaration";
- SyntaxKind[SyntaxKind["ClassDeclaration"] = 212] = "ClassDeclaration";
- SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 213] = "InterfaceDeclaration";
- SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 214] = "TypeAliasDeclaration";
- SyntaxKind[SyntaxKind["EnumDeclaration"] = 215] = "EnumDeclaration";
- SyntaxKind[SyntaxKind["ModuleDeclaration"] = 216] = "ModuleDeclaration";
- SyntaxKind[SyntaxKind["ModuleBlock"] = 217] = "ModuleBlock";
- SyntaxKind[SyntaxKind["CaseBlock"] = 218] = "CaseBlock";
- SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 219] = "ImportEqualsDeclaration";
- SyntaxKind[SyntaxKind["ImportDeclaration"] = 220] = "ImportDeclaration";
- SyntaxKind[SyntaxKind["ImportClause"] = 221] = "ImportClause";
- SyntaxKind[SyntaxKind["NamespaceImport"] = 222] = "NamespaceImport";
- SyntaxKind[SyntaxKind["NamedImports"] = 223] = "NamedImports";
- SyntaxKind[SyntaxKind["ImportSpecifier"] = 224] = "ImportSpecifier";
- SyntaxKind[SyntaxKind["ExportAssignment"] = 225] = "ExportAssignment";
- SyntaxKind[SyntaxKind["ExportDeclaration"] = 226] = "ExportDeclaration";
- SyntaxKind[SyntaxKind["NamedExports"] = 227] = "NamedExports";
- SyntaxKind[SyntaxKind["ExportSpecifier"] = 228] = "ExportSpecifier";
- SyntaxKind[SyntaxKind["MissingDeclaration"] = 229] = "MissingDeclaration";
+ SyntaxKind[SyntaxKind["Block"] = 192] = "Block";
+ SyntaxKind[SyntaxKind["VariableStatement"] = 193] = "VariableStatement";
+ SyntaxKind[SyntaxKind["EmptyStatement"] = 194] = "EmptyStatement";
+ SyntaxKind[SyntaxKind["ExpressionStatement"] = 195] = "ExpressionStatement";
+ SyntaxKind[SyntaxKind["IfStatement"] = 196] = "IfStatement";
+ SyntaxKind[SyntaxKind["DoStatement"] = 197] = "DoStatement";
+ SyntaxKind[SyntaxKind["WhileStatement"] = 198] = "WhileStatement";
+ SyntaxKind[SyntaxKind["ForStatement"] = 199] = "ForStatement";
+ SyntaxKind[SyntaxKind["ForInStatement"] = 200] = "ForInStatement";
+ SyntaxKind[SyntaxKind["ForOfStatement"] = 201] = "ForOfStatement";
+ SyntaxKind[SyntaxKind["ContinueStatement"] = 202] = "ContinueStatement";
+ SyntaxKind[SyntaxKind["BreakStatement"] = 203] = "BreakStatement";
+ SyntaxKind[SyntaxKind["ReturnStatement"] = 204] = "ReturnStatement";
+ SyntaxKind[SyntaxKind["WithStatement"] = 205] = "WithStatement";
+ SyntaxKind[SyntaxKind["SwitchStatement"] = 206] = "SwitchStatement";
+ SyntaxKind[SyntaxKind["LabeledStatement"] = 207] = "LabeledStatement";
+ SyntaxKind[SyntaxKind["ThrowStatement"] = 208] = "ThrowStatement";
+ SyntaxKind[SyntaxKind["TryStatement"] = 209] = "TryStatement";
+ SyntaxKind[SyntaxKind["DebuggerStatement"] = 210] = "DebuggerStatement";
+ SyntaxKind[SyntaxKind["VariableDeclaration"] = 211] = "VariableDeclaration";
+ SyntaxKind[SyntaxKind["VariableDeclarationList"] = 212] = "VariableDeclarationList";
+ SyntaxKind[SyntaxKind["FunctionDeclaration"] = 213] = "FunctionDeclaration";
+ SyntaxKind[SyntaxKind["ClassDeclaration"] = 214] = "ClassDeclaration";
+ SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 215] = "InterfaceDeclaration";
+ SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 216] = "TypeAliasDeclaration";
+ SyntaxKind[SyntaxKind["EnumDeclaration"] = 217] = "EnumDeclaration";
+ SyntaxKind[SyntaxKind["ModuleDeclaration"] = 218] = "ModuleDeclaration";
+ SyntaxKind[SyntaxKind["ModuleBlock"] = 219] = "ModuleBlock";
+ SyntaxKind[SyntaxKind["CaseBlock"] = 220] = "CaseBlock";
+ SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 221] = "ImportEqualsDeclaration";
+ SyntaxKind[SyntaxKind["ImportDeclaration"] = 222] = "ImportDeclaration";
+ SyntaxKind[SyntaxKind["ImportClause"] = 223] = "ImportClause";
+ SyntaxKind[SyntaxKind["NamespaceImport"] = 224] = "NamespaceImport";
+ SyntaxKind[SyntaxKind["NamedImports"] = 225] = "NamedImports";
+ SyntaxKind[SyntaxKind["ImportSpecifier"] = 226] = "ImportSpecifier";
+ SyntaxKind[SyntaxKind["ExportAssignment"] = 227] = "ExportAssignment";
+ SyntaxKind[SyntaxKind["ExportDeclaration"] = 228] = "ExportDeclaration";
+ SyntaxKind[SyntaxKind["NamedExports"] = 229] = "NamedExports";
+ SyntaxKind[SyntaxKind["ExportSpecifier"] = 230] = "ExportSpecifier";
+ SyntaxKind[SyntaxKind["MissingDeclaration"] = 231] = "MissingDeclaration";
// Module references
- SyntaxKind[SyntaxKind["ExternalModuleReference"] = 230] = "ExternalModuleReference";
+ SyntaxKind[SyntaxKind["ExternalModuleReference"] = 232] = "ExternalModuleReference";
// JSX
- SyntaxKind[SyntaxKind["JsxElement"] = 231] = "JsxElement";
- SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 232] = "JsxSelfClosingElement";
- SyntaxKind[SyntaxKind["JsxOpeningElement"] = 233] = "JsxOpeningElement";
- SyntaxKind[SyntaxKind["JsxText"] = 234] = "JsxText";
- SyntaxKind[SyntaxKind["JsxClosingElement"] = 235] = "JsxClosingElement";
- SyntaxKind[SyntaxKind["JsxAttribute"] = 236] = "JsxAttribute";
- SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 237] = "JsxSpreadAttribute";
- SyntaxKind[SyntaxKind["JsxExpression"] = 238] = "JsxExpression";
+ SyntaxKind[SyntaxKind["JsxElement"] = 233] = "JsxElement";
+ SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 234] = "JsxSelfClosingElement";
+ SyntaxKind[SyntaxKind["JsxOpeningElement"] = 235] = "JsxOpeningElement";
+ SyntaxKind[SyntaxKind["JsxText"] = 236] = "JsxText";
+ SyntaxKind[SyntaxKind["JsxClosingElement"] = 237] = "JsxClosingElement";
+ SyntaxKind[SyntaxKind["JsxAttribute"] = 238] = "JsxAttribute";
+ SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 239] = "JsxSpreadAttribute";
+ SyntaxKind[SyntaxKind["JsxExpression"] = 240] = "JsxExpression";
// Clauses
- SyntaxKind[SyntaxKind["CaseClause"] = 239] = "CaseClause";
- SyntaxKind[SyntaxKind["DefaultClause"] = 240] = "DefaultClause";
- SyntaxKind[SyntaxKind["HeritageClause"] = 241] = "HeritageClause";
- SyntaxKind[SyntaxKind["CatchClause"] = 242] = "CatchClause";
+ SyntaxKind[SyntaxKind["CaseClause"] = 241] = "CaseClause";
+ SyntaxKind[SyntaxKind["DefaultClause"] = 242] = "DefaultClause";
+ SyntaxKind[SyntaxKind["HeritageClause"] = 243] = "HeritageClause";
+ SyntaxKind[SyntaxKind["CatchClause"] = 244] = "CatchClause";
// Property assignments
- SyntaxKind[SyntaxKind["PropertyAssignment"] = 243] = "PropertyAssignment";
- SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 244] = "ShorthandPropertyAssignment";
+ SyntaxKind[SyntaxKind["PropertyAssignment"] = 245] = "PropertyAssignment";
+ SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 246] = "ShorthandPropertyAssignment";
// Enum
- SyntaxKind[SyntaxKind["EnumMember"] = 245] = "EnumMember";
+ SyntaxKind[SyntaxKind["EnumMember"] = 247] = "EnumMember";
// Top-level nodes
- SyntaxKind[SyntaxKind["SourceFile"] = 246] = "SourceFile";
+ SyntaxKind[SyntaxKind["SourceFile"] = 248] = "SourceFile";
// JSDoc nodes.
- SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 247] = "JSDocTypeExpression";
+ SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 249] = "JSDocTypeExpression";
// The * type.
- SyntaxKind[SyntaxKind["JSDocAllType"] = 248] = "JSDocAllType";
+ SyntaxKind[SyntaxKind["JSDocAllType"] = 250] = "JSDocAllType";
// The ? type.
- SyntaxKind[SyntaxKind["JSDocUnknownType"] = 249] = "JSDocUnknownType";
- SyntaxKind[SyntaxKind["JSDocArrayType"] = 250] = "JSDocArrayType";
- SyntaxKind[SyntaxKind["JSDocUnionType"] = 251] = "JSDocUnionType";
- SyntaxKind[SyntaxKind["JSDocTupleType"] = 252] = "JSDocTupleType";
- SyntaxKind[SyntaxKind["JSDocNullableType"] = 253] = "JSDocNullableType";
- SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 254] = "JSDocNonNullableType";
- SyntaxKind[SyntaxKind["JSDocRecordType"] = 255] = "JSDocRecordType";
- SyntaxKind[SyntaxKind["JSDocRecordMember"] = 256] = "JSDocRecordMember";
- SyntaxKind[SyntaxKind["JSDocTypeReference"] = 257] = "JSDocTypeReference";
- SyntaxKind[SyntaxKind["JSDocOptionalType"] = 258] = "JSDocOptionalType";
- SyntaxKind[SyntaxKind["JSDocFunctionType"] = 259] = "JSDocFunctionType";
- SyntaxKind[SyntaxKind["JSDocVariadicType"] = 260] = "JSDocVariadicType";
- SyntaxKind[SyntaxKind["JSDocConstructorType"] = 261] = "JSDocConstructorType";
- SyntaxKind[SyntaxKind["JSDocThisType"] = 262] = "JSDocThisType";
- SyntaxKind[SyntaxKind["JSDocComment"] = 263] = "JSDocComment";
- SyntaxKind[SyntaxKind["JSDocTag"] = 264] = "JSDocTag";
- SyntaxKind[SyntaxKind["JSDocParameterTag"] = 265] = "JSDocParameterTag";
- SyntaxKind[SyntaxKind["JSDocReturnTag"] = 266] = "JSDocReturnTag";
- SyntaxKind[SyntaxKind["JSDocTypeTag"] = 267] = "JSDocTypeTag";
- SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 268] = "JSDocTemplateTag";
+ SyntaxKind[SyntaxKind["JSDocUnknownType"] = 251] = "JSDocUnknownType";
+ SyntaxKind[SyntaxKind["JSDocArrayType"] = 252] = "JSDocArrayType";
+ SyntaxKind[SyntaxKind["JSDocUnionType"] = 253] = "JSDocUnionType";
+ SyntaxKind[SyntaxKind["JSDocTupleType"] = 254] = "JSDocTupleType";
+ SyntaxKind[SyntaxKind["JSDocNullableType"] = 255] = "JSDocNullableType";
+ SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 256] = "JSDocNonNullableType";
+ SyntaxKind[SyntaxKind["JSDocRecordType"] = 257] = "JSDocRecordType";
+ SyntaxKind[SyntaxKind["JSDocRecordMember"] = 258] = "JSDocRecordMember";
+ SyntaxKind[SyntaxKind["JSDocTypeReference"] = 259] = "JSDocTypeReference";
+ SyntaxKind[SyntaxKind["JSDocOptionalType"] = 260] = "JSDocOptionalType";
+ SyntaxKind[SyntaxKind["JSDocFunctionType"] = 261] = "JSDocFunctionType";
+ SyntaxKind[SyntaxKind["JSDocVariadicType"] = 262] = "JSDocVariadicType";
+ SyntaxKind[SyntaxKind["JSDocConstructorType"] = 263] = "JSDocConstructorType";
+ SyntaxKind[SyntaxKind["JSDocThisType"] = 264] = "JSDocThisType";
+ SyntaxKind[SyntaxKind["JSDocComment"] = 265] = "JSDocComment";
+ SyntaxKind[SyntaxKind["JSDocTag"] = 266] = "JSDocTag";
+ SyntaxKind[SyntaxKind["JSDocParameterTag"] = 267] = "JSDocParameterTag";
+ SyntaxKind[SyntaxKind["JSDocReturnTag"] = 268] = "JSDocReturnTag";
+ SyntaxKind[SyntaxKind["JSDocTypeTag"] = 269] = "JSDocTypeTag";
+ SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 270] = "JSDocTemplateTag";
// Synthesized list
- SyntaxKind[SyntaxKind["SyntaxList"] = 269] = "SyntaxList";
+ SyntaxKind[SyntaxKind["SyntaxList"] = 271] = "SyntaxList";
// Enum value count
- SyntaxKind[SyntaxKind["Count"] = 270] = "Count";
+ SyntaxKind[SyntaxKind["Count"] = 272] = "Count";
// Markers
- SyntaxKind[SyntaxKind["FirstAssignment"] = 55] = "FirstAssignment";
- SyntaxKind[SyntaxKind["LastAssignment"] = 66] = "LastAssignment";
- SyntaxKind[SyntaxKind["FirstReservedWord"] = 68] = "FirstReservedWord";
- SyntaxKind[SyntaxKind["LastReservedWord"] = 103] = "LastReservedWord";
- SyntaxKind[SyntaxKind["FirstKeyword"] = 68] = "FirstKeyword";
- SyntaxKind[SyntaxKind["LastKeyword"] = 132] = "LastKeyword";
- SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 104] = "FirstFutureReservedWord";
- SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 112] = "LastFutureReservedWord";
- SyntaxKind[SyntaxKind["FirstTypeNode"] = 149] = "FirstTypeNode";
- SyntaxKind[SyntaxKind["LastTypeNode"] = 158] = "LastTypeNode";
+ 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"] = 134] = "LastKeyword";
+ SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord";
+ SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord";
+ SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode";
+ SyntaxKind[SyntaxKind["LastTypeNode"] = 160] = "LastTypeNode";
SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation";
- SyntaxKind[SyntaxKind["LastPunctuation"] = 66] = "LastPunctuation";
+ SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation";
SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken";
- SyntaxKind[SyntaxKind["LastToken"] = 132] = "LastToken";
+ SyntaxKind[SyntaxKind["LastToken"] = 134] = "LastToken";
SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken";
SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken";
SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken";
@@ -343,8 +346,8 @@ var ts;
SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken";
SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken";
SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator";
- SyntaxKind[SyntaxKind["LastBinaryOperator"] = 66] = "LastBinaryOperator";
- SyntaxKind[SyntaxKind["FirstNode"] = 133] = "FirstNode";
+ SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator";
+ SyntaxKind[SyntaxKind["FirstNode"] = 135] = "FirstNode";
})(ts.SyntaxKind || (ts.SyntaxKind = {}));
var SyntaxKind = ts.SyntaxKind;
(function (NodeFlags) {
@@ -365,6 +368,7 @@ var ts;
NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral";
NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace";
NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext";
+ NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis";
NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier";
NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier";
NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped";
@@ -614,6 +618,7 @@ var ts;
/* @internal */
TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType";
TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol";
+ TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType";
/* @internal */
TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic";
/* @internal */
@@ -656,6 +661,8 @@ var ts;
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) {
@@ -673,6 +680,7 @@ var ts;
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;
@@ -1222,8 +1230,11 @@ var ts;
}
ts.chainDiagnosticMessages = chainDiagnosticMessages;
function concatenateDiagnosticMessageChains(headChain, tailChain) {
- Debug.assert(!headChain.next);
- headChain.next = tailChain;
+ var lastChain = headChain;
+ while (lastChain.next) {
+ lastChain = lastChain.next;
+ }
+ lastChain.next = tailChain;
return headChain;
}
ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains;
@@ -1471,6 +1482,9 @@ var ts;
}
ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
function getBaseFileName(path) {
+ if (!path) {
+ return undefined;
+ }
var i = path.lastIndexOf(ts.directorySeparator);
return i < 0 ? path : path.substring(i + 1);
}
@@ -1497,6 +1511,25 @@ var ts;
* List of supported extensions in order of file resolution precedence.
*/
ts.supportedExtensions = [".ts", ".tsx", ".d.ts"];
+ /**
+ * List of extensions that will be used to look for external modules.
+ * This list is kept separate from supportedExtensions to for cases when we'll allow to include .js files in compilation,
+ * but still would like to load only TypeScript files as modules
+ */
+ ts.moduleFileExtensions = ts.supportedExtensions;
+ function isSupportedSourceFileName(fileName) {
+ if (!fileName) {
+ return false;
+ }
+ for (var _i = 0; _i < ts.supportedExtensions.length; _i++) {
+ var extension = ts.supportedExtensions[_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; _i < extensionsToRemove.length; _i++) {
@@ -1580,6 +1613,16 @@ var ts;
}
Debug.fail = fail;
})(Debug = ts.Debug || (ts.Debug = {}));
+ function copyListRemovingItem(item, list) {
+ var copiedList = [];
+ for (var i = 0, len = list.length; i < len; i++) {
+ if (list[i] !== item) {
+ copiedList.push(list[i]);
+ }
+ }
+ return copiedList;
+ }
+ ts.copyListRemovingItem = copyListRemovingItem;
})(ts || (ts = {}));
///
var ts;
@@ -1726,6 +1769,94 @@ var ts;
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 createWatchedFileSet(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.fileName, function (err, stats) {
+ if (err) {
+ watchedFile.callback(watchedFile.fileName);
+ }
+ else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) {
+ watchedFile.mtime = getModifiedTime(watchedFile.fileName);
+ watchedFile.callback(watchedFile.fileName, 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(fileName, callback) {
+ var file = {
+ fileName: fileName,
+ callback: callback,
+ mtime: getModifiedTime(fileName)
+ };
+ 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
+ };
+ }
+ // 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 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";
@@ -1814,17 +1945,32 @@ var ts;
readFile: readFile,
writeFile: writeFile,
watchFile: function (fileName, callback) {
- // watchFile polls a file every 250ms, picking up file notifications.
- _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);
+ // 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.
+ if (isNode4OrLater()) {
+ // Note: in node the callback of fs.watch is given only the relative file name as a parameter
+ return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); });
+ }
+ var watchedFile = watchedFileSet.addFile(fileName, callback);
return {
- close: function () { _fs.unwatchFile(fileName, fileChanged); }
+ close: function () { return watchedFileSet.removeFile(watchedFile); }
};
- function fileChanged(curr, prev) {
- if (+curr.mtime <= +prev.mtime) {
- return;
- }
- callback(fileName);
- }
+ },
+ 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)
+ return _fs.watch(path, { persisten: true, recursive: !!recursive }, 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);
@@ -1926,7 +2072,7 @@ var ts;
Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "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." },
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." },
- Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: ts.DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." },
+ 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." },
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." },
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." },
Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." },
@@ -2014,7 +2160,7 @@ var ts;
Property_destructuring_pattern_expected: { code: 1180, category: ts.DiagnosticCategory.Error, key: "Property destructuring pattern expected." },
Array_element_destructuring_pattern_expected: { code: 1181, category: ts.DiagnosticCategory.Error, key: "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." },
- An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." },
+ An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." },
Modifiers_cannot_appear_here: { code: 1184, category: ts.DiagnosticCategory.Error, key: "Modifiers cannot appear here." },
Merge_conflict_marker_encountered: { code: 1185, category: ts.DiagnosticCategory.Error, key: "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." },
@@ -2032,10 +2178,9 @@ var ts;
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." },
Unterminated_Unicode_escape_sequence: { code: 1199, category: ts.DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." },
Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
- Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
- Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
- Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." },
- Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." },
+ 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 * 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' or another module format instead." },
+ Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules into 'es6' when targeting 'ES5' or lower." },
Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "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/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." },
@@ -2064,10 +2209,6 @@ var ts;
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." },
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." },
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." },
- Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: ts.DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." },
- 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." },
- 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." },
- 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." },
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'." },
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'." },
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." },
@@ -2078,6 +2219,10 @@ var ts;
_0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "'{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." },
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." },
+ 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." },
+ 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." },
+ 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." },
+ 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." },
Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@@ -2118,7 +2263,7 @@ var ts;
Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "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." },
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}'." },
- 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'." },
+ 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'." },
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "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}'." },
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." },
@@ -2202,7 +2347,7 @@ var ts;
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 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 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" },
- Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." },
+ 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." },
Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "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" },
Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import name cannot be '{0}'" },
@@ -2283,12 +2428,15 @@ var ts;
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}'." },
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." },
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." },
- Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: ts.DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." },
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." },
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." },
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 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." },
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." },
+ 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." },
+ 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." },
+ 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." },
+ A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A module cannot have multiple default exports." },
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object 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." },
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." },
@@ -2301,8 +2449,9 @@ var ts;
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "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 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 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}'." },
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 package author to update the package definition." },
- Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. 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 the package definition." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "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}'." },
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}'." },
@@ -2387,7 +2536,7 @@ var ts;
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 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}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
- A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." },
+ 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: '{0}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "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." },
@@ -2399,7 +2548,7 @@ var ts;
Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." },
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." },
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" },
- Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" },
+ Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'" },
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." },
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "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." },
@@ -2420,7 +2569,7 @@ var ts;
Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." },
Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "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}'." },
- Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." },
+ Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'." },
Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." },
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 or -. For example '{0}' or '{1}'." },
Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." },
@@ -2441,7 +2590,6 @@ var ts;
Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." },
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "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." },
- Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "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: '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." },
@@ -2488,79 +2636,86 @@ var ts;
Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." },
JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "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." },
- 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'" }
+ 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'" },
+ 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 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. Consider enclosing the expression in parentheses." }
};
})(ts || (ts = {}));
///
///
var ts;
(function (ts) {
+ /* @internal */
+ function tokenIsIdentifierOrKeyword(token) {
+ return token >= 69 /* Identifier */;
+ }
+ ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
var textToToken = {
- "abstract": 113 /* AbstractKeyword */,
- "any": 115 /* AnyKeyword */,
- "as": 114 /* AsKeyword */,
- "boolean": 118 /* BooleanKeyword */,
- "break": 68 /* BreakKeyword */,
- "case": 69 /* CaseKeyword */,
- "catch": 70 /* CatchKeyword */,
- "class": 71 /* ClassKeyword */,
- "continue": 73 /* ContinueKeyword */,
- "const": 72 /* ConstKeyword */,
- "constructor": 119 /* ConstructorKeyword */,
- "debugger": 74 /* DebuggerKeyword */,
- "declare": 120 /* DeclareKeyword */,
- "default": 75 /* DefaultKeyword */,
- "delete": 76 /* DeleteKeyword */,
- "do": 77 /* DoKeyword */,
- "else": 78 /* ElseKeyword */,
- "enum": 79 /* EnumKeyword */,
- "export": 80 /* ExportKeyword */,
- "extends": 81 /* ExtendsKeyword */,
- "false": 82 /* FalseKeyword */,
- "finally": 83 /* FinallyKeyword */,
- "for": 84 /* ForKeyword */,
- "from": 131 /* FromKeyword */,
- "function": 85 /* FunctionKeyword */,
- "get": 121 /* GetKeyword */,
- "if": 86 /* IfKeyword */,
- "implements": 104 /* ImplementsKeyword */,
- "import": 87 /* ImportKeyword */,
- "in": 88 /* InKeyword */,
- "instanceof": 89 /* InstanceOfKeyword */,
- "interface": 105 /* InterfaceKeyword */,
- "is": 122 /* IsKeyword */,
- "let": 106 /* LetKeyword */,
- "module": 123 /* ModuleKeyword */,
- "namespace": 124 /* NamespaceKeyword */,
- "new": 90 /* NewKeyword */,
- "null": 91 /* NullKeyword */,
- "number": 126 /* NumberKeyword */,
- "package": 107 /* PackageKeyword */,
- "private": 108 /* PrivateKeyword */,
- "protected": 109 /* ProtectedKeyword */,
- "public": 110 /* PublicKeyword */,
- "require": 125 /* RequireKeyword */,
- "return": 92 /* ReturnKeyword */,
- "set": 127 /* SetKeyword */,
- "static": 111 /* StaticKeyword */,
- "string": 128 /* StringKeyword */,
- "super": 93 /* SuperKeyword */,
- "switch": 94 /* SwitchKeyword */,
- "symbol": 129 /* SymbolKeyword */,
- "this": 95 /* ThisKeyword */,
- "throw": 96 /* ThrowKeyword */,
- "true": 97 /* TrueKeyword */,
- "try": 98 /* TryKeyword */,
- "type": 130 /* TypeKeyword */,
- "typeof": 99 /* TypeOfKeyword */,
- "var": 100 /* VarKeyword */,
- "void": 101 /* VoidKeyword */,
- "while": 102 /* WhileKeyword */,
- "with": 103 /* WithKeyword */,
- "yield": 112 /* YieldKeyword */,
- "async": 116 /* AsyncKeyword */,
- "await": 117 /* AwaitKeyword */,
- "of": 132 /* OfKeyword */,
+ "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 */,
+ "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": 134 /* OfKeyword */,
"{": 15 /* OpenBraceToken */,
"}": 16 /* CloseBraceToken */,
"(": 17 /* OpenParenToken */,
@@ -2582,37 +2737,39 @@ var ts;
"=>": 34 /* EqualsGreaterThanToken */,
"+": 35 /* PlusToken */,
"-": 36 /* MinusToken */,
+ "**": 38 /* AsteriskAsteriskToken */,
"*": 37 /* AsteriskToken */,
- "/": 38 /* SlashToken */,
- "%": 39 /* PercentToken */,
- "++": 40 /* PlusPlusToken */,
- "--": 41 /* MinusMinusToken */,
- "<<": 42 /* LessThanLessThanToken */,
+ "/": 39 /* SlashToken */,
+ "%": 40 /* PercentToken */,
+ "++": 41 /* PlusPlusToken */,
+ "--": 42 /* MinusMinusToken */,
+ "<<": 43 /* LessThanLessThanToken */,
"": 26 /* LessThanSlashToken */,
- ">>": 43 /* GreaterThanGreaterThanToken */,
- ">>>": 44 /* GreaterThanGreaterThanGreaterThanToken */,
- "&": 45 /* AmpersandToken */,
- "|": 46 /* BarToken */,
- "^": 47 /* CaretToken */,
- "!": 48 /* ExclamationToken */,
- "~": 49 /* TildeToken */,
- "&&": 50 /* AmpersandAmpersandToken */,
- "||": 51 /* BarBarToken */,
- "?": 52 /* QuestionToken */,
- ":": 53 /* ColonToken */,
- "=": 55 /* EqualsToken */,
- "+=": 56 /* PlusEqualsToken */,
- "-=": 57 /* MinusEqualsToken */,
- "*=": 58 /* AsteriskEqualsToken */,
- "/=": 59 /* SlashEqualsToken */,
- "%=": 60 /* PercentEqualsToken */,
- "<<=": 61 /* LessThanLessThanEqualsToken */,
- ">>=": 62 /* GreaterThanGreaterThanEqualsToken */,
- ">>>=": 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */,
- "&=": 64 /* AmpersandEqualsToken */,
- "|=": 65 /* BarEqualsToken */,
- "^=": 66 /* CaretEqualsToken */,
- "@": 54 /* AtToken */
+ ">>": 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
@@ -3116,8 +3273,8 @@ var ts;
getTokenValue: function () { return tokenValue; },
hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; },
hasPrecedingLineBreak: function () { return precedingLineBreak; },
- isIdentifier: function () { return token === 67 /* Identifier */ || token > 103 /* LastReservedWord */; },
- isReservedWord: function () { return token >= 68 /* FirstReservedWord */ && token <= 103 /* LastReservedWord */; },
+ 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,
@@ -3139,16 +3296,6 @@ var ts;
onError(message, length || 0);
}
}
- function isIdentifierStart(ch) {
- return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ ||
- ch === 36 /* $ */ || ch === 95 /* _ */ ||
- ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion);
- }
- function isIdentifierPart(ch) {
- 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);
- }
function scanNumber() {
var start = pos;
while (isDigit(text.charCodeAt(pos)))
@@ -3431,12 +3578,12 @@ var ts;
var start = pos;
while (pos < end) {
var ch = text.charCodeAt(pos);
- if (isIdentifierPart(ch)) {
+ if (isIdentifierPart(ch, languageVersion)) {
pos++;
}
else if (ch === 92 /* backslash */) {
ch = peekUnicodeEscape();
- if (!(ch >= 0 && isIdentifierPart(ch))) {
+ if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) {
break;
}
result += text.substring(start, pos);
@@ -3461,7 +3608,7 @@ var ts;
return token = textToToken[tokenValue];
}
}
- return token = 67 /* Identifier */;
+ return token = 69 /* Identifier */;
}
function scanBinaryOrOctalDigits(base) {
ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8");
@@ -3545,7 +3692,7 @@ var ts;
}
return pos += 2, token = 31 /* ExclamationEqualsToken */;
}
- return pos++, token = 48 /* ExclamationToken */;
+ return pos++, token = 49 /* ExclamationToken */;
case 34 /* doubleQuote */:
case 39 /* singleQuote */:
tokenValue = scanString();
@@ -3554,42 +3701,48 @@ var ts;
return token = scanTemplateAndSetTokenValue();
case 37 /* percent */:
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 60 /* PercentEqualsToken */;
+ return pos += 2, token = 62 /* PercentEqualsToken */;
}
- return pos++, token = 39 /* PercentToken */;
+ return pos++, token = 40 /* PercentToken */;
case 38 /* ampersand */:
if (text.charCodeAt(pos + 1) === 38 /* ampersand */) {
- return pos += 2, token = 50 /* AmpersandAmpersandToken */;
+ return pos += 2, token = 51 /* AmpersandAmpersandToken */;
}
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 64 /* AmpersandEqualsToken */;
+ return pos += 2, token = 66 /* AmpersandEqualsToken */;
}
- return pos++, token = 45 /* AmpersandToken */;
+ return pos++, token = 46 /* AmpersandToken */;
case 40 /* openParen */:
return pos++, token = 17 /* OpenParenToken */;
case 41 /* closeParen */:
return pos++, token = 18 /* CloseParenToken */;
case 42 /* asterisk */:
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 58 /* AsteriskEqualsToken */;
+ 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 */;
}
return pos++, token = 37 /* AsteriskToken */;
case 43 /* plus */:
if (text.charCodeAt(pos + 1) === 43 /* plus */) {
- return pos += 2, token = 40 /* PlusPlusToken */;
+ return pos += 2, token = 41 /* PlusPlusToken */;
}
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 56 /* PlusEqualsToken */;
+ return pos += 2, token = 57 /* PlusEqualsToken */;
}
return pos++, token = 35 /* PlusToken */;
case 44 /* comma */:
return pos++, token = 24 /* CommaToken */;
case 45 /* minus */:
if (text.charCodeAt(pos + 1) === 45 /* minus */) {
- return pos += 2, token = 41 /* MinusMinusToken */;
+ return pos += 2, token = 42 /* MinusMinusToken */;
}
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 57 /* MinusEqualsToken */;
+ return pos += 2, token = 58 /* MinusEqualsToken */;
}
return pos++, token = 36 /* MinusToken */;
case 46 /* dot */:
@@ -3646,9 +3799,9 @@ var ts;
}
}
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 59 /* SlashEqualsToken */;
+ return pos += 2, token = 61 /* SlashEqualsToken */;
}
- return pos++, token = 38 /* SlashToken */;
+ return pos++, token = 39 /* SlashToken */;
case 48 /* _0 */:
if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) {
pos += 2;
@@ -3700,7 +3853,7 @@ var ts;
tokenValue = "" + scanNumber();
return token = 8 /* NumericLiteral */;
case 58 /* colon */:
- return pos++, token = 53 /* ColonToken */;
+ return pos++, token = 54 /* ColonToken */;
case 59 /* semicolon */:
return pos++, token = 23 /* SemicolonToken */;
case 60 /* lessThan */:
@@ -3715,14 +3868,16 @@ var ts;
}
if (text.charCodeAt(pos + 1) === 60 /* lessThan */) {
if (text.charCodeAt(pos + 2) === 61 /* equals */) {
- return pos += 3, token = 61 /* LessThanLessThanEqualsToken */;
+ return pos += 3, token = 63 /* LessThanLessThanEqualsToken */;
}
- return pos += 2, token = 42 /* LessThanLessThanToken */;
+ return pos += 2, token = 43 /* LessThanLessThanToken */;
}
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
return pos += 2, token = 28 /* LessThanEqualsToken */;
}
- if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) {
+ if (languageVariant === 1 /* JSX */ &&
+ text.charCodeAt(pos + 1) === 47 /* slash */ &&
+ text.charCodeAt(pos + 2) !== 42 /* asterisk */) {
return pos += 2, token = 26 /* LessThanSlashToken */;
}
return pos++, token = 25 /* LessThanToken */;
@@ -3745,7 +3900,7 @@ var ts;
if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) {
return pos += 2, token = 34 /* EqualsGreaterThanToken */;
}
- return pos++, token = 55 /* EqualsToken */;
+ return pos++, token = 56 /* EqualsToken */;
case 62 /* greaterThan */:
if (isConflictMarkerTrivia(text, pos)) {
pos = scanConflictMarkerTrivia(text, pos, error);
@@ -3758,35 +3913,35 @@ var ts;
}
return pos++, token = 27 /* GreaterThanToken */;
case 63 /* question */:
- return pos++, token = 52 /* QuestionToken */;
+ return pos++, token = 53 /* QuestionToken */;
case 91 /* openBracket */:
return pos++, token = 19 /* OpenBracketToken */;
case 93 /* closeBracket */:
return pos++, token = 20 /* CloseBracketToken */;
case 94 /* caret */:
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 66 /* CaretEqualsToken */;
+ return pos += 2, token = 68 /* CaretEqualsToken */;
}
- return pos++, token = 47 /* CaretToken */;
+ return pos++, token = 48 /* CaretToken */;
case 123 /* openBrace */:
return pos++, token = 15 /* OpenBraceToken */;
case 124 /* bar */:
if (text.charCodeAt(pos + 1) === 124 /* bar */) {
- return pos += 2, token = 51 /* BarBarToken */;
+ return pos += 2, token = 52 /* BarBarToken */;
}
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 65 /* BarEqualsToken */;
+ return pos += 2, token = 67 /* BarEqualsToken */;
}
- return pos++, token = 46 /* BarToken */;
+ return pos++, token = 47 /* BarToken */;
case 125 /* closeBrace */:
return pos++, token = 16 /* CloseBraceToken */;
case 126 /* tilde */:
- return pos++, token = 49 /* TildeToken */;
+ return pos++, token = 50 /* TildeToken */;
case 64 /* at */:
- return pos++, token = 54 /* AtToken */;
+ return pos++, token = 55 /* AtToken */;
case 92 /* backslash */:
var cookedChar = peekUnicodeEscape();
- if (cookedChar >= 0 && isIdentifierStart(cookedChar)) {
+ if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
pos += 6;
tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
return token = getIdentifierToken();
@@ -3794,9 +3949,9 @@ var ts;
error(ts.Diagnostics.Invalid_character);
return pos++, token = 0 /* Unknown */;
default:
- if (isIdentifierStart(ch)) {
+ if (isIdentifierStart(ch, languageVersion)) {
pos++;
- while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos)))
+ while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion))
pos++;
tokenValue = text.substring(tokenPos, pos);
if (ch === 92 /* backslash */) {
@@ -3823,14 +3978,14 @@ var ts;
if (text.charCodeAt(pos) === 62 /* greaterThan */) {
if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) {
if (text.charCodeAt(pos + 2) === 61 /* equals */) {
- return pos += 3, token = 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */;
+ return pos += 3, token = 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */;
}
- return pos += 2, token = 44 /* GreaterThanGreaterThanGreaterThanToken */;
+ return pos += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */;
}
if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 62 /* GreaterThanGreaterThanEqualsToken */;
+ return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */;
}
- return pos++, token = 43 /* GreaterThanGreaterThanToken */;
+ return pos++, token = 44 /* GreaterThanGreaterThanToken */;
}
if (text.charCodeAt(pos) === 61 /* equals */) {
return pos++, token = 29 /* GreaterThanEqualsToken */;
@@ -3839,7 +3994,7 @@ var ts;
return token;
}
function reScanSlashToken() {
- if (token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) {
+ if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) {
var p = tokenPos + 1;
var inEscape = false;
var inCharacterClass = false;
@@ -3879,7 +4034,7 @@ var ts;
}
p++;
}
- while (p < end && isIdentifierPart(text.charCodeAt(p))) {
+ while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) {
p++;
}
pos = p;
@@ -3925,16 +4080,16 @@ var ts;
break;
}
}
- return token = 234 /* JsxText */;
+ return token = 236 /* JsxText */;
}
// Scans a JSX identifier; these differ from normal identifiers in that
// they allow dashes
function scanJsxIdentifier() {
- if (token === 67 /* Identifier */) {
+ if (tokenIsIdentifierOrKeyword(token)) {
var firstCharPosition = pos;
while (pos < end) {
var ch = text.charCodeAt(pos);
- if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) {
+ if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) {
pos++;
}
else {
@@ -4013,16 +4168,16 @@ var ts;
function getModuleInstanceState(node) {
// A module is uninstantiated if it contains only
// 1. interface declarations, type alias declarations
- if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 214 /* TypeAliasDeclaration */) {
+ if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 216 /* TypeAliasDeclaration */) {
return 0 /* NonInstantiated */;
}
else if (ts.isConstEnumDeclaration(node)) {
return 2 /* ConstEnumOnly */;
}
- else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) {
+ else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) {
return 0 /* NonInstantiated */;
}
- else if (node.kind === 217 /* ModuleBlock */) {
+ else if (node.kind === 219 /* ModuleBlock */) {
var state = 0 /* NonInstantiated */;
ts.forEachChild(node, function (n) {
switch (getModuleInstanceState(n)) {
@@ -4041,7 +4196,7 @@ var ts;
});
return state;
}
- else if (node.kind === 216 /* ModuleDeclaration */) {
+ else if (node.kind === 218 /* ModuleDeclaration */) {
return getModuleInstanceState(node.body);
}
else {
@@ -4081,6 +4236,7 @@ var ts;
var container;
var blockScopeContainer;
var lastContainer;
+ var seenThisKeyword;
// 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).
@@ -4119,10 +4275,10 @@ var ts;
// unless it is a well known Symbol.
function getDeclarationName(node) {
if (node.name) {
- if (node.kind === 216 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) {
+ if (node.kind === 218 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) {
return "\"" + node.name.text + "\"";
}
- if (node.name.kind === 134 /* ComputedPropertyName */) {
+ if (node.name.kind === 136 /* ComputedPropertyName */) {
var nameExpression = node.name.expression;
ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression));
return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text);
@@ -4130,22 +4286,22 @@ var ts;
return node.name.text;
}
switch (node.kind) {
- case 142 /* Constructor */:
+ case 144 /* Constructor */:
return "__constructor";
- case 150 /* FunctionType */:
- case 145 /* CallSignature */:
+ case 152 /* FunctionType */:
+ case 147 /* CallSignature */:
return "__call";
- case 151 /* ConstructorType */:
- case 146 /* ConstructSignature */:
+ case 153 /* ConstructorType */:
+ case 148 /* ConstructSignature */:
return "__new";
- case 147 /* IndexSignature */:
+ case 149 /* IndexSignature */:
return "__index";
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
return "__export";
- case 225 /* ExportAssignment */:
+ case 227 /* ExportAssignment */:
return node.isExportEquals ? "export=" : "default";
- case 211 /* FunctionDeclaration */:
- case 212 /* ClassDeclaration */:
+ case 213 /* FunctionDeclaration */:
+ case 214 /* ClassDeclaration */:
return node.flags & 1024 /* Default */ ? "default" : undefined;
}
}
@@ -4162,8 +4318,9 @@ var ts;
*/
function declareSymbol(symbolTable, parent, node, includes, excludes) {
ts.Debug.assert(!ts.hasDynamicName(node));
+ var isDefaultExport = node.flags & 1024 /* Default */;
// The exported symbol for an export default function/class node is always named "default"
- var name = node.flags & 1024 /* Default */ && parent ? "default" : getDeclarationName(node);
+ 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,
@@ -4199,6 +4356,11 @@ var ts;
var message = 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 & 1024 /* Default */) {
+ message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
+ }
+ });
ts.forEach(symbol.declarations, function (declaration) {
file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration)));
});
@@ -4216,7 +4378,7 @@ var ts;
function declareModuleMember(node, symbolFlags, symbolExcludes) {
var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */;
if (symbolFlags & 8388608 /* Alias */) {
- if (node.kind === 228 /* ExportSpecifier */ || (node.kind === 219 /* ImportEqualsDeclaration */ && hasExportModifier)) {
+ if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* ImportEqualsDeclaration */ && hasExportModifier)) {
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
}
else {
@@ -4290,44 +4452,51 @@ var ts;
blockScopeContainer = node;
blockScopeContainer.locals = undefined;
}
- ts.forEachChild(node, bind);
+ if (node.kind === 215 /* InterfaceDeclaration */) {
+ seenThisKeyword = false;
+ ts.forEachChild(node, bind);
+ node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */;
+ }
+ else {
+ ts.forEachChild(node, bind);
+ }
container = saveContainer;
parent = saveParent;
blockScopeContainer = savedBlockScopeContainer;
}
function getContainerFlags(node) {
switch (node.kind) {
- case 184 /* ClassExpression */:
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 215 /* EnumDeclaration */:
- case 153 /* TypeLiteral */:
- case 163 /* ObjectLiteralExpression */:
+ case 186 /* ClassExpression */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 155 /* TypeLiteral */:
+ case 165 /* ObjectLiteralExpression */:
return 1 /* IsContainer */;
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */:
- case 147 /* IndexSignature */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 211 /* FunctionDeclaration */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
- case 216 /* ModuleDeclaration */:
- case 246 /* SourceFile */:
- case 214 /* TypeAliasDeclaration */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 149 /* IndexSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 213 /* FunctionDeclaration */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
+ case 218 /* ModuleDeclaration */:
+ case 248 /* SourceFile */:
+ case 216 /* TypeAliasDeclaration */:
return 5 /* IsContainerWithLocals */;
- case 242 /* CatchClause */:
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 218 /* CaseBlock */:
+ case 244 /* CatchClause */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 220 /* CaseBlock */:
return 2 /* IsBlockScopedContainer */;
- case 190 /* Block */:
+ case 192 /* 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
@@ -4364,38 +4533,38 @@ var ts;
// 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 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
return declareModuleMember(node, symbolFlags, symbolExcludes);
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
return declareSourceFileMember(node, symbolFlags, symbolExcludes);
- case 184 /* ClassExpression */:
- case 212 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
+ case 214 /* ClassDeclaration */:
return declareClassMember(node, symbolFlags, symbolExcludes);
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
- case 153 /* TypeLiteral */:
- case 163 /* ObjectLiteralExpression */:
- case 213 /* InterfaceDeclaration */:
+ case 155 /* TypeLiteral */:
+ case 165 /* ObjectLiteralExpression */:
+ case 215 /* InterfaceDeclaration */:
// 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 150 /* FunctionType */:
- case 151 /* ConstructorType */:
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */:
- case 147 /* IndexSignature */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
- case 214 /* TypeAliasDeclaration */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 149 /* IndexSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
+ case 216 /* 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
@@ -4425,11 +4594,11 @@ var ts;
return false;
}
function hasExportDeclarations(node) {
- var body = node.kind === 246 /* SourceFile */ ? node : node.body;
- if (body.kind === 246 /* SourceFile */ || body.kind === 217 /* ModuleBlock */) {
+ var body = node.kind === 248 /* SourceFile */ ? node : node.body;
+ if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) {
for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
var stat = _a[_i];
- if (stat.kind === 226 /* ExportDeclaration */ || stat.kind === 225 /* ExportAssignment */) {
+ if (stat.kind === 228 /* ExportDeclaration */ || stat.kind === 227 /* ExportAssignment */) {
return true;
}
}
@@ -4501,7 +4670,7 @@ var ts;
var seen = {};
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var prop = _a[_i];
- if (prop.name.kind !== 67 /* Identifier */) {
+ if (prop.name.kind !== 69 /* Identifier */) {
continue;
}
var identifier = prop.name;
@@ -4513,7 +4682,7 @@ var ts;
// 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 === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */ || prop.kind === 141 /* MethodDeclaration */
+ var currentKind = prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */ || prop.kind === 143 /* MethodDeclaration */
? 1 /* Property */
: 2 /* Accessor */;
var existingKind = seen[identifier.text];
@@ -4535,10 +4704,10 @@ var ts;
}
function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) {
switch (blockScopeContainer.kind) {
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
declareModuleMember(node, symbolFlags, symbolExcludes);
break;
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
if (ts.isExternalModule(container)) {
declareModuleMember(node, symbolFlags, symbolExcludes);
break;
@@ -4559,8 +4728,8 @@ var ts;
// check for reserved words used as identifiers in strict mode code.
function checkStrictModeIdentifier(node) {
if (inStrictMode &&
- node.originalKeywordKind >= 104 /* FirstFutureReservedWord */ &&
- node.originalKeywordKind <= 112 /* LastFutureReservedWord */ &&
+ 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) {
@@ -4595,7 +4764,7 @@ var ts;
}
function checkStrictModeDeleteExpression(node) {
// Grammar checking
- if (inStrictMode && node.expression.kind === 67 /* Identifier */) {
+ 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);
@@ -4603,11 +4772,11 @@ var ts;
}
}
function isEvalOrArgumentsIdentifier(node) {
- return node.kind === 67 /* Identifier */ &&
+ return node.kind === 69 /* Identifier */ &&
(node.text === "eval" || node.text === "arguments");
}
function checkStrictModeEvalOrArguments(contextNode, name) {
- if (name && name.kind === 67 /* Identifier */) {
+ 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
@@ -4651,7 +4820,7 @@ var ts;
function checkStrictModePrefixUnaryExpression(node) {
// Grammar checking
if (inStrictMode) {
- if (node.operator === 40 /* PlusPlusToken */ || node.operator === 41 /* MinusMinusToken */) {
+ if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) {
checkStrictModeEvalOrArguments(node, node.operand);
}
}
@@ -4695,17 +4864,17 @@ var ts;
}
function updateStrictMode(node) {
switch (node.kind) {
- case 246 /* SourceFile */:
- case 217 /* ModuleBlock */:
+ case 248 /* SourceFile */:
+ case 219 /* ModuleBlock */:
updateStrictModeStatementList(node.statements);
return;
- case 190 /* Block */:
+ case 192 /* Block */:
if (ts.isFunctionLike(node.parent)) {
updateStrictModeStatementList(node.statements);
}
return;
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
// All classes are automatically in strict mode in ES6.
inStrictMode = true;
return;
@@ -4732,92 +4901,95 @@ var ts;
}
function bindWorker(node) {
switch (node.kind) {
- case 67 /* Identifier */:
+ case 69 /* Identifier */:
return checkStrictModeIdentifier(node);
- case 179 /* BinaryExpression */:
+ case 181 /* BinaryExpression */:
return checkStrictModeBinaryExpression(node);
- case 242 /* CatchClause */:
+ case 244 /* CatchClause */:
return checkStrictModeCatchClause(node);
- case 173 /* DeleteExpression */:
+ case 175 /* DeleteExpression */:
return checkStrictModeDeleteExpression(node);
case 8 /* NumericLiteral */:
return checkStrictModeNumericLiteral(node);
- case 178 /* PostfixUnaryExpression */:
+ case 180 /* PostfixUnaryExpression */:
return checkStrictModePostfixUnaryExpression(node);
- case 177 /* PrefixUnaryExpression */:
+ case 179 /* PrefixUnaryExpression */:
return checkStrictModePrefixUnaryExpression(node);
- case 203 /* WithStatement */:
+ case 205 /* WithStatement */:
return checkStrictModeWithStatement(node);
- case 135 /* TypeParameter */:
+ case 97 /* ThisKeyword */:
+ seenThisKeyword = true;
+ return;
+ case 137 /* TypeParameter */:
return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */);
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
return bindParameter(node);
- case 209 /* VariableDeclaration */:
- case 161 /* BindingElement */:
+ case 211 /* VariableDeclaration */:
+ case 163 /* BindingElement */:
return bindVariableDeclarationOrBindingElement(node);
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */);
- case 243 /* PropertyAssignment */:
- case 244 /* ShorthandPropertyAssignment */:
+ case 245 /* PropertyAssignment */:
+ case 246 /* ShorthandPropertyAssignment */:
return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */);
- case 245 /* EnumMember */:
+ case 247 /* EnumMember */:
return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */);
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */:
- case 147 /* IndexSignature */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 149 /* IndexSignature */:
return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */);
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* 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 211 /* FunctionDeclaration */:
+ case 213 /* FunctionDeclaration */:
checkStrictModeFunctionName(node);
return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */);
- case 142 /* Constructor */:
+ case 144 /* Constructor */:
return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */);
- case 143 /* GetAccessor */:
+ case 145 /* GetAccessor */:
return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */);
- case 144 /* SetAccessor */:
+ case 146 /* SetAccessor */:
return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */);
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
return bindFunctionOrConstructorType(node);
- case 153 /* TypeLiteral */:
+ case 155 /* TypeLiteral */:
return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type");
- case 163 /* ObjectLiteralExpression */:
+ case 165 /* ObjectLiteralExpression */:
return bindObjectLiteralExpression(node);
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
checkStrictModeFunctionName(node);
var bindingName = node.name ? node.name.text : "__function";
return bindAnonymousDeclaration(node, 16 /* Function */, bindingName);
- case 184 /* ClassExpression */:
- case 212 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
+ case 214 /* ClassDeclaration */:
return bindClassLikeDeclaration(node);
- case 213 /* InterfaceDeclaration */:
+ case 215 /* InterfaceDeclaration */:
return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */);
- case 214 /* TypeAliasDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */);
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
return bindEnumDeclaration(node);
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
return bindModuleDeclaration(node);
- case 219 /* ImportEqualsDeclaration */:
- case 222 /* NamespaceImport */:
- case 224 /* ImportSpecifier */:
- case 228 /* ExportSpecifier */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 224 /* NamespaceImport */:
+ case 226 /* ImportSpecifier */:
+ case 230 /* ExportSpecifier */:
return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */);
- case 221 /* ImportClause */:
+ case 223 /* ImportClause */:
return bindImportClause(node);
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
return bindExportDeclaration(node);
- case 225 /* ExportAssignment */:
+ case 227 /* ExportAssignment */:
return bindExportAssignment(node);
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
return bindSourceFileIfExternalModule();
}
}
@@ -4832,7 +5004,7 @@ var ts;
// Export assignment in some sort of block construct
bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node));
}
- else if (node.expression.kind === 67 /* Identifier */) {
+ else if (node.expression.kind === 69 /* Identifier */) {
// 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 */);
}
@@ -4857,7 +5029,7 @@ var ts;
}
}
function bindClassLikeDeclaration(node) {
- if (node.kind === 212 /* ClassDeclaration */) {
+ if (node.kind === 214 /* ClassDeclaration */) {
bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */);
}
else {
@@ -4933,7 +5105,7 @@ var ts;
// If this is a property-parameter, then also declare the property symbol into the
// containing class.
if (node.flags & 112 /* AccessibilityModifier */ &&
- node.parent.kind === 142 /* Constructor */ &&
+ node.parent.kind === 144 /* Constructor */ &&
ts.isClassLike(node.parent.parent)) {
var classDeclaration = node.parent.parent;
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */);
@@ -4947,6 +5119,7 @@ var ts;
}
})(ts || (ts = {}));
///
+///
/* @internal */
var ts;
(function (ts) {
@@ -4984,7 +5157,8 @@ var ts;
increaseIndent: function () { },
decreaseIndent: function () { },
clear: function () { return str = ""; },
- trackSymbol: function () { }
+ trackSymbol: function () { },
+ reportInaccessibleThisError: function () { }
};
}
return stringWriters.pop();
@@ -5054,7 +5228,7 @@ var ts;
}
}
function getSourceFileOfNode(node) {
- while (node && node.kind !== 246 /* SourceFile */) {
+ while (node && node.kind !== 248 /* SourceFile */) {
node = node.parent;
}
return node;
@@ -5076,16 +5250,16 @@ var ts;
return node.pos;
}
ts.getStartPosOfNode = getStartPosOfNode;
- // Returns true if this node is missing from the actual source code. 'missing' is different
- // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes
- // in the tree), it is definitel missing. HOwever, a node may be defined, but still be
+ // 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:
+ // 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.
+ // 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) {
@@ -5166,15 +5340,15 @@ var ts;
return current;
}
switch (current.kind) {
- case 246 /* SourceFile */:
- case 218 /* CaseBlock */:
- case 242 /* CatchClause */:
- case 216 /* ModuleDeclaration */:
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
+ case 248 /* SourceFile */:
+ case 220 /* CaseBlock */:
+ case 244 /* CatchClause */:
+ case 218 /* ModuleDeclaration */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
return current;
- case 190 /* Block */:
+ case 192 /* Block */:
// function block is not considered block-scope container
// see comment in binder.ts: bind(...), case for SyntaxKind.Block
if (!isFunctionLike(current.parent)) {
@@ -5187,9 +5361,9 @@ var ts;
ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
function isCatchClauseVariableDeclaration(declaration) {
return declaration &&
- declaration.kind === 209 /* VariableDeclaration */ &&
+ declaration.kind === 211 /* VariableDeclaration */ &&
declaration.parent &&
- declaration.parent.kind === 242 /* CatchClause */;
+ declaration.parent.kind === 244 /* CatchClause */;
}
ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration;
// Return display name of an identifier
@@ -5228,7 +5402,7 @@ var ts;
function getErrorSpanForNode(sourceFile, node) {
var errorNode = node;
switch (node.kind) {
- case 246 /* SourceFile */:
+ case 248 /* 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
@@ -5237,16 +5411,16 @@ var ts;
return getSpanOfTokenAtPosition(sourceFile, pos_1);
// This list is a work in progress. Add missing node kinds to improve their error
// spans.
- case 209 /* VariableDeclaration */:
- case 161 /* BindingElement */:
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
- case 213 /* InterfaceDeclaration */:
- case 216 /* ModuleDeclaration */:
- case 215 /* EnumDeclaration */:
- case 245 /* EnumMember */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
+ case 211 /* VariableDeclaration */:
+ case 163 /* BindingElement */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
+ case 215 /* InterfaceDeclaration */:
+ case 218 /* ModuleDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 247 /* EnumMember */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
errorNode = node.name;
break;
}
@@ -5270,11 +5444,11 @@ var ts;
}
ts.isDeclarationFile = isDeclarationFile;
function isConstEnumDeclaration(node) {
- return node.kind === 215 /* EnumDeclaration */ && isConst(node);
+ return node.kind === 217 /* EnumDeclaration */ && isConst(node);
}
ts.isConstEnumDeclaration = isConstEnumDeclaration;
function walkUpBindingElementsAndPatterns(node) {
- while (node && (node.kind === 161 /* BindingElement */ || isBindingPattern(node))) {
+ while (node && (node.kind === 163 /* BindingElement */ || isBindingPattern(node))) {
node = node.parent;
}
return node;
@@ -5289,14 +5463,14 @@ var ts;
function getCombinedNodeFlags(node) {
node = walkUpBindingElementsAndPatterns(node);
var flags = node.flags;
- if (node.kind === 209 /* VariableDeclaration */) {
+ if (node.kind === 211 /* VariableDeclaration */) {
node = node.parent;
}
- if (node && node.kind === 210 /* VariableDeclarationList */) {
+ if (node && node.kind === 212 /* VariableDeclarationList */) {
flags |= node.flags;
node = node.parent;
}
- if (node && node.kind === 191 /* VariableStatement */) {
+ if (node && node.kind === 193 /* VariableStatement */) {
flags |= node.flags;
}
return flags;
@@ -5311,7 +5485,7 @@ var ts;
}
ts.isLet = isLet;
function isPrologueDirective(node) {
- return node.kind === 193 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */;
+ return node.kind === 195 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */;
}
ts.isPrologueDirective = isPrologueDirective;
function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
@@ -5319,7 +5493,7 @@ var ts;
}
ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode;
function getJsDocComments(node, sourceFileOfNode) {
- var commentRanges = (node.kind === 136 /* Parameter */ || node.kind === 135 /* TypeParameter */) ?
+ var commentRanges = (node.kind === 138 /* Parameter */ || node.kind === 137 /* TypeParameter */) ?
ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) :
getLeadingCommentRangesOfNode(node, sourceFileOfNode);
return ts.filter(commentRanges, isJsDocComment);
@@ -5332,41 +5506,42 @@ var ts;
}
ts.getJsDocComments = getJsDocComments;
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/;
+ ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/;
function isTypeNode(node) {
- if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) {
+ if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 160 /* LastTypeNode */) {
return true;
}
switch (node.kind) {
- case 115 /* AnyKeyword */:
- case 126 /* NumberKeyword */:
- case 128 /* StringKeyword */:
- case 118 /* BooleanKeyword */:
- case 129 /* SymbolKeyword */:
+ case 117 /* AnyKeyword */:
+ case 128 /* NumberKeyword */:
+ case 130 /* StringKeyword */:
+ case 120 /* BooleanKeyword */:
+ case 131 /* SymbolKeyword */:
return true;
- case 101 /* VoidKeyword */:
- return node.parent.kind !== 175 /* VoidExpression */;
+ case 103 /* VoidKeyword */:
+ return node.parent.kind !== 177 /* VoidExpression */;
case 9 /* StringLiteral */:
// Specialized signatures can have string literals as their parameters' type names
- return node.parent.kind === 136 /* Parameter */;
- case 186 /* ExpressionWithTypeArguments */:
+ return node.parent.kind === 138 /* Parameter */;
+ case 188 /* 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 67 /* Identifier */:
+ 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 === 133 /* QualifiedName */ && node.parent.right === node) {
+ if (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) {
node = node.parent;
}
- else if (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node) {
+ else if (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node) {
node = node.parent;
}
- // fall through
- case 133 /* QualifiedName */:
- case 164 /* PropertyAccessExpression */:
// At this point, node is either a qualified name or an identifier
- ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'.");
+ ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'.");
+ case 135 /* QualifiedName */:
+ case 166 /* PropertyAccessExpression */:
+ case 97 /* ThisKeyword */:
var parent_1 = node.parent;
- if (parent_1.kind === 152 /* TypeQuery */) {
+ if (parent_1.kind === 154 /* TypeQuery */) {
return false;
}
// Do not recursively call isTypeNode on the parent. In the example:
@@ -5375,38 +5550,38 @@ var ts;
//
// Calling isTypeNode would consider the qualified name A.B a type node. Only C or
// A.B.C is a type node.
- if (149 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 158 /* LastTypeNode */) {
+ if (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 160 /* LastTypeNode */) {
return true;
}
switch (parent_1.kind) {
- case 186 /* ExpressionWithTypeArguments */:
+ case 188 /* ExpressionWithTypeArguments */:
return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1);
- case 135 /* TypeParameter */:
+ case 137 /* TypeParameter */:
return node === parent_1.constraint;
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 136 /* Parameter */:
- case 209 /* VariableDeclaration */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 138 /* Parameter */:
+ case 211 /* VariableDeclaration */:
return node === parent_1.type;
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
- case 142 /* Constructor */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
+ case 144 /* Constructor */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
return node === parent_1.type;
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */:
- case 147 /* IndexSignature */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 149 /* IndexSignature */:
return node === parent_1.type;
- case 169 /* TypeAssertionExpression */:
+ case 171 /* TypeAssertionExpression */:
return node === parent_1.type;
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0;
- case 168 /* TaggedTemplateExpression */:
+ case 170 /* TaggedTemplateExpression */:
// TODO (drosen): TaggedTemplateExpressions may eventually support type arguments.
return false;
}
@@ -5420,23 +5595,23 @@ var ts;
return traverse(body);
function traverse(node) {
switch (node.kind) {
- case 202 /* ReturnStatement */:
+ case 204 /* ReturnStatement */:
return visitor(node);
- case 218 /* CaseBlock */:
- case 190 /* Block */:
- case 194 /* IfStatement */:
- case 195 /* DoStatement */:
- case 196 /* WhileStatement */:
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 203 /* WithStatement */:
- case 204 /* SwitchStatement */:
- case 239 /* CaseClause */:
- case 240 /* DefaultClause */:
- case 205 /* LabeledStatement */:
- case 207 /* TryStatement */:
- case 242 /* CatchClause */:
+ case 220 /* CaseBlock */:
+ case 192 /* Block */:
+ case 196 /* IfStatement */:
+ case 197 /* DoStatement */:
+ case 198 /* WhileStatement */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 205 /* WithStatement */:
+ case 206 /* SwitchStatement */:
+ case 241 /* CaseClause */:
+ case 242 /* DefaultClause */:
+ case 207 /* LabeledStatement */:
+ case 209 /* TryStatement */:
+ case 244 /* CatchClause */:
return ts.forEachChild(node, traverse);
}
}
@@ -5446,18 +5621,18 @@ var ts;
return traverse(body);
function traverse(node) {
switch (node.kind) {
- case 182 /* YieldExpression */:
+ case 184 /* YieldExpression */:
visitor(node);
var operand = node.expression;
if (operand) {
traverse(operand);
}
- case 215 /* EnumDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 216 /* ModuleDeclaration */:
- case 214 /* TypeAliasDeclaration */:
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
+ case 217 /* EnumDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 218 /* ModuleDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* 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.
@@ -5465,7 +5640,7 @@ var ts;
default:
if (isFunctionLike(node)) {
var name_5 = node.name;
- if (name_5 && name_5.kind === 134 /* ComputedPropertyName */) {
+ if (name_5 && name_5.kind === 136 /* 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);
@@ -5484,14 +5659,14 @@ var ts;
function isVariableLike(node) {
if (node) {
switch (node.kind) {
- case 161 /* BindingElement */:
- case 245 /* EnumMember */:
- case 136 /* Parameter */:
- case 243 /* PropertyAssignment */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 244 /* ShorthandPropertyAssignment */:
- case 209 /* VariableDeclaration */:
+ case 163 /* BindingElement */:
+ case 247 /* EnumMember */:
+ case 138 /* Parameter */:
+ case 245 /* PropertyAssignment */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 246 /* ShorthandPropertyAssignment */:
+ case 211 /* VariableDeclaration */:
return true;
}
}
@@ -5499,29 +5674,29 @@ var ts;
}
ts.isVariableLike = isVariableLike;
function isAccessor(node) {
- return node && (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */);
+ return node && (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */);
}
ts.isAccessor = isAccessor;
function isClassLike(node) {
- return node && (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */);
+ return node && (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */);
}
ts.isClassLike = isClassLike;
function isFunctionLike(node) {
if (node) {
switch (node.kind) {
- case 142 /* Constructor */:
- case 171 /* FunctionExpression */:
- case 211 /* FunctionDeclaration */:
- case 172 /* ArrowFunction */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */:
- case 147 /* IndexSignature */:
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
+ case 144 /* Constructor */:
+ case 173 /* FunctionExpression */:
+ case 213 /* FunctionDeclaration */:
+ case 174 /* ArrowFunction */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 149 /* IndexSignature */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
return true;
}
}
@@ -5530,24 +5705,24 @@ var ts;
ts.isFunctionLike = isFunctionLike;
function introducesArgumentsExoticObject(node) {
switch (node.kind) {
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
return true;
}
return false;
}
ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject;
function isFunctionBlock(node) {
- return node && node.kind === 190 /* Block */ && isFunctionLike(node.parent);
+ return node && node.kind === 192 /* Block */ && isFunctionLike(node.parent);
}
ts.isFunctionBlock = isFunctionBlock;
function isObjectLiteralMethod(node) {
- return node && node.kind === 141 /* MethodDeclaration */ && node.parent.kind === 163 /* ObjectLiteralExpression */;
+ return node && node.kind === 143 /* MethodDeclaration */ && node.parent.kind === 165 /* ObjectLiteralExpression */;
}
ts.isObjectLiteralMethod = isObjectLiteralMethod;
function getContainingFunction(node) {
@@ -5575,7 +5750,7 @@ var ts;
return undefined;
}
switch (node.kind) {
- case 134 /* ComputedPropertyName */:
+ case 136 /* 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
@@ -5590,9 +5765,9 @@ var ts;
// the *body* of the container.
node = node.parent;
break;
- case 137 /* Decorator */:
+ case 139 /* Decorator */:
// Decorators are always applied outside of the body of a class or method.
- if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) {
+ if (node.parent.kind === 138 /* 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;
@@ -5603,23 +5778,26 @@ var ts;
node = node.parent;
}
break;
- case 172 /* ArrowFunction */:
+ case 174 /* ArrowFunction */:
if (!includeArrowFunctions) {
continue;
}
// Fall through
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 216 /* ModuleDeclaration */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 215 /* EnumDeclaration */:
- case 246 /* SourceFile */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 218 /* ModuleDeclaration */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 149 /* IndexSignature */:
+ case 217 /* EnumDeclaration */:
+ case 248 /* SourceFile */:
return node;
}
}
@@ -5631,7 +5809,7 @@ var ts;
if (!node)
return node;
switch (node.kind) {
- case 134 /* ComputedPropertyName */:
+ case 136 /* ComputedPropertyName */:
// If the grandparent node is an object literal (as opposed to a class),
// then the computed property is not a 'super' container.
// A computed property name in a class needs to be a super container
@@ -5646,9 +5824,9 @@ var ts;
// the *body* of the container.
node = node.parent;
break;
- case 137 /* Decorator */:
+ case 139 /* Decorator */:
// Decorators are always applied outside of the body of a class or method.
- if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) {
+ if (node.parent.kind === 138 /* 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;
@@ -5659,19 +5837,19 @@ var ts;
node = node.parent;
}
break;
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
if (!includeFunctions) {
continue;
}
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
return node;
}
}
@@ -5680,12 +5858,12 @@ var ts;
function getEntityNameFromTypeNode(node) {
if (node) {
switch (node.kind) {
- case 149 /* TypeReference */:
+ case 151 /* TypeReference */:
return node.typeName;
- case 186 /* ExpressionWithTypeArguments */:
+ case 188 /* ExpressionWithTypeArguments */:
return node.expression;
- case 67 /* Identifier */:
- case 133 /* QualifiedName */:
+ case 69 /* Identifier */:
+ case 135 /* QualifiedName */:
return node;
}
}
@@ -5693,7 +5871,7 @@ var ts;
}
ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode;
function getInvokedExpression(node) {
- if (node.kind === 168 /* TaggedTemplateExpression */) {
+ if (node.kind === 170 /* TaggedTemplateExpression */) {
return node.tag;
}
// Will either be a CallExpression, NewExpression, or Decorator.
@@ -5702,44 +5880,44 @@ var ts;
ts.getInvokedExpression = getInvokedExpression;
function nodeCanBeDecorated(node) {
switch (node.kind) {
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
// classes are valid targets
return true;
- case 139 /* PropertyDeclaration */:
+ case 141 /* PropertyDeclaration */:
// property declarations are valid if their parent is a class declaration.
- return node.parent.kind === 212 /* ClassDeclaration */;
- case 136 /* Parameter */:
+ return node.parent.kind === 214 /* ClassDeclaration */;
+ case 138 /* 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 && node.parent.parent.kind === 212 /* ClassDeclaration */;
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 141 /* MethodDeclaration */:
+ return node.parent.body && node.parent.parent.kind === 214 /* ClassDeclaration */;
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 143 /* MethodDeclaration */:
// if this method has a body and its parent is a class declaration, this is a valid target.
- return node.body && node.parent.kind === 212 /* ClassDeclaration */;
+ return node.body && node.parent.kind === 214 /* ClassDeclaration */;
}
return false;
}
ts.nodeCanBeDecorated = nodeCanBeDecorated;
function nodeIsDecorated(node) {
switch (node.kind) {
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
if (node.decorators) {
return true;
}
return false;
- case 139 /* PropertyDeclaration */:
- case 136 /* Parameter */:
+ case 141 /* PropertyDeclaration */:
+ case 138 /* Parameter */:
if (node.decorators) {
return true;
}
return false;
- case 143 /* GetAccessor */:
+ case 145 /* GetAccessor */:
if (node.body && node.decorators) {
return true;
}
return false;
- case 141 /* MethodDeclaration */:
- case 144 /* SetAccessor */:
+ case 143 /* MethodDeclaration */:
+ case 146 /* SetAccessor */:
if (node.body && node.decorators) {
return true;
}
@@ -5750,10 +5928,10 @@ var ts;
ts.nodeIsDecorated = nodeIsDecorated;
function childIsDecorated(node) {
switch (node.kind) {
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
return ts.forEach(node.members, nodeOrChildIsDecorated);
- case 141 /* MethodDeclaration */:
- case 144 /* SetAccessor */:
+ case 143 /* MethodDeclaration */:
+ case 146 /* SetAccessor */:
return ts.forEach(node.parameters, nodeIsDecorated);
}
return false;
@@ -5763,96 +5941,106 @@ var ts;
return nodeIsDecorated(node) || childIsDecorated(node);
}
ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated;
+ function isPropertyAccessExpression(node) {
+ return node.kind === 166 /* PropertyAccessExpression */;
+ }
+ ts.isPropertyAccessExpression = isPropertyAccessExpression;
+ function isElementAccessExpression(node) {
+ return node.kind === 167 /* ElementAccessExpression */;
+ }
+ ts.isElementAccessExpression = isElementAccessExpression;
function isExpression(node) {
switch (node.kind) {
- case 95 /* ThisKeyword */:
- case 93 /* SuperKeyword */:
- case 91 /* NullKeyword */:
- case 97 /* TrueKeyword */:
- case 82 /* FalseKeyword */:
+ case 95 /* SuperKeyword */:
+ case 93 /* NullKeyword */:
+ case 99 /* TrueKeyword */:
+ case 84 /* FalseKeyword */:
case 10 /* RegularExpressionLiteral */:
- case 162 /* ArrayLiteralExpression */:
- case 163 /* ObjectLiteralExpression */:
- case 164 /* PropertyAccessExpression */:
- case 165 /* ElementAccessExpression */:
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
- case 168 /* TaggedTemplateExpression */:
- case 187 /* AsExpression */:
- case 169 /* TypeAssertionExpression */:
- case 170 /* ParenthesizedExpression */:
- case 171 /* FunctionExpression */:
- case 184 /* ClassExpression */:
- case 172 /* ArrowFunction */:
- case 175 /* VoidExpression */:
- case 173 /* DeleteExpression */:
- case 174 /* TypeOfExpression */:
- case 177 /* PrefixUnaryExpression */:
- case 178 /* PostfixUnaryExpression */:
- case 179 /* BinaryExpression */:
- case 180 /* ConditionalExpression */:
- case 183 /* SpreadElementExpression */:
- case 181 /* TemplateExpression */:
+ case 164 /* ArrayLiteralExpression */:
+ case 165 /* ObjectLiteralExpression */:
+ case 166 /* PropertyAccessExpression */:
+ case 167 /* ElementAccessExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
+ case 170 /* TaggedTemplateExpression */:
+ case 189 /* AsExpression */:
+ case 171 /* TypeAssertionExpression */:
+ case 172 /* ParenthesizedExpression */:
+ case 173 /* FunctionExpression */:
+ case 186 /* ClassExpression */:
+ case 174 /* ArrowFunction */:
+ case 177 /* VoidExpression */:
+ case 175 /* DeleteExpression */:
+ case 176 /* TypeOfExpression */:
+ case 179 /* PrefixUnaryExpression */:
+ case 180 /* PostfixUnaryExpression */:
+ case 181 /* BinaryExpression */:
+ case 182 /* ConditionalExpression */:
+ case 185 /* SpreadElementExpression */:
+ case 183 /* TemplateExpression */:
case 11 /* NoSubstitutionTemplateLiteral */:
- case 185 /* OmittedExpression */:
- case 231 /* JsxElement */:
- case 232 /* JsxSelfClosingElement */:
- case 182 /* YieldExpression */:
+ case 187 /* OmittedExpression */:
+ case 233 /* JsxElement */:
+ case 234 /* JsxSelfClosingElement */:
+ case 184 /* YieldExpression */:
+ case 178 /* AwaitExpression */:
return true;
- case 133 /* QualifiedName */:
- while (node.parent.kind === 133 /* QualifiedName */) {
+ case 135 /* QualifiedName */:
+ while (node.parent.kind === 135 /* QualifiedName */) {
node = node.parent;
}
- return node.parent.kind === 152 /* TypeQuery */;
- case 67 /* Identifier */:
- if (node.parent.kind === 152 /* TypeQuery */) {
+ return node.parent.kind === 154 /* TypeQuery */;
+ case 69 /* Identifier */:
+ if (node.parent.kind === 154 /* TypeQuery */) {
return true;
}
// fall through
case 8 /* NumericLiteral */:
case 9 /* StringLiteral */:
+ case 97 /* ThisKeyword */:
var parent_2 = node.parent;
switch (parent_2.kind) {
- case 209 /* VariableDeclaration */:
- case 136 /* Parameter */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 245 /* EnumMember */:
- case 243 /* PropertyAssignment */:
- case 161 /* BindingElement */:
+ case 211 /* VariableDeclaration */:
+ case 138 /* Parameter */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 247 /* EnumMember */:
+ case 245 /* PropertyAssignment */:
+ case 163 /* BindingElement */:
return parent_2.initializer === node;
- case 193 /* ExpressionStatement */:
- case 194 /* IfStatement */:
- case 195 /* DoStatement */:
- case 196 /* WhileStatement */:
- case 202 /* ReturnStatement */:
- case 203 /* WithStatement */:
- case 204 /* SwitchStatement */:
- case 239 /* CaseClause */:
- case 206 /* ThrowStatement */:
- case 204 /* SwitchStatement */:
+ case 195 /* ExpressionStatement */:
+ case 196 /* IfStatement */:
+ case 197 /* DoStatement */:
+ case 198 /* WhileStatement */:
+ case 204 /* ReturnStatement */:
+ case 205 /* WithStatement */:
+ case 206 /* SwitchStatement */:
+ case 241 /* CaseClause */:
+ case 208 /* ThrowStatement */:
+ case 206 /* SwitchStatement */:
return parent_2.expression === node;
- case 197 /* ForStatement */:
+ case 199 /* ForStatement */:
var forStatement = parent_2;
- return (forStatement.initializer === node && forStatement.initializer.kind !== 210 /* VariableDeclarationList */) ||
+ return (forStatement.initializer === node && forStatement.initializer.kind !== 212 /* VariableDeclarationList */) ||
forStatement.condition === node ||
forStatement.incrementor === node;
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
var forInStatement = parent_2;
- return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210 /* VariableDeclarationList */) ||
+ return (forInStatement.initializer === node && forInStatement.initializer.kind !== 212 /* VariableDeclarationList */) ||
forInStatement.expression === node;
- case 169 /* TypeAssertionExpression */:
- case 187 /* AsExpression */:
+ case 171 /* TypeAssertionExpression */:
+ case 189 /* AsExpression */:
return node === parent_2.expression;
- case 188 /* TemplateSpan */:
+ case 190 /* TemplateSpan */:
return node === parent_2.expression;
- case 134 /* ComputedPropertyName */:
+ case 136 /* ComputedPropertyName */:
return node === parent_2.expression;
- case 137 /* Decorator */:
- case 238 /* JsxExpression */:
+ case 139 /* Decorator */:
+ case 240 /* JsxExpression */:
+ case 239 /* JsxSpreadAttribute */:
return true;
- case 186 /* ExpressionWithTypeArguments */:
+ case 188 /* ExpressionWithTypeArguments */:
return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2);
default:
if (isExpression(parent_2)) {
@@ -5863,6 +6051,12 @@ var ts;
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 */ ||
@@ -5870,7 +6064,7 @@ var ts;
}
ts.isInstantiatedModule = isInstantiatedModule;
function isExternalModuleImportEqualsDeclaration(node) {
- return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */;
+ return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */;
}
ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration;
function getExternalModuleImportEqualsDeclarationExpression(node) {
@@ -5879,20 +6073,20 @@ var ts;
}
ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
function isInternalModuleImportEqualsDeclaration(node) {
- return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 230 /* ExternalModuleReference */;
+ return node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 232 /* ExternalModuleReference */;
}
ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration;
function getExternalModuleName(node) {
- if (node.kind === 220 /* ImportDeclaration */) {
+ if (node.kind === 222 /* ImportDeclaration */) {
return node.moduleSpecifier;
}
- if (node.kind === 219 /* ImportEqualsDeclaration */) {
+ if (node.kind === 221 /* ImportEqualsDeclaration */) {
var reference = node.moduleReference;
- if (reference.kind === 230 /* ExternalModuleReference */) {
+ if (reference.kind === 232 /* ExternalModuleReference */) {
return reference.expression;
}
}
- if (node.kind === 226 /* ExportDeclaration */) {
+ if (node.kind === 228 /* ExportDeclaration */) {
return node.moduleSpecifier;
}
}
@@ -5900,13 +6094,13 @@ var ts;
function hasQuestionToken(node) {
if (node) {
switch (node.kind) {
- case 136 /* Parameter */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 244 /* ShorthandPropertyAssignment */:
- case 243 /* PropertyAssignment */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
+ case 138 /* Parameter */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 246 /* ShorthandPropertyAssignment */:
+ case 245 /* PropertyAssignment */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
return node.questionToken !== undefined;
}
}
@@ -5914,9 +6108,9 @@ var ts;
}
ts.hasQuestionToken = hasQuestionToken;
function isJSDocConstructSignature(node) {
- return node.kind === 259 /* JSDocFunctionType */ &&
+ return node.kind === 261 /* JSDocFunctionType */ &&
node.parameters.length > 0 &&
- node.parameters[0].type.kind === 261 /* JSDocConstructorType */;
+ node.parameters[0].type.kind === 263 /* JSDocConstructorType */;
}
ts.isJSDocConstructSignature = isJSDocConstructSignature;
function getJSDocTag(node, kind) {
@@ -5930,26 +6124,26 @@ var ts;
}
}
function getJSDocTypeTag(node) {
- return getJSDocTag(node, 267 /* JSDocTypeTag */);
+ return getJSDocTag(node, 269 /* JSDocTypeTag */);
}
ts.getJSDocTypeTag = getJSDocTypeTag;
function getJSDocReturnTag(node) {
- return getJSDocTag(node, 266 /* JSDocReturnTag */);
+ return getJSDocTag(node, 268 /* JSDocReturnTag */);
}
ts.getJSDocReturnTag = getJSDocReturnTag;
function getJSDocTemplateTag(node) {
- return getJSDocTag(node, 268 /* JSDocTemplateTag */);
+ return getJSDocTag(node, 270 /* JSDocTemplateTag */);
}
ts.getJSDocTemplateTag = getJSDocTemplateTag;
function getCorrespondingJSDocParameterTag(parameter) {
- if (parameter.name && parameter.name.kind === 67 /* Identifier */) {
+ 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 docComment = parameter.parent.jsDocComment;
if (docComment) {
return ts.forEach(docComment.tags, function (t) {
- if (t.kind === 265 /* JSDocParameterTag */) {
+ if (t.kind === 267 /* JSDocParameterTag */) {
var parameterTag = t;
var name_6 = parameterTag.preParameterName || parameterTag.postParameterName;
if (name_6.text === parameterName) {
@@ -5968,12 +6162,12 @@ var ts;
function isRestParameter(node) {
if (node) {
if (node.parserContextFlags & 32 /* JavaScriptFile */) {
- if (node.type && node.type.kind === 260 /* JSDocVariadicType */) {
+ if (node.type && node.type.kind === 262 /* JSDocVariadicType */) {
return true;
}
var paramTag = getCorrespondingJSDocParameterTag(node);
if (paramTag && paramTag.typeExpression) {
- return paramTag.typeExpression.type.kind === 260 /* JSDocVariadicType */;
+ return paramTag.typeExpression.type.kind === 262 /* JSDocVariadicType */;
}
}
return node.dotDotDotToken !== undefined;
@@ -5994,9 +6188,18 @@ var ts;
}
ts.isTemplateLiteralKind = isTemplateLiteralKind;
function isBindingPattern(node) {
- return !!node && (node.kind === 160 /* ArrayBindingPattern */ || node.kind === 159 /* ObjectBindingPattern */);
+ return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* 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 & (2 /* Ambient */ | 8192 /* DeclarationFile */)) {
@@ -6009,34 +6212,34 @@ var ts;
ts.isInAmbientContext = isInAmbientContext;
function isDeclaration(node) {
switch (node.kind) {
- case 172 /* ArrowFunction */:
- case 161 /* BindingElement */:
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
- case 142 /* Constructor */:
- case 215 /* EnumDeclaration */:
- case 245 /* EnumMember */:
- case 228 /* ExportSpecifier */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 143 /* GetAccessor */:
- case 221 /* ImportClause */:
- case 219 /* ImportEqualsDeclaration */:
- case 224 /* ImportSpecifier */:
- case 213 /* InterfaceDeclaration */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 216 /* ModuleDeclaration */:
- case 222 /* NamespaceImport */:
- case 136 /* Parameter */:
- case 243 /* PropertyAssignment */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 144 /* SetAccessor */:
- case 244 /* ShorthandPropertyAssignment */:
- case 214 /* TypeAliasDeclaration */:
- case 135 /* TypeParameter */:
- case 209 /* VariableDeclaration */:
+ case 174 /* ArrowFunction */:
+ case 163 /* BindingElement */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
+ case 144 /* Constructor */:
+ case 217 /* EnumDeclaration */:
+ case 247 /* EnumMember */:
+ case 230 /* ExportSpecifier */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 145 /* GetAccessor */:
+ case 223 /* ImportClause */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 226 /* ImportSpecifier */:
+ case 215 /* InterfaceDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 218 /* ModuleDeclaration */:
+ case 224 /* NamespaceImport */:
+ case 138 /* Parameter */:
+ case 245 /* PropertyAssignment */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 146 /* SetAccessor */:
+ case 246 /* ShorthandPropertyAssignment */:
+ case 216 /* TypeAliasDeclaration */:
+ case 137 /* TypeParameter */:
+ case 211 /* VariableDeclaration */:
return true;
}
return false;
@@ -6044,25 +6247,25 @@ var ts;
ts.isDeclaration = isDeclaration;
function isStatement(n) {
switch (n.kind) {
- case 201 /* BreakStatement */:
- case 200 /* ContinueStatement */:
- case 208 /* DebuggerStatement */:
- case 195 /* DoStatement */:
- case 193 /* ExpressionStatement */:
- case 192 /* EmptyStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 197 /* ForStatement */:
- case 194 /* IfStatement */:
- case 205 /* LabeledStatement */:
- case 202 /* ReturnStatement */:
- case 204 /* SwitchStatement */:
- case 96 /* ThrowKeyword */:
- case 207 /* TryStatement */:
- case 191 /* VariableStatement */:
- case 196 /* WhileStatement */:
- case 203 /* WithStatement */:
- case 225 /* ExportAssignment */:
+ case 203 /* BreakStatement */:
+ case 202 /* ContinueStatement */:
+ case 210 /* DebuggerStatement */:
+ case 197 /* DoStatement */:
+ case 195 /* ExpressionStatement */:
+ case 194 /* EmptyStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 199 /* ForStatement */:
+ case 196 /* IfStatement */:
+ case 207 /* LabeledStatement */:
+ case 204 /* ReturnStatement */:
+ case 206 /* SwitchStatement */:
+ case 98 /* ThrowKeyword */:
+ case 209 /* TryStatement */:
+ case 193 /* VariableStatement */:
+ case 198 /* WhileStatement */:
+ case 205 /* WithStatement */:
+ case 227 /* ExportAssignment */:
return true;
default:
return false;
@@ -6071,13 +6274,13 @@ var ts;
ts.isStatement = isStatement;
function isClassElement(n) {
switch (n.kind) {
- case 142 /* Constructor */:
- case 139 /* PropertyDeclaration */:
- case 141 /* MethodDeclaration */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 140 /* MethodSignature */:
- case 147 /* IndexSignature */:
+ case 144 /* Constructor */:
+ case 141 /* PropertyDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 142 /* MethodSignature */:
+ case 149 /* IndexSignature */:
return true;
default:
return false;
@@ -6086,11 +6289,11 @@ var ts;
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 !== 67 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) {
+ if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) {
return false;
}
var parent = name.parent;
- if (parent.kind === 224 /* ImportSpecifier */ || parent.kind === 228 /* ExportSpecifier */) {
+ if (parent.kind === 226 /* ImportSpecifier */ || parent.kind === 230 /* ExportSpecifier */) {
if (parent.propertyName) {
return true;
}
@@ -6105,31 +6308,31 @@ var ts;
function isIdentifierName(node) {
var parent = node.parent;
switch (parent.kind) {
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 245 /* EnumMember */:
- case 243 /* PropertyAssignment */:
- case 164 /* PropertyAccessExpression */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 247 /* EnumMember */:
+ case 245 /* PropertyAssignment */:
+ case 166 /* PropertyAccessExpression */:
// Name in member declaration or property name in property access
return parent.name === node;
- case 133 /* QualifiedName */:
+ case 135 /* QualifiedName */:
// Name on right hand side of dot in a type query
if (parent.right === node) {
- while (parent.kind === 133 /* QualifiedName */) {
+ while (parent.kind === 135 /* QualifiedName */) {
parent = parent.parent;
}
- return parent.kind === 152 /* TypeQuery */;
+ return parent.kind === 154 /* TypeQuery */;
}
return false;
- case 161 /* BindingElement */:
- case 224 /* ImportSpecifier */:
+ case 163 /* BindingElement */:
+ case 226 /* ImportSpecifier */:
// Property name in binding element or import specifier
return parent.propertyName === node;
- case 228 /* ExportSpecifier */:
+ case 230 /* ExportSpecifier */:
// Any name in an export specifier
return true;
}
@@ -6145,26 +6348,26 @@ var ts;
// export = ...
// export default ...
function isAliasSymbolDeclaration(node) {
- return node.kind === 219 /* ImportEqualsDeclaration */ ||
- node.kind === 221 /* ImportClause */ && !!node.name ||
- node.kind === 222 /* NamespaceImport */ ||
- node.kind === 224 /* ImportSpecifier */ ||
- node.kind === 228 /* ExportSpecifier */ ||
- node.kind === 225 /* ExportAssignment */ && node.expression.kind === 67 /* Identifier */;
+ return node.kind === 221 /* ImportEqualsDeclaration */ ||
+ node.kind === 223 /* ImportClause */ && !!node.name ||
+ node.kind === 224 /* NamespaceImport */ ||
+ node.kind === 226 /* ImportSpecifier */ ||
+ node.kind === 230 /* ExportSpecifier */ ||
+ node.kind === 227 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */;
}
ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
function getClassExtendsHeritageClauseElement(node) {
- var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */);
+ 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, 104 /* ImplementsKeyword */);
+ var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */);
return heritageClause ? heritageClause.types : undefined;
}
ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements;
function getInterfaceBaseTypeNodes(node) {
- var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */);
+ var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */);
return heritageClause ? heritageClause.types : undefined;
}
ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes;
@@ -6233,7 +6436,7 @@ var ts;
}
ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath;
function isKeyword(token) {
- return 68 /* FirstKeyword */ <= token && token <= 132 /* LastKeyword */;
+ return 70 /* FirstKeyword */ <= token && token <= 134 /* LastKeyword */;
}
ts.isKeyword = isKeyword;
function isTrivia(token) {
@@ -6253,7 +6456,7 @@ var ts;
*/
function hasDynamicName(declaration) {
return declaration.name &&
- declaration.name.kind === 134 /* ComputedPropertyName */ &&
+ declaration.name.kind === 136 /* ComputedPropertyName */ &&
!isWellKnownSymbolSyntactically(declaration.name.expression);
}
ts.hasDynamicName = hasDynamicName;
@@ -6263,14 +6466,14 @@ var ts;
* where Symbol is literally the word "Symbol", and name is any identifierName
*/
function isWellKnownSymbolSyntactically(node) {
- return node.kind === 164 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression);
+ return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression);
}
ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically;
function getPropertyNameForPropertyNameNode(name) {
- if (name.kind === 67 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) {
+ if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) {
return name.text;
}
- if (name.kind === 134 /* ComputedPropertyName */) {
+ if (name.kind === 136 /* ComputedPropertyName */) {
var nameExpression = name.expression;
if (isWellKnownSymbolSyntactically(nameExpression)) {
var rightHandSideName = nameExpression.name.text;
@@ -6288,21 +6491,21 @@ var ts;
* Includes the word "Symbol" with unicode escapes
*/
function isESSymbolIdentifier(node) {
- return node.kind === 67 /* Identifier */ && node.text === "Symbol";
+ return node.kind === 69 /* Identifier */ && node.text === "Symbol";
}
ts.isESSymbolIdentifier = isESSymbolIdentifier;
function isModifier(token) {
switch (token) {
- case 113 /* AbstractKeyword */:
- case 116 /* AsyncKeyword */:
- case 72 /* ConstKeyword */:
- case 120 /* DeclareKeyword */:
- case 75 /* DefaultKeyword */:
- case 80 /* ExportKeyword */:
- case 110 /* PublicKeyword */:
- case 108 /* PrivateKeyword */:
- case 109 /* ProtectedKeyword */:
- case 111 /* StaticKeyword */:
+ 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;
@@ -6310,28 +6513,28 @@ var ts;
ts.isModifier = isModifier;
function isParameterDeclaration(node) {
var root = getRootDeclaration(node);
- return root.kind === 136 /* Parameter */;
+ return root.kind === 138 /* Parameter */;
}
ts.isParameterDeclaration = isParameterDeclaration;
function getRootDeclaration(node) {
- while (node.kind === 161 /* BindingElement */) {
+ while (node.kind === 163 /* BindingElement */) {
node = node.parent.parent;
}
return node;
}
ts.getRootDeclaration = getRootDeclaration;
function nodeStartsNewLexicalEnvironment(n) {
- return isFunctionLike(n) || n.kind === 216 /* ModuleDeclaration */ || n.kind === 246 /* SourceFile */;
+ return isFunctionLike(n) || n.kind === 218 /* ModuleDeclaration */ || n.kind === 248 /* SourceFile */;
}
ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment;
function cloneEntityName(node) {
- if (node.kind === 67 /* Identifier */) {
- var clone_1 = createSynthesizedNode(67 /* Identifier */);
+ if (node.kind === 69 /* Identifier */) {
+ var clone_1 = createSynthesizedNode(69 /* Identifier */);
clone_1.text = node.text;
return clone_1;
}
else {
- var clone_2 = createSynthesizedNode(133 /* QualifiedName */);
+ var clone_2 = createSynthesizedNode(135 /* QualifiedName */);
clone_2.left = cloneEntityName(node.left);
clone_2.left.parent = clone_2;
clone_2.right = cloneEntityName(node.right);
@@ -6586,7 +6789,7 @@ var ts;
ts.getLineOfLocalPosition = getLineOfLocalPosition;
function getFirstConstructorWithBody(node) {
return ts.forEach(node.members, function (member) {
- if (member.kind === 142 /* Constructor */ && nodeIsPresent(member.body)) {
+ if (member.kind === 144 /* Constructor */ && nodeIsPresent(member.body)) {
return member;
}
});
@@ -6615,10 +6818,10 @@ var ts;
var setAccessor;
if (hasDynamicName(accessor)) {
firstAccessor = accessor;
- if (accessor.kind === 143 /* GetAccessor */) {
+ if (accessor.kind === 145 /* GetAccessor */) {
getAccessor = accessor;
}
- else if (accessor.kind === 144 /* SetAccessor */) {
+ else if (accessor.kind === 146 /* SetAccessor */) {
setAccessor = accessor;
}
else {
@@ -6627,7 +6830,7 @@ var ts;
}
else {
ts.forEach(declarations, function (member) {
- if ((member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */)
+ if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */)
&& (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) {
var memberName = getPropertyNameForPropertyNameNode(member.name);
var accessorName = getPropertyNameForPropertyNameNode(accessor.name);
@@ -6638,10 +6841,10 @@ var ts;
else if (!secondAccessor) {
secondAccessor = member;
}
- if (member.kind === 143 /* GetAccessor */ && !getAccessor) {
+ if (member.kind === 145 /* GetAccessor */ && !getAccessor) {
getAccessor = member;
}
- if (member.kind === 144 /* SetAccessor */ && !setAccessor) {
+ if (member.kind === 146 /* SetAccessor */ && !setAccessor) {
setAccessor = member;
}
}
@@ -6774,16 +6977,16 @@ var ts;
ts.writeCommentRange = writeCommentRange;
function modifierToFlag(token) {
switch (token) {
- case 111 /* StaticKeyword */: return 128 /* Static */;
- case 110 /* PublicKeyword */: return 16 /* Public */;
- case 109 /* ProtectedKeyword */: return 64 /* Protected */;
- case 108 /* PrivateKeyword */: return 32 /* Private */;
- case 113 /* AbstractKeyword */: return 256 /* Abstract */;
- case 80 /* ExportKeyword */: return 1 /* Export */;
- case 120 /* DeclareKeyword */: return 2 /* Ambient */;
- case 72 /* ConstKeyword */: return 32768 /* Const */;
- case 75 /* DefaultKeyword */: return 1024 /* Default */;
- case 116 /* AsyncKeyword */: return 512 /* Async */;
+ case 113 /* StaticKeyword */: return 128 /* Static */;
+ case 112 /* PublicKeyword */: return 16 /* Public */;
+ case 111 /* ProtectedKeyword */: return 64 /* Protected */;
+ case 110 /* PrivateKeyword */: return 32 /* Private */;
+ case 115 /* AbstractKeyword */: return 256 /* Abstract */;
+ case 82 /* ExportKeyword */: return 1 /* Export */;
+ case 122 /* DeclareKeyword */: return 2 /* Ambient */;
+ case 74 /* ConstKeyword */: return 32768 /* Const */;
+ case 77 /* DefaultKeyword */: return 1024 /* Default */;
+ case 118 /* AsyncKeyword */: return 512 /* Async */;
}
return 0;
}
@@ -6791,29 +6994,29 @@ var ts;
function isLeftHandSideExpression(expr) {
if (expr) {
switch (expr.kind) {
- case 164 /* PropertyAccessExpression */:
- case 165 /* ElementAccessExpression */:
- case 167 /* NewExpression */:
- case 166 /* CallExpression */:
- case 231 /* JsxElement */:
- case 232 /* JsxSelfClosingElement */:
- case 168 /* TaggedTemplateExpression */:
- case 162 /* ArrayLiteralExpression */:
- case 170 /* ParenthesizedExpression */:
- case 163 /* ObjectLiteralExpression */:
- case 184 /* ClassExpression */:
- case 171 /* FunctionExpression */:
- case 67 /* Identifier */:
+ case 166 /* PropertyAccessExpression */:
+ case 167 /* ElementAccessExpression */:
+ case 169 /* NewExpression */:
+ case 168 /* CallExpression */:
+ case 233 /* JsxElement */:
+ case 234 /* JsxSelfClosingElement */:
+ case 170 /* TaggedTemplateExpression */:
+ case 164 /* ArrayLiteralExpression */:
+ case 172 /* ParenthesizedExpression */:
+ case 165 /* ObjectLiteralExpression */:
+ case 186 /* ClassExpression */:
+ case 173 /* FunctionExpression */:
+ case 69 /* Identifier */:
case 10 /* RegularExpressionLiteral */:
case 8 /* NumericLiteral */:
case 9 /* StringLiteral */:
case 11 /* NoSubstitutionTemplateLiteral */:
- case 181 /* TemplateExpression */:
- case 82 /* FalseKeyword */:
- case 91 /* NullKeyword */:
- case 95 /* ThisKeyword */:
- case 97 /* TrueKeyword */:
- case 93 /* SuperKeyword */:
+ case 183 /* TemplateExpression */:
+ case 84 /* FalseKeyword */:
+ case 93 /* NullKeyword */:
+ case 97 /* ThisKeyword */:
+ case 99 /* TrueKeyword */:
+ case 95 /* SuperKeyword */:
return true;
}
}
@@ -6821,12 +7024,12 @@ var ts;
}
ts.isLeftHandSideExpression = isLeftHandSideExpression;
function isAssignmentOperator(token) {
- return token >= 55 /* FirstAssignment */ && token <= 66 /* LastAssignment */;
+ return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */;
}
ts.isAssignmentOperator = isAssignmentOperator;
function isExpressionWithTypeArgumentsInClassExtendsClause(node) {
- return node.kind === 186 /* ExpressionWithTypeArguments */ &&
- node.parent.token === 81 /* ExtendsKeyword */ &&
+ return node.kind === 188 /* ExpressionWithTypeArguments */ &&
+ node.parent.token === 83 /* ExtendsKeyword */ &&
isClassLike(node.parent.parent);
}
ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause;
@@ -6837,10 +7040,10 @@ var ts;
}
ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments;
function isSupportedExpressionWithTypeArgumentsRest(node) {
- if (node.kind === 67 /* Identifier */) {
+ if (node.kind === 69 /* Identifier */) {
return true;
}
- else if (node.kind === 164 /* PropertyAccessExpression */) {
+ else if (isPropertyAccessExpression(node)) {
return isSupportedExpressionWithTypeArgumentsRest(node.expression);
}
else {
@@ -6848,16 +7051,16 @@ var ts;
}
}
function isRightSideOfQualifiedNameOrPropertyAccess(node) {
- return (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) ||
- (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node);
+ return (node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node) ||
+ (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node);
}
ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
function isEmptyObjectLiteralOrArrayLiteral(expression) {
var kind = expression.kind;
- if (kind === 163 /* ObjectLiteralExpression */) {
+ if (kind === 165 /* ObjectLiteralExpression */) {
return expression.properties.length === 0;
}
- if (kind === 162 /* ArrayLiteralExpression */) {
+ if (kind === 164 /* ArrayLiteralExpression */) {
return expression.elements.length === 0;
}
return false;
@@ -7169,21 +7372,31 @@ var ts;
}
ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
function getTypeParameterOwner(d) {
- if (d && d.kind === 135 /* TypeParameter */) {
+ if (d && d.kind === 137 /* TypeParameter */) {
for (var current = d; current; current = current.parent) {
- if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213 /* InterfaceDeclaration */) {
+ if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 215 /* InterfaceDeclaration */) {
return current;
}
}
}
}
ts.getTypeParameterOwner = getTypeParameterOwner;
+ function arrayStructurallyIsEqualTo(array1, array2) {
+ if (!array1 || !array2) {
+ return false;
+ }
+ if (array1.length !== array2.length) {
+ return false;
+ }
+ return ts.arrayIsEqualTo(array1.sort(), array2.sort());
+ }
+ ts.arrayStructurallyIsEqualTo = arrayStructurallyIsEqualTo;
})(ts || (ts = {}));
///
///
var ts;
(function (ts) {
- var nodeConstructors = new Array(270 /* Count */);
+ var nodeConstructors = new Array(272 /* Count */);
/* @internal */ ts.parseTime = 0;
function getNodeConstructor(kind) {
return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind));
@@ -7228,20 +7441,26 @@ var ts;
var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode;
var cbNodes = cbNodeArray || cbNode;
switch (node.kind) {
- case 133 /* QualifiedName */:
+ case 135 /* QualifiedName */:
return visitNode(cbNode, node.left) ||
visitNode(cbNode, node.right);
- case 135 /* TypeParameter */:
+ case 137 /* TypeParameter */:
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.constraint) ||
visitNode(cbNode, node.expression);
- case 136 /* Parameter */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 243 /* PropertyAssignment */:
- case 244 /* ShorthandPropertyAssignment */:
- case 209 /* VariableDeclaration */:
- case 161 /* BindingElement */:
+ case 246 /* 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 138 /* Parameter */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 245 /* PropertyAssignment */:
+ case 211 /* VariableDeclaration */:
+ case 163 /* BindingElement */:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, node.propertyName) ||
@@ -7250,24 +7469,24 @@ var ts;
visitNode(cbNode, node.questionToken) ||
visitNode(cbNode, node.type) ||
visitNode(cbNode, node.initializer);
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */:
- case 147 /* IndexSignature */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 149 /* IndexSignature */:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNodes(cbNodes, node.typeParameters) ||
visitNodes(cbNodes, node.parameters) ||
visitNode(cbNode, node.type);
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 171 /* FunctionExpression */:
- case 211 /* FunctionDeclaration */:
- case 172 /* ArrowFunction */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 173 /* FunctionExpression */:
+ case 213 /* FunctionDeclaration */:
+ case 174 /* ArrowFunction */:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, node.asteriskToken) ||
@@ -7278,290 +7497,290 @@ var ts;
visitNode(cbNode, node.type) ||
visitNode(cbNode, node.equalsGreaterThanToken) ||
visitNode(cbNode, node.body);
- case 149 /* TypeReference */:
+ case 151 /* TypeReference */:
return visitNode(cbNode, node.typeName) ||
visitNodes(cbNodes, node.typeArguments);
- case 148 /* TypePredicate */:
+ case 150 /* TypePredicate */:
return visitNode(cbNode, node.parameterName) ||
visitNode(cbNode, node.type);
- case 152 /* TypeQuery */:
+ case 154 /* TypeQuery */:
return visitNode(cbNode, node.exprName);
- case 153 /* TypeLiteral */:
+ case 155 /* TypeLiteral */:
return visitNodes(cbNodes, node.members);
- case 154 /* ArrayType */:
+ case 156 /* ArrayType */:
return visitNode(cbNode, node.elementType);
- case 155 /* TupleType */:
+ case 157 /* TupleType */:
return visitNodes(cbNodes, node.elementTypes);
- case 156 /* UnionType */:
- case 157 /* IntersectionType */:
+ case 158 /* UnionType */:
+ case 159 /* IntersectionType */:
return visitNodes(cbNodes, node.types);
- case 158 /* ParenthesizedType */:
+ case 160 /* ParenthesizedType */:
return visitNode(cbNode, node.type);
- case 159 /* ObjectBindingPattern */:
- case 160 /* ArrayBindingPattern */:
+ case 161 /* ObjectBindingPattern */:
+ case 162 /* ArrayBindingPattern */:
return visitNodes(cbNodes, node.elements);
- case 162 /* ArrayLiteralExpression */:
+ case 164 /* ArrayLiteralExpression */:
return visitNodes(cbNodes, node.elements);
- case 163 /* ObjectLiteralExpression */:
+ case 165 /* ObjectLiteralExpression */:
return visitNodes(cbNodes, node.properties);
- case 164 /* PropertyAccessExpression */:
+ case 166 /* PropertyAccessExpression */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.dotToken) ||
visitNode(cbNode, node.name);
- case 165 /* ElementAccessExpression */:
+ case 167 /* ElementAccessExpression */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.argumentExpression);
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
return visitNode(cbNode, node.expression) ||
visitNodes(cbNodes, node.typeArguments) ||
visitNodes(cbNodes, node.arguments);
- case 168 /* TaggedTemplateExpression */:
+ case 170 /* TaggedTemplateExpression */:
return visitNode(cbNode, node.tag) ||
visitNode(cbNode, node.template);
- case 169 /* TypeAssertionExpression */:
+ case 171 /* TypeAssertionExpression */:
return visitNode(cbNode, node.type) ||
visitNode(cbNode, node.expression);
- case 170 /* ParenthesizedExpression */:
+ case 172 /* ParenthesizedExpression */:
return visitNode(cbNode, node.expression);
- case 173 /* DeleteExpression */:
+ case 175 /* DeleteExpression */:
return visitNode(cbNode, node.expression);
- case 174 /* TypeOfExpression */:
+ case 176 /* TypeOfExpression */:
return visitNode(cbNode, node.expression);
- case 175 /* VoidExpression */:
+ case 177 /* VoidExpression */:
return visitNode(cbNode, node.expression);
- case 177 /* PrefixUnaryExpression */:
+ case 179 /* PrefixUnaryExpression */:
return visitNode(cbNode, node.operand);
- case 182 /* YieldExpression */:
+ case 184 /* YieldExpression */:
return visitNode(cbNode, node.asteriskToken) ||
visitNode(cbNode, node.expression);
- case 176 /* AwaitExpression */:
+ case 178 /* AwaitExpression */:
return visitNode(cbNode, node.expression);
- case 178 /* PostfixUnaryExpression */:
+ case 180 /* PostfixUnaryExpression */:
return visitNode(cbNode, node.operand);
- case 179 /* BinaryExpression */:
+ case 181 /* BinaryExpression */:
return visitNode(cbNode, node.left) ||
visitNode(cbNode, node.operatorToken) ||
visitNode(cbNode, node.right);
- case 187 /* AsExpression */:
+ case 189 /* AsExpression */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.type);
- case 180 /* ConditionalExpression */:
+ case 182 /* ConditionalExpression */:
return visitNode(cbNode, node.condition) ||
visitNode(cbNode, node.questionToken) ||
visitNode(cbNode, node.whenTrue) ||
visitNode(cbNode, node.colonToken) ||
visitNode(cbNode, node.whenFalse);
- case 183 /* SpreadElementExpression */:
+ case 185 /* SpreadElementExpression */:
return visitNode(cbNode, node.expression);
- case 190 /* Block */:
- case 217 /* ModuleBlock */:
+ case 192 /* Block */:
+ case 219 /* ModuleBlock */:
return visitNodes(cbNodes, node.statements);
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
return visitNodes(cbNodes, node.statements) ||
visitNode(cbNode, node.endOfFileToken);
- case 191 /* VariableStatement */:
+ case 193 /* VariableStatement */:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, node.declarationList);
- case 210 /* VariableDeclarationList */:
+ case 212 /* VariableDeclarationList */:
return visitNodes(cbNodes, node.declarations);
- case 193 /* ExpressionStatement */:
+ case 195 /* ExpressionStatement */:
return visitNode(cbNode, node.expression);
- case 194 /* IfStatement */:
+ case 196 /* IfStatement */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.thenStatement) ||
visitNode(cbNode, node.elseStatement);
- case 195 /* DoStatement */:
+ case 197 /* DoStatement */:
return visitNode(cbNode, node.statement) ||
visitNode(cbNode, node.expression);
- case 196 /* WhileStatement */:
+ case 198 /* WhileStatement */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.statement);
- case 197 /* ForStatement */:
+ case 199 /* ForStatement */:
return visitNode(cbNode, node.initializer) ||
visitNode(cbNode, node.condition) ||
visitNode(cbNode, node.incrementor) ||
visitNode(cbNode, node.statement);
- case 198 /* ForInStatement */:
+ case 200 /* ForInStatement */:
return visitNode(cbNode, node.initializer) ||
visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.statement);
- case 199 /* ForOfStatement */:
+ case 201 /* ForOfStatement */:
return visitNode(cbNode, node.initializer) ||
visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.statement);
- case 200 /* ContinueStatement */:
- case 201 /* BreakStatement */:
+ case 202 /* ContinueStatement */:
+ case 203 /* BreakStatement */:
return visitNode(cbNode, node.label);
- case 202 /* ReturnStatement */:
+ case 204 /* ReturnStatement */:
return visitNode(cbNode, node.expression);
- case 203 /* WithStatement */:
+ case 205 /* WithStatement */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.statement);
- case 204 /* SwitchStatement */:
+ case 206 /* SwitchStatement */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.caseBlock);
- case 218 /* CaseBlock */:
+ case 220 /* CaseBlock */:
return visitNodes(cbNodes, node.clauses);
- case 239 /* CaseClause */:
+ case 241 /* CaseClause */:
return visitNode(cbNode, node.expression) ||
visitNodes(cbNodes, node.statements);
- case 240 /* DefaultClause */:
+ case 242 /* DefaultClause */:
return visitNodes(cbNodes, node.statements);
- case 205 /* LabeledStatement */:
+ case 207 /* LabeledStatement */:
return visitNode(cbNode, node.label) ||
visitNode(cbNode, node.statement);
- case 206 /* ThrowStatement */:
+ case 208 /* ThrowStatement */:
return visitNode(cbNode, node.expression);
- case 207 /* TryStatement */:
+ case 209 /* TryStatement */:
return visitNode(cbNode, node.tryBlock) ||
visitNode(cbNode, node.catchClause) ||
visitNode(cbNode, node.finallyBlock);
- case 242 /* CatchClause */:
+ case 244 /* CatchClause */:
return visitNode(cbNode, node.variableDeclaration) ||
visitNode(cbNode, node.block);
- case 137 /* Decorator */:
+ case 139 /* Decorator */:
return visitNode(cbNode, node.expression);
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* 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 213 /* InterfaceDeclaration */:
+ case 215 /* 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 214 /* TypeAliasDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
visitNodes(cbNodes, node.typeParameters) ||
visitNode(cbNode, node.type);
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
visitNodes(cbNodes, node.members);
- case 245 /* EnumMember */:
+ case 247 /* EnumMember */:
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.initializer);
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
visitNode(cbNode, node.body);
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
visitNode(cbNode, node.moduleReference);
- case 220 /* ImportDeclaration */:
+ case 222 /* ImportDeclaration */:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, node.importClause) ||
visitNode(cbNode, node.moduleSpecifier);
- case 221 /* ImportClause */:
+ case 223 /* ImportClause */:
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.namedBindings);
- case 222 /* NamespaceImport */:
+ case 224 /* NamespaceImport */:
return visitNode(cbNode, node.name);
- case 223 /* NamedImports */:
- case 227 /* NamedExports */:
+ case 225 /* NamedImports */:
+ case 229 /* NamedExports */:
return visitNodes(cbNodes, node.elements);
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, node.exportClause) ||
visitNode(cbNode, node.moduleSpecifier);
- case 224 /* ImportSpecifier */:
- case 228 /* ExportSpecifier */:
+ case 226 /* ImportSpecifier */:
+ case 230 /* ExportSpecifier */:
return visitNode(cbNode, node.propertyName) ||
visitNode(cbNode, node.name);
- case 225 /* ExportAssignment */:
+ case 227 /* ExportAssignment */:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, node.expression);
- case 181 /* TemplateExpression */:
+ case 183 /* TemplateExpression */:
return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans);
- case 188 /* TemplateSpan */:
+ case 190 /* TemplateSpan */:
return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal);
- case 134 /* ComputedPropertyName */:
+ case 136 /* ComputedPropertyName */:
return visitNode(cbNode, node.expression);
- case 241 /* HeritageClause */:
+ case 243 /* HeritageClause */:
return visitNodes(cbNodes, node.types);
- case 186 /* ExpressionWithTypeArguments */:
+ case 188 /* ExpressionWithTypeArguments */:
return visitNode(cbNode, node.expression) ||
visitNodes(cbNodes, node.typeArguments);
- case 230 /* ExternalModuleReference */:
+ case 232 /* ExternalModuleReference */:
return visitNode(cbNode, node.expression);
- case 229 /* MissingDeclaration */:
+ case 231 /* MissingDeclaration */:
return visitNodes(cbNodes, node.decorators);
- case 231 /* JsxElement */:
+ case 233 /* JsxElement */:
return visitNode(cbNode, node.openingElement) ||
visitNodes(cbNodes, node.children) ||
visitNode(cbNode, node.closingElement);
- case 232 /* JsxSelfClosingElement */:
- case 233 /* JsxOpeningElement */:
+ case 234 /* JsxSelfClosingElement */:
+ case 235 /* JsxOpeningElement */:
return visitNode(cbNode, node.tagName) ||
visitNodes(cbNodes, node.attributes);
- case 236 /* JsxAttribute */:
+ case 238 /* JsxAttribute */:
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.initializer);
- case 237 /* JsxSpreadAttribute */:
+ case 239 /* JsxSpreadAttribute */:
return visitNode(cbNode, node.expression);
- case 238 /* JsxExpression */:
+ case 240 /* JsxExpression */:
return visitNode(cbNode, node.expression);
- case 235 /* JsxClosingElement */:
+ case 237 /* JsxClosingElement */:
return visitNode(cbNode, node.tagName);
- case 247 /* JSDocTypeExpression */:
+ case 249 /* JSDocTypeExpression */:
return visitNode(cbNode, node.type);
- case 251 /* JSDocUnionType */:
+ case 253 /* JSDocUnionType */:
return visitNodes(cbNodes, node.types);
- case 252 /* JSDocTupleType */:
+ case 254 /* JSDocTupleType */:
return visitNodes(cbNodes, node.types);
- case 250 /* JSDocArrayType */:
+ case 252 /* JSDocArrayType */:
return visitNode(cbNode, node.elementType);
- case 254 /* JSDocNonNullableType */:
+ case 256 /* JSDocNonNullableType */:
return visitNode(cbNode, node.type);
- case 253 /* JSDocNullableType */:
+ case 255 /* JSDocNullableType */:
return visitNode(cbNode, node.type);
- case 255 /* JSDocRecordType */:
+ case 257 /* JSDocRecordType */:
return visitNodes(cbNodes, node.members);
- case 257 /* JSDocTypeReference */:
+ case 259 /* JSDocTypeReference */:
return visitNode(cbNode, node.name) ||
visitNodes(cbNodes, node.typeArguments);
- case 258 /* JSDocOptionalType */:
+ case 260 /* JSDocOptionalType */:
return visitNode(cbNode, node.type);
- case 259 /* JSDocFunctionType */:
+ case 261 /* JSDocFunctionType */:
return visitNodes(cbNodes, node.parameters) ||
visitNode(cbNode, node.type);
- case 260 /* JSDocVariadicType */:
+ case 262 /* JSDocVariadicType */:
return visitNode(cbNode, node.type);
- case 261 /* JSDocConstructorType */:
+ case 263 /* JSDocConstructorType */:
return visitNode(cbNode, node.type);
- case 262 /* JSDocThisType */:
+ case 264 /* JSDocThisType */:
return visitNode(cbNode, node.type);
- case 256 /* JSDocRecordMember */:
+ case 258 /* JSDocRecordMember */:
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.type);
- case 263 /* JSDocComment */:
+ case 265 /* JSDocComment */:
return visitNodes(cbNodes, node.tags);
- case 265 /* JSDocParameterTag */:
+ case 267 /* JSDocParameterTag */:
return visitNode(cbNode, node.preParameterName) ||
visitNode(cbNode, node.typeExpression) ||
visitNode(cbNode, node.postParameterName);
- case 266 /* JSDocReturnTag */:
+ case 268 /* JSDocReturnTag */:
return visitNode(cbNode, node.typeExpression);
- case 267 /* JSDocTypeTag */:
+ case 269 /* JSDocTypeTag */:
return visitNode(cbNode, node.typeExpression);
- case 268 /* JSDocTemplateTag */:
+ case 270 /* JSDocTemplateTag */:
return visitNodes(cbNodes, node.typeParameters);
}
}
@@ -7756,9 +7975,9 @@ var ts;
// Add additional cases as necessary depending on how we see JSDoc comments used
// in the wild.
switch (node.kind) {
- case 191 /* VariableStatement */:
- case 211 /* FunctionDeclaration */:
- case 136 /* Parameter */:
+ case 193 /* VariableStatement */:
+ case 213 /* FunctionDeclaration */:
+ case 138 /* Parameter */:
addJSDocComment(node);
}
forEachChild(node, visit);
@@ -7799,7 +8018,7 @@ var ts;
}
Parser.fixupParentReferences = fixupParentReferences;
function createSourceFile(fileName, languageVersion) {
- var sourceFile = createNode(246 /* SourceFile */, /*pos*/ 0);
+ var sourceFile = createNode(248 /* SourceFile */, /*pos*/ 0);
sourceFile.pos = 0;
sourceFile.end = sourceText.length;
sourceFile.text = sourceText;
@@ -7963,7 +8182,7 @@ var ts;
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/restorating of these flags happens naturally through the recursive
+ // 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;
@@ -7998,20 +8217,20 @@ var ts;
}
// Ignore strict mode flag because we will report an error in type checker instead.
function isIdentifier() {
- if (token === 67 /* Identifier */) {
+ 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 === 112 /* YieldKeyword */ && inYieldContext()) {
+ 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 === 117 /* AwaitKeyword */ && inAwaitContext()) {
+ if (token === 119 /* AwaitKeyword */ && inAwaitContext()) {
return false;
}
- return token > 103 /* LastReservedWord */;
+ return token > 105 /* LastReservedWord */;
}
function parseExpected(kind, diagnosticMessage, shouldAdvance) {
if (shouldAdvance === void 0) { shouldAdvance = true; }
@@ -8117,25 +8336,25 @@ var ts;
function createIdentifier(isIdentifier, diagnosticMessage) {
identifierCount++;
if (isIdentifier) {
- var node = createNode(67 /* Identifier */);
+ 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 !== 67 /* Identifier */) {
+ if (token !== 69 /* Identifier */) {
node.originalKeywordKind = token;
}
node.text = internIdentifier(scanner.getTokenValue());
nextToken();
return finishNode(node);
}
- return createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected);
+ return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected);
}
function parseIdentifier(diagnosticMessage) {
return createIdentifier(isIdentifier(), diagnosticMessage);
}
function parseIdentifierName() {
- return createIdentifier(isIdentifierOrKeyword());
+ return createIdentifier(ts.tokenIsIdentifierOrKeyword(token));
}
function isLiteralPropertyName() {
- return isIdentifierOrKeyword() ||
+ return ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 /* StringLiteral */ ||
token === 8 /* NumericLiteral */;
}
@@ -8155,13 +8374,13 @@ var ts;
return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false);
}
function isSimplePropertyName() {
- return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || isIdentifierOrKeyword();
+ return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token);
}
function parseComputedPropertyName() {
// PropertyName [Yield]:
// LiteralPropertyName
// ComputedPropertyName[?Yield]
- var node = createNode(134 /* ComputedPropertyName */);
+ var node = createNode(136 /* 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
@@ -8174,21 +8393,28 @@ var ts;
return token === t && tryParse(nextTokenCanFollowModifier);
}
function nextTokenCanFollowModifier() {
- if (token === 72 /* ConstKeyword */) {
+ if (token === 74 /* ConstKeyword */) {
// 'const' is only a modifier if followed by 'enum'.
- return nextToken() === 79 /* EnumKeyword */;
+ return nextToken() === 81 /* EnumKeyword */;
}
- if (token === 80 /* ExportKeyword */) {
+ if (token === 82 /* ExportKeyword */) {
nextToken();
- if (token === 75 /* DefaultKeyword */) {
+ if (token === 77 /* DefaultKeyword */) {
return lookAhead(nextTokenIsClassOrFunction);
}
return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier();
}
- if (token === 75 /* DefaultKeyword */) {
+ if (token === 77 /* DefaultKeyword */) {
return nextTokenIsClassOrFunction();
}
+ if (token === 113 /* StaticKeyword */) {
+ nextToken();
+ return canFollowModifier();
+ }
nextToken();
+ if (scanner.hasPrecedingLineBreak()) {
+ return false;
+ }
return canFollowModifier();
}
function parseAnyContextualModifier() {
@@ -8202,7 +8428,7 @@ var ts;
}
function nextTokenIsClassOrFunction() {
nextToken();
- return token === 71 /* ClassKeyword */ || token === 85 /* FunctionKeyword */;
+ return token === 73 /* ClassKeyword */ || token === 87 /* FunctionKeyword */;
}
// True if positioned at the start of a list element
function isListElement(parsingContext, inErrorRecovery) {
@@ -8222,7 +8448,7 @@ var ts;
// outer module. We just want to consume and move on.
return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement();
case 2 /* SwitchClauses */:
- return token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */;
+ return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */;
case 4 /* TypeMembers */:
return isStartOfTypeMember();
case 5 /* ClassMembers */:
@@ -8271,9 +8497,9 @@ var ts;
case 20 /* HeritageClauses */:
return isHeritageClause();
case 21 /* ImportOrExportSpecifiers */:
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
case 13 /* JsxAttributes */:
- return isIdentifierOrKeyword() || token === 15 /* OpenBraceToken */;
+ return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */;
case 14 /* JsxChildren */:
return true;
case 22 /* JSDocFunctionParameters */:
@@ -8296,7 +8522,7 @@ var ts;
// extends {} extends
// extends {} implements
var next = nextToken();
- return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 81 /* ExtendsKeyword */ || next === 104 /* ImplementsKeyword */;
+ return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */;
}
return true;
}
@@ -8306,11 +8532,11 @@ var ts;
}
function nextTokenIsIdentifierOrKeyword() {
nextToken();
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
function isHeritageClauseExtendsOrImplementsKeyword() {
- if (token === 104 /* ImplementsKeyword */ ||
- token === 81 /* ExtendsKeyword */) {
+ if (token === 106 /* ImplementsKeyword */ ||
+ token === 83 /* ExtendsKeyword */) {
return lookAhead(nextTokenIsStartOfExpression);
}
return false;
@@ -8336,14 +8562,14 @@ var ts;
case 21 /* ImportOrExportSpecifiers */:
return token === 16 /* CloseBraceToken */;
case 3 /* SwitchClauseStatements */:
- return token === 16 /* CloseBraceToken */ || token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */;
+ return token === 16 /* CloseBraceToken */ || token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */;
case 7 /* HeritageClauseElement */:
- return token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */;
+ 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 === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */;
+ 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 */;
@@ -8360,11 +8586,11 @@ var ts;
case 20 /* HeritageClauses */:
return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */;
case 13 /* JsxAttributes */:
- return token === 27 /* GreaterThanToken */ || token === 38 /* SlashToken */;
+ return token === 27 /* GreaterThanToken */ || token === 39 /* SlashToken */;
case 14 /* JsxChildren */:
return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash);
case 22 /* JSDocFunctionParameters */:
- return token === 18 /* CloseParenToken */ || token === 53 /* ColonToken */ || token === 16 /* CloseBraceToken */;
+ return token === 18 /* CloseParenToken */ || token === 54 /* ColonToken */ || token === 16 /* CloseBraceToken */;
case 23 /* JSDocTypeArguments */:
return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */;
case 25 /* JSDocTupleTypes */:
@@ -8552,20 +8778,20 @@ var ts;
function isReusableClassMember(node) {
if (node) {
switch (node.kind) {
- case 142 /* Constructor */:
- case 147 /* IndexSignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 139 /* PropertyDeclaration */:
- case 189 /* SemicolonClassElement */:
+ case 144 /* Constructor */:
+ case 149 /* IndexSignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 141 /* PropertyDeclaration */:
+ case 191 /* SemicolonClassElement */:
return true;
- case 141 /* MethodDeclaration */:
+ case 143 /* 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 === 67 /* Identifier */ &&
- methodDeclaration.name.originalKeywordKind === 119 /* ConstructorKeyword */;
+ var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ &&
+ methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */;
return !nameIsConstructor;
}
}
@@ -8574,8 +8800,8 @@ var ts;
function isReusableSwitchClause(node) {
if (node) {
switch (node.kind) {
- case 239 /* CaseClause */:
- case 240 /* DefaultClause */:
+ case 241 /* CaseClause */:
+ case 242 /* DefaultClause */:
return true;
}
}
@@ -8584,58 +8810,58 @@ var ts;
function isReusableStatement(node) {
if (node) {
switch (node.kind) {
- case 211 /* FunctionDeclaration */:
- case 191 /* VariableStatement */:
- case 190 /* Block */:
- case 194 /* IfStatement */:
- case 193 /* ExpressionStatement */:
- case 206 /* ThrowStatement */:
- case 202 /* ReturnStatement */:
- case 204 /* SwitchStatement */:
- case 201 /* BreakStatement */:
- case 200 /* ContinueStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 197 /* ForStatement */:
- case 196 /* WhileStatement */:
- case 203 /* WithStatement */:
- case 192 /* EmptyStatement */:
- case 207 /* TryStatement */:
- case 205 /* LabeledStatement */:
- case 195 /* DoStatement */:
- case 208 /* DebuggerStatement */:
- case 220 /* ImportDeclaration */:
- case 219 /* ImportEqualsDeclaration */:
- case 226 /* ExportDeclaration */:
- case 225 /* ExportAssignment */:
- case 216 /* ModuleDeclaration */:
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 215 /* EnumDeclaration */:
- case 214 /* TypeAliasDeclaration */:
+ case 213 /* FunctionDeclaration */:
+ case 193 /* VariableStatement */:
+ case 192 /* Block */:
+ case 196 /* IfStatement */:
+ case 195 /* ExpressionStatement */:
+ case 208 /* ThrowStatement */:
+ case 204 /* ReturnStatement */:
+ case 206 /* SwitchStatement */:
+ case 203 /* BreakStatement */:
+ case 202 /* ContinueStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 199 /* ForStatement */:
+ case 198 /* WhileStatement */:
+ case 205 /* WithStatement */:
+ case 194 /* EmptyStatement */:
+ case 209 /* TryStatement */:
+ case 207 /* LabeledStatement */:
+ case 197 /* DoStatement */:
+ case 210 /* DebuggerStatement */:
+ case 222 /* ImportDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 228 /* ExportDeclaration */:
+ case 227 /* ExportAssignment */:
+ case 218 /* ModuleDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
return true;
}
}
return false;
}
function isReusableEnumMember(node) {
- return node.kind === 245 /* EnumMember */;
+ return node.kind === 247 /* EnumMember */;
}
function isReusableTypeMember(node) {
if (node) {
switch (node.kind) {
- case 146 /* ConstructSignature */:
- case 140 /* MethodSignature */:
- case 147 /* IndexSignature */:
- case 138 /* PropertySignature */:
- case 145 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 142 /* MethodSignature */:
+ case 149 /* IndexSignature */:
+ case 140 /* PropertySignature */:
+ case 147 /* CallSignature */:
return true;
}
}
return false;
}
function isReusableVariableDeclaration(node) {
- if (node.kind !== 209 /* VariableDeclaration */) {
+ if (node.kind !== 211 /* VariableDeclaration */) {
return false;
}
// Very subtle incremental parsing bug. Consider the following code:
@@ -8656,7 +8882,7 @@ var ts;
return variableDeclarator.initializer === undefined;
}
function isReusableParameter(node) {
- if (node.kind !== 136 /* Parameter */) {
+ if (node.kind !== 138 /* Parameter */) {
return false;
}
// See the comment in isReusableVariableDeclaration for why we do this.
@@ -8773,7 +8999,7 @@ var ts;
function parseEntityName(allowReservedWords, diagnosticMessage) {
var entity = parseIdentifier(diagnosticMessage);
while (parseOptional(21 /* DotToken */)) {
- var node = createNode(133 /* QualifiedName */, entity.pos);
+ var node = createNode(135 /* QualifiedName */, entity.pos);
node.left = entity;
node.right = parseRightSideOfDot(allowReservedWords);
entity = finishNode(node);
@@ -8800,19 +9026,19 @@ var ts;
// 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() && isIdentifierOrKeyword()) {
+ 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(67 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected);
+ return createMissingNode(69 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected);
}
}
return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
}
function parseTemplateExpression() {
- var template = createNode(181 /* TemplateExpression */);
+ var template = createNode(183 /* TemplateExpression */);
template.head = parseLiteralNode();
ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind");
var templateSpans = [];
@@ -8825,7 +9051,7 @@ var ts;
return finishNode(template);
}
function parseTemplateSpan() {
- var span = createNode(188 /* TemplateSpan */);
+ var span = createNode(190 /* TemplateSpan */);
span.expression = allowInAnd(parseExpression);
var literal;
if (token === 16 /* CloseBraceToken */) {
@@ -8867,14 +9093,14 @@ var ts;
// TYPES
function parseTypeReferenceOrTypePredicate() {
var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected);
- if (typeName.kind === 67 /* Identifier */ && token === 122 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) {
+ if (typeName.kind === 69 /* Identifier */ && token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) {
nextToken();
- var node_1 = createNode(148 /* TypePredicate */, typeName.pos);
+ var node_1 = createNode(150 /* TypePredicate */, typeName.pos);
node_1.parameterName = typeName;
node_1.type = parseType();
return finishNode(node_1);
}
- var node = createNode(149 /* TypeReference */, typeName.pos);
+ var node = createNode(151 /* TypeReference */, typeName.pos);
node.typeName = typeName;
if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) {
node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */);
@@ -8882,15 +9108,15 @@ var ts;
return finishNode(node);
}
function parseTypeQuery() {
- var node = createNode(152 /* TypeQuery */);
- parseExpected(99 /* TypeOfKeyword */);
+ var node = createNode(154 /* TypeQuery */);
+ parseExpected(101 /* TypeOfKeyword */);
node.exprName = parseEntityName(/*allowReservedWords*/ true);
return finishNode(node);
}
function parseTypeParameter() {
- var node = createNode(135 /* TypeParameter */);
+ var node = createNode(137 /* TypeParameter */);
node.name = parseIdentifier();
- if (parseOptional(81 /* ExtendsKeyword */)) {
+ 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
@@ -8917,7 +9143,7 @@ var ts;
}
}
function parseParameterType() {
- if (parseOptional(53 /* ColonToken */)) {
+ if (parseOptional(54 /* ColonToken */)) {
return token === 9 /* StringLiteral */
? parseLiteralNode(/*internName*/ true)
: parseType();
@@ -8925,7 +9151,7 @@ var ts;
return undefined;
}
function isStartOfParameter() {
- return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 54 /* AtToken */;
+ return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 55 /* AtToken */;
}
function setModifiers(node, modifiers) {
if (modifiers) {
@@ -8934,7 +9160,7 @@ var ts;
}
}
function parseParameter() {
- var node = createNode(136 /* Parameter */);
+ var node = createNode(138 /* Parameter */);
node.decorators = parseDecorators();
setModifiers(node, parseModifiers());
node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */);
@@ -8952,7 +9178,7 @@ var ts;
// to avoid this we'll advance cursor to the next token.
nextToken();
}
- node.questionToken = parseOptionalToken(52 /* QuestionToken */);
+ 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
@@ -9028,10 +9254,10 @@ var ts;
}
function parseSignatureMember(kind) {
var node = createNode(kind);
- if (kind === 146 /* ConstructSignature */) {
- parseExpected(90 /* NewKeyword */);
+ if (kind === 148 /* ConstructSignature */) {
+ parseExpected(92 /* NewKeyword */);
}
- fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node);
+ fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node);
parseTypeMemberSemicolon();
return finishNode(node);
}
@@ -9078,21 +9304,21 @@ var ts;
// 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 === 53 /* ColonToken */ || token === 24 /* CommaToken */) {
+ 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 !== 52 /* QuestionToken */) {
+ 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 === 53 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */;
+ return token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */;
}
function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) {
- var node = createNode(147 /* IndexSignature */, fullStart);
+ var node = createNode(149 /* IndexSignature */, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */);
@@ -9103,19 +9329,19 @@ var ts;
function parsePropertyOrMethodSignature() {
var fullStart = scanner.getStartPos();
var name = parsePropertyName();
- var questionToken = parseOptionalToken(52 /* QuestionToken */);
+ var questionToken = parseOptionalToken(53 /* QuestionToken */);
if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) {
- var method = createNode(140 /* MethodSignature */, fullStart);
+ var method = createNode(142 /* MethodSignature */, fullStart);
method.name = name;
method.questionToken = questionToken;
// Method signatues don't exist in expression contexts. So they have neither
// [Yield] nor [Await]
- fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method);
+ fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method);
parseTypeMemberSemicolon();
return finishNode(method);
}
else {
- var property = createNode(138 /* PropertySignature */, fullStart);
+ var property = createNode(140 /* PropertySignature */, fullStart);
property.name = name;
property.questionToken = questionToken;
property.type = parseTypeAnnotation();
@@ -9149,23 +9375,23 @@ var ts;
nextToken();
return token === 17 /* OpenParenToken */ ||
token === 25 /* LessThanToken */ ||
- token === 52 /* QuestionToken */ ||
- token === 53 /* ColonToken */ ||
+ token === 53 /* QuestionToken */ ||
+ token === 54 /* ColonToken */ ||
canParseSemicolon();
}
function parseTypeMember() {
switch (token) {
case 17 /* OpenParenToken */:
case 25 /* LessThanToken */:
- return parseSignatureMember(145 /* CallSignature */);
+ return parseSignatureMember(147 /* CallSignature */);
case 19 /* OpenBracketToken */:
// Indexer or computed property
return isIndexSignature()
? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined)
: parsePropertyOrMethodSignature();
- case 90 /* NewKeyword */:
+ case 92 /* NewKeyword */:
if (lookAhead(isStartOfConstructSignature)) {
- return parseSignatureMember(146 /* ConstructSignature */);
+ return parseSignatureMember(148 /* ConstructSignature */);
}
// fall through.
case 9 /* StringLiteral */:
@@ -9184,7 +9410,7 @@ var ts;
return result;
}
}
- if (isIdentifierOrKeyword()) {
+ if (ts.tokenIsIdentifierOrKeyword(token)) {
return parsePropertyOrMethodSignature();
}
}
@@ -9202,7 +9428,7 @@ var ts;
return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */;
}
function parseTypeLiteral() {
- var node = createNode(153 /* TypeLiteral */);
+ var node = createNode(155 /* TypeLiteral */);
node.members = parseObjectTypeMembers();
return finishNode(node);
}
@@ -9218,12 +9444,12 @@ var ts;
return members;
}
function parseTupleType() {
- var node = createNode(155 /* TupleType */);
+ var node = createNode(157 /* TupleType */);
node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */);
return finishNode(node);
}
function parseParenthesizedType() {
- var node = createNode(158 /* ParenthesizedType */);
+ var node = createNode(160 /* ParenthesizedType */);
parseExpected(17 /* OpenParenToken */);
node.type = parseType();
parseExpected(18 /* CloseParenToken */);
@@ -9231,8 +9457,8 @@ var ts;
}
function parseFunctionOrConstructorType(kind) {
var node = createNode(kind);
- if (kind === 151 /* ConstructorType */) {
- parseExpected(90 /* NewKeyword */);
+ if (kind === 153 /* ConstructorType */) {
+ parseExpected(92 /* NewKeyword */);
}
fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node);
return finishNode(node);
@@ -9243,17 +9469,18 @@ var ts;
}
function parseNonArrayType() {
switch (token) {
- case 115 /* AnyKeyword */:
- case 128 /* StringKeyword */:
- case 126 /* NumberKeyword */:
- case 118 /* BooleanKeyword */:
- case 129 /* SymbolKeyword */:
+ 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 || parseTypeReferenceOrTypePredicate();
- case 101 /* VoidKeyword */:
+ case 103 /* VoidKeyword */:
+ case 97 /* ThisKeyword */:
return parseTokenNode();
- case 99 /* TypeOfKeyword */:
+ case 101 /* TypeOfKeyword */:
return parseTypeQuery();
case 15 /* OpenBraceToken */:
return parseTypeLiteral();
@@ -9267,17 +9494,18 @@ var ts;
}
function isStartOfType() {
switch (token) {
- case 115 /* AnyKeyword */:
- case 128 /* StringKeyword */:
- case 126 /* NumberKeyword */:
- case 118 /* BooleanKeyword */:
- case 129 /* SymbolKeyword */:
- case 101 /* VoidKeyword */:
- case 99 /* TypeOfKeyword */:
+ 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 90 /* NewKeyword */:
+ case 92 /* NewKeyword */:
return true;
case 17 /* OpenParenToken */:
// Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier,
@@ -9295,7 +9523,7 @@ var ts;
var type = parseNonArrayType();
while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) {
parseExpected(20 /* CloseBracketToken */);
- var node = createNode(154 /* ArrayType */, type.pos);
+ var node = createNode(156 /* ArrayType */, type.pos);
node.elementType = type;
type = finishNode(node);
}
@@ -9317,10 +9545,10 @@ var ts;
return type;
}
function parseIntersectionTypeOrHigher() {
- return parseUnionOrIntersectionType(157 /* IntersectionType */, parseArrayTypeOrHigher, 45 /* AmpersandToken */);
+ return parseUnionOrIntersectionType(159 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */);
}
function parseUnionTypeOrHigher() {
- return parseUnionOrIntersectionType(156 /* UnionType */, parseIntersectionTypeOrHigher, 46 /* BarToken */);
+ return parseUnionOrIntersectionType(158 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */);
}
function isStartOfFunctionType() {
if (token === 25 /* LessThanToken */) {
@@ -9337,8 +9565,8 @@ var ts;
}
if (isIdentifier() || ts.isModifier(token)) {
nextToken();
- if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */ ||
- token === 52 /* QuestionToken */ || token === 55 /* EqualsToken */ ||
+ if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ ||
+ token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ ||
isIdentifier() || ts.isModifier(token)) {
// ( id :
// ( id ,
@@ -9364,24 +9592,24 @@ var ts;
}
function parseTypeWorker() {
if (isStartOfFunctionType()) {
- return parseFunctionOrConstructorType(150 /* FunctionType */);
+ return parseFunctionOrConstructorType(152 /* FunctionType */);
}
- if (token === 90 /* NewKeyword */) {
- return parseFunctionOrConstructorType(151 /* ConstructorType */);
+ if (token === 92 /* NewKeyword */) {
+ return parseFunctionOrConstructorType(153 /* ConstructorType */);
}
return parseUnionTypeOrHigher();
}
function parseTypeAnnotation() {
- return parseOptional(53 /* ColonToken */) ? parseType() : undefined;
+ return parseOptional(54 /* ColonToken */) ? parseType() : undefined;
}
// EXPRESSIONS
function isStartOfLeftHandSideExpression() {
switch (token) {
- case 95 /* ThisKeyword */:
- case 93 /* SuperKeyword */:
- case 91 /* NullKeyword */:
- case 97 /* TrueKeyword */:
- case 82 /* FalseKeyword */:
+ case 97 /* ThisKeyword */:
+ case 95 /* SuperKeyword */:
+ case 93 /* NullKeyword */:
+ case 99 /* TrueKeyword */:
+ case 84 /* FalseKeyword */:
case 8 /* NumericLiteral */:
case 9 /* StringLiteral */:
case 11 /* NoSubstitutionTemplateLiteral */:
@@ -9389,12 +9617,12 @@ var ts;
case 17 /* OpenParenToken */:
case 19 /* OpenBracketToken */:
case 15 /* OpenBraceToken */:
- case 85 /* FunctionKeyword */:
- case 71 /* ClassKeyword */:
- case 90 /* NewKeyword */:
- case 38 /* SlashToken */:
- case 59 /* SlashEqualsToken */:
- case 67 /* Identifier */:
+ case 87 /* FunctionKeyword */:
+ case 73 /* ClassKeyword */:
+ case 92 /* NewKeyword */:
+ case 39 /* SlashToken */:
+ case 61 /* SlashEqualsToken */:
+ case 69 /* Identifier */:
return true;
default:
return isIdentifier();
@@ -9407,16 +9635,16 @@ var ts;
switch (token) {
case 35 /* PlusToken */:
case 36 /* MinusToken */:
- case 49 /* TildeToken */:
- case 48 /* ExclamationToken */:
- case 76 /* DeleteKeyword */:
- case 99 /* TypeOfKeyword */:
- case 101 /* VoidKeyword */:
- case 40 /* PlusPlusToken */:
- case 41 /* MinusMinusToken */:
+ 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 117 /* AwaitKeyword */:
- case 112 /* YieldKeyword */:
+ 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.
@@ -9435,9 +9663,9 @@ var ts;
function isStartOfExpressionStatement() {
// As per the grammar, none of '{' or 'function' or 'class' can start an expression statement.
return token !== 15 /* OpenBraceToken */ &&
- token !== 85 /* FunctionKeyword */ &&
- token !== 71 /* ClassKeyword */ &&
- token !== 54 /* AtToken */ &&
+ token !== 87 /* FunctionKeyword */ &&
+ token !== 73 /* ClassKeyword */ &&
+ token !== 55 /* AtToken */ &&
isStartOfExpression();
}
function allowInAndParseExpression() {
@@ -9463,7 +9691,7 @@ var ts;
return expr;
}
function parseInitializer(inParameter) {
- if (token !== 55 /* EqualsToken */) {
+ 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.
@@ -9480,7 +9708,7 @@ var ts;
}
// Initializer[In, Yield] :
// = AssignmentExpression[?In, ?Yield]
- parseExpected(55 /* EqualsToken */);
+ parseExpected(56 /* EqualsToken */);
return parseAssignmentExpressionOrHigher();
}
function parseAssignmentExpressionOrHigher() {
@@ -9518,7 +9746,7 @@ var ts;
// 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 === 67 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) {
+ if (expr.kind === 69 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) {
return parseSimpleArrowFunctionExpression(expr);
}
// Now see if we might be in cases '2' or '3'.
@@ -9534,7 +9762,7 @@ var ts;
return parseConditionalExpressionRest(expr);
}
function isYieldExpression() {
- if (token === 112 /* YieldKeyword */) {
+ 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()) {
@@ -9563,7 +9791,7 @@ var ts;
return !scanner.hasPrecedingLineBreak() && isIdentifier();
}
function parseYieldExpression() {
- var node = createNode(182 /* YieldExpression */);
+ var node = createNode(184 /* YieldExpression */);
// YieldExpression[In] :
// yield
// yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield]
@@ -9583,8 +9811,8 @@ var ts;
}
function parseSimpleArrowFunctionExpression(identifier) {
ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
- var node = createNode(172 /* ArrowFunction */, identifier.pos);
- var parameter = createNode(136 /* Parameter */, identifier.pos);
+ var node = createNode(174 /* ArrowFunction */, identifier.pos);
+ var parameter = createNode(138 /* Parameter */, identifier.pos);
parameter.name = identifier;
finishNode(parameter);
node.parameters = [parameter];
@@ -9626,7 +9854,7 @@ var ts;
// 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 === 116 /* AsyncKeyword */) {
+ if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 118 /* AsyncKeyword */) {
return lookAhead(isParenthesizedArrowFunctionExpressionWorker);
}
if (token === 34 /* EqualsGreaterThanToken */) {
@@ -9639,7 +9867,7 @@ var ts;
return 0 /* False */;
}
function isParenthesizedArrowFunctionExpressionWorker() {
- if (token === 116 /* AsyncKeyword */) {
+ if (token === 118 /* AsyncKeyword */) {
nextToken();
if (scanner.hasPrecedingLineBreak()) {
return 0 /* False */;
@@ -9659,7 +9887,7 @@ var ts;
var third = nextToken();
switch (third) {
case 34 /* EqualsGreaterThanToken */:
- case 53 /* ColonToken */:
+ case 54 /* ColonToken */:
case 15 /* OpenBraceToken */:
return 1 /* True */;
default:
@@ -9690,7 +9918,7 @@ var ts;
}
// If we have something like "(a:", then we must have a
// type-annotated parameter in an arrow function expression.
- if (nextToken() === 53 /* ColonToken */) {
+ if (nextToken() === 54 /* ColonToken */) {
return 1 /* True */;
}
// This *could* be a parenthesized arrow function.
@@ -9708,10 +9936,10 @@ var ts;
if (sourceFile.languageVariant === 1 /* JSX */) {
var isArrowFunctionInJsx = lookAhead(function () {
var third = nextToken();
- if (third === 81 /* ExtendsKeyword */) {
+ if (third === 83 /* ExtendsKeyword */) {
var fourth = nextToken();
switch (fourth) {
- case 55 /* EqualsToken */:
+ case 56 /* EqualsToken */:
case 27 /* GreaterThanToken */:
return false;
default:
@@ -9736,7 +9964,7 @@ var ts;
return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false);
}
function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) {
- var node = createNode(172 /* ArrowFunction */);
+ var node = createNode(174 /* ArrowFunction */);
setModifiers(node, parseModifiersForArrowFunction());
var isAsync = !!(node.flags & 512 /* Async */);
// Arrow functions are never generators.
@@ -9746,7 +9974,7 @@ var ts;
// a => (b => c)
// And think that "(b =>" was actually a parenthesized arrow function with a missing
// close paren.
- fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node);
+ 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;
@@ -9770,8 +9998,8 @@ var ts;
return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false);
}
if (token !== 23 /* SemicolonToken */ &&
- token !== 85 /* FunctionKeyword */ &&
- token !== 71 /* ClassKeyword */ &&
+ 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)
@@ -9796,17 +10024,17 @@ var ts;
}
function parseConditionalExpressionRest(leftOperand) {
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
- var questionToken = parseOptionalToken(52 /* QuestionToken */);
+ 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(180 /* ConditionalExpression */, leftOperand.pos);
+ var node = createNode(182 /* ConditionalExpression */, leftOperand.pos);
node.condition = leftOperand;
node.questionToken = questionToken;
node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher);
- node.colonToken = parseExpectedToken(53 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(53 /* ColonToken */));
+ node.colonToken = parseExpectedToken(54 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(54 /* ColonToken */));
node.whenFalse = parseAssignmentExpressionOrHigher();
return finishNode(node);
}
@@ -9815,7 +10043,7 @@ var ts;
return parseBinaryExpressionRest(precedence, leftOperand);
}
function isInOrOfKeyword(t) {
- return t === 88 /* InKeyword */ || t === 132 /* OfKeyword */;
+ return t === 90 /* InKeyword */ || t === 134 /* OfKeyword */;
}
function parseBinaryExpressionRest(precedence, leftOperand) {
while (true) {
@@ -9824,13 +10052,36 @@ var ts;
reScanGreaterToken();
var newPrecedence = getBinaryOperatorPrecedence();
// Check the precedence to see if we should "take" this operator
- if (newPrecedence <= precedence) {
+ // - 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 === 88 /* InKeyword */ && inDisallowInContext()) {
+ if (token === 90 /* InKeyword */ && inDisallowInContext()) {
break;
}
- if (token === 114 /* AsKeyword */) {
+ if (token === 116 /* AsKeyword */) {
// Make sure we *do* perform ASI for constructs like this:
// var x = foo
// as (Bar)
@@ -9851,22 +10102,22 @@ var ts;
return leftOperand;
}
function isBinaryOperator() {
- if (inDisallowInContext() && token === 88 /* InKeyword */) {
+ if (inDisallowInContext() && token === 90 /* InKeyword */) {
return false;
}
return getBinaryOperatorPrecedence() > 0;
}
function getBinaryOperatorPrecedence() {
switch (token) {
- case 51 /* BarBarToken */:
+ case 52 /* BarBarToken */:
return 1;
- case 50 /* AmpersandAmpersandToken */:
+ case 51 /* AmpersandAmpersandToken */:
return 2;
- case 46 /* BarToken */:
+ case 47 /* BarToken */:
return 3;
- case 47 /* CaretToken */:
+ case 48 /* CaretToken */:
return 4;
- case 45 /* AmpersandToken */:
+ case 46 /* AmpersandToken */:
return 5;
case 30 /* EqualsEqualsToken */:
case 31 /* ExclamationEqualsToken */:
@@ -9877,66 +10128,68 @@ var ts;
case 27 /* GreaterThanToken */:
case 28 /* LessThanEqualsToken */:
case 29 /* GreaterThanEqualsToken */:
- case 89 /* InstanceOfKeyword */:
- case 88 /* InKeyword */:
- case 114 /* AsKeyword */:
+ case 91 /* InstanceOfKeyword */:
+ case 90 /* InKeyword */:
+ case 116 /* AsKeyword */:
return 7;
- case 42 /* LessThanLessThanToken */:
- case 43 /* GreaterThanGreaterThanToken */:
- case 44 /* GreaterThanGreaterThanGreaterThanToken */:
+ case 43 /* LessThanLessThanToken */:
+ case 44 /* GreaterThanGreaterThanToken */:
+ case 45 /* GreaterThanGreaterThanGreaterThanToken */:
return 8;
case 35 /* PlusToken */:
case 36 /* MinusToken */:
return 9;
case 37 /* AsteriskToken */:
- case 38 /* SlashToken */:
- case 39 /* PercentToken */:
+ 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(179 /* BinaryExpression */, left.pos);
+ var node = createNode(181 /* BinaryExpression */, left.pos);
node.left = left;
node.operatorToken = operatorToken;
node.right = right;
return finishNode(node);
}
function makeAsExpression(left, right) {
- var node = createNode(187 /* AsExpression */, left.pos);
+ var node = createNode(189 /* AsExpression */, left.pos);
node.expression = left;
node.type = right;
return finishNode(node);
}
function parsePrefixUnaryExpression() {
- var node = createNode(177 /* PrefixUnaryExpression */);
+ var node = createNode(179 /* PrefixUnaryExpression */);
node.operator = token;
nextToken();
- node.operand = parseUnaryExpressionOrHigher();
+ node.operand = parseSimpleUnaryExpression();
return finishNode(node);
}
function parseDeleteExpression() {
- var node = createNode(173 /* DeleteExpression */);
+ var node = createNode(175 /* DeleteExpression */);
nextToken();
- node.expression = parseUnaryExpressionOrHigher();
+ node.expression = parseSimpleUnaryExpression();
return finishNode(node);
}
function parseTypeOfExpression() {
- var node = createNode(174 /* TypeOfExpression */);
+ var node = createNode(176 /* TypeOfExpression */);
nextToken();
- node.expression = parseUnaryExpressionOrHigher();
+ node.expression = parseSimpleUnaryExpression();
return finishNode(node);
}
function parseVoidExpression() {
- var node = createNode(175 /* VoidExpression */);
+ var node = createNode(177 /* VoidExpression */);
nextToken();
- node.expression = parseUnaryExpressionOrHigher();
+ node.expression = parseSimpleUnaryExpression();
return finishNode(node);
}
function isAwaitExpression() {
- if (token === 117 /* AwaitKeyword */) {
+ if (token === 119 /* AwaitKeyword */) {
if (inAwaitContext()) {
return true;
}
@@ -9946,46 +10199,137 @@ var ts;
return false;
}
function parseAwaitExpression() {
- var node = createNode(176 /* AwaitExpression */);
+ var node = createNode(178 /* AwaitExpression */);
nextToken();
- node.expression = parseUnaryExpressionOrHigher();
+ 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 diagnostic;
+ var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos);
+ if (simpleUnaryExpression.kind === 171 /* 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 49 /* TildeToken */:
- case 48 /* ExclamationToken */:
- case 40 /* PlusPlusToken */:
- case 41 /* MinusMinusToken */:
+ case 50 /* TildeToken */:
+ case 49 /* ExclamationToken */:
return parsePrefixUnaryExpression();
- case 76 /* DeleteKeyword */:
+ case 78 /* DeleteKeyword */:
return parseDeleteExpression();
- case 99 /* TypeOfKeyword */:
+ case 101 /* TypeOfKeyword */:
return parseTypeOfExpression();
- case 101 /* VoidKeyword */:
+ 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 parseTypeAssertion();
- }
- if (lookAhead(nextTokenIsIdentifierOrKeyword)) {
- return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true);
+ return false;
}
+ // We are in JSX context and the token is part of JSXElement.
// Fall through
default:
- return parsePostfixExpressionOrHigher();
+ return true;
}
}
- function parsePostfixExpressionOrHigher() {
+ /**
+ * 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(179 /* 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 === 40 /* PlusPlusToken */ || token === 41 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) {
- var node = createNode(178 /* PostfixUnaryExpression */, expression.pos);
+ if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) {
+ var node = createNode(180 /* PostfixUnaryExpression */, expression.pos);
node.operand = expression;
node.operator = token;
nextToken();
@@ -10024,7 +10368,7 @@ var ts;
// 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 === 93 /* SuperKeyword */
+ var expression = token === 95 /* SuperKeyword */
? parseSuperExpression()
: parseMemberExpressionOrHigher();
// Now, we *may* be complete. However, we might have consumed the start of a
@@ -10089,7 +10433,7 @@ var ts;
}
// 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(164 /* PropertyAccessExpression */, expression.pos);
+ var node = createNode(166 /* 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);
@@ -10097,27 +10441,27 @@ var ts;
}
function parseJsxElementOrSelfClosingElement(inExpressionContext) {
var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext);
- if (opening.kind === 233 /* JsxOpeningElement */) {
- var node = createNode(231 /* JsxElement */, opening.pos);
+ if (opening.kind === 235 /* JsxOpeningElement */) {
+ var node = createNode(233 /* JsxElement */, opening.pos);
node.openingElement = opening;
node.children = parseJsxChildren(node.openingElement.tagName);
node.closingElement = parseJsxClosingElement(inExpressionContext);
return finishNode(node);
}
else {
- ts.Debug.assert(opening.kind === 232 /* JsxSelfClosingElement */);
+ ts.Debug.assert(opening.kind === 234 /* JsxSelfClosingElement */);
// Nothing else to do for self-closing elements
return opening;
}
}
function parseJsxText() {
- var node = createNode(234 /* JsxText */, scanner.getStartPos());
+ var node = createNode(236 /* JsxText */, scanner.getStartPos());
token = scanner.scanJsxToken();
return finishNode(node);
}
function parseJsxChild() {
switch (token) {
- case 234 /* JsxText */:
+ case 236 /* JsxText */:
return parseJsxText();
case 15 /* OpenBraceToken */:
return parseJsxExpression(/*inExpressionContext*/ false);
@@ -10156,11 +10500,11 @@ var ts;
// 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(233 /* JsxOpeningElement */, fullStart);
+ node = createNode(235 /* JsxOpeningElement */, fullStart);
scanJsxText();
}
else {
- parseExpected(38 /* SlashToken */);
+ parseExpected(39 /* SlashToken */);
if (inExpressionContext) {
parseExpected(27 /* GreaterThanToken */);
}
@@ -10168,7 +10512,7 @@ var ts;
parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false);
scanJsxText();
}
- node = createNode(232 /* JsxSelfClosingElement */, fullStart);
+ node = createNode(234 /* JsxSelfClosingElement */, fullStart);
}
node.tagName = tagName;
node.attributes = attributes;
@@ -10179,7 +10523,7 @@ var ts;
var elementName = parseIdentifierName();
while (parseOptional(21 /* DotToken */)) {
scanJsxIdentifier();
- var node = createNode(133 /* QualifiedName */, elementName.pos);
+ var node = createNode(135 /* QualifiedName */, elementName.pos);
node.left = elementName;
node.right = parseIdentifierName();
elementName = finishNode(node);
@@ -10187,7 +10531,7 @@ var ts;
return elementName;
}
function parseJsxExpression(inExpressionContext) {
- var node = createNode(238 /* JsxExpression */);
+ var node = createNode(240 /* JsxExpression */);
parseExpected(15 /* OpenBraceToken */);
if (token !== 16 /* CloseBraceToken */) {
node.expression = parseExpression();
@@ -10206,9 +10550,9 @@ var ts;
return parseJsxSpreadAttribute();
}
scanJsxIdentifier();
- var node = createNode(236 /* JsxAttribute */);
+ var node = createNode(238 /* JsxAttribute */);
node.name = parseIdentifierName();
- if (parseOptional(55 /* EqualsToken */)) {
+ if (parseOptional(56 /* EqualsToken */)) {
switch (token) {
case 9 /* StringLiteral */:
node.initializer = parseLiteralNode();
@@ -10221,7 +10565,7 @@ var ts;
return finishNode(node);
}
function parseJsxSpreadAttribute() {
- var node = createNode(237 /* JsxSpreadAttribute */);
+ var node = createNode(239 /* JsxSpreadAttribute */);
parseExpected(15 /* OpenBraceToken */);
parseExpected(22 /* DotDotDotToken */);
node.expression = parseExpression();
@@ -10229,7 +10573,7 @@ var ts;
return finishNode(node);
}
function parseJsxClosingElement(inExpressionContext) {
- var node = createNode(235 /* JsxClosingElement */);
+ var node = createNode(237 /* JsxClosingElement */);
parseExpected(26 /* LessThanSlashToken */);
node.tagName = parseJsxElementName();
if (inExpressionContext) {
@@ -10242,18 +10586,18 @@ var ts;
return finishNode(node);
}
function parseTypeAssertion() {
- var node = createNode(169 /* TypeAssertionExpression */);
+ var node = createNode(171 /* TypeAssertionExpression */);
parseExpected(25 /* LessThanToken */);
node.type = parseType();
parseExpected(27 /* GreaterThanToken */);
- node.expression = parseUnaryExpressionOrHigher();
+ node.expression = parseSimpleUnaryExpression();
return finishNode(node);
}
function parseMemberExpressionRest(expression) {
while (true) {
var dotToken = parseOptionalToken(21 /* DotToken */);
if (dotToken) {
- var propertyAccess = createNode(164 /* PropertyAccessExpression */, expression.pos);
+ var propertyAccess = createNode(166 /* PropertyAccessExpression */, expression.pos);
propertyAccess.expression = expression;
propertyAccess.dotToken = dotToken;
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
@@ -10262,7 +10606,7 @@ var ts;
}
// 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(165 /* ElementAccessExpression */, expression.pos);
+ var indexedAccess = createNode(167 /* 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.
@@ -10278,7 +10622,7 @@ var ts;
continue;
}
if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) {
- var tagExpression = createNode(168 /* TaggedTemplateExpression */, expression.pos);
+ var tagExpression = createNode(170 /* TaggedTemplateExpression */, expression.pos);
tagExpression.tag = expression;
tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */
? parseLiteralNode()
@@ -10301,7 +10645,7 @@ var ts;
if (!typeArguments) {
return expression;
}
- var callExpr = createNode(166 /* CallExpression */, expression.pos);
+ var callExpr = createNode(168 /* CallExpression */, expression.pos);
callExpr.expression = expression;
callExpr.typeArguments = typeArguments;
callExpr.arguments = parseArgumentList();
@@ -10309,7 +10653,7 @@ var ts;
continue;
}
else if (token === 17 /* OpenParenToken */) {
- var callExpr = createNode(166 /* CallExpression */, expression.pos);
+ var callExpr = createNode(168 /* CallExpression */, expression.pos);
callExpr.expression = expression;
callExpr.arguments = parseArgumentList();
expression = finishNode(callExpr);
@@ -10347,18 +10691,18 @@ var ts;
case 21 /* DotToken */: // foo.
case 18 /* CloseParenToken */: // foo)
case 20 /* CloseBracketToken */: // foo]
- case 53 /* ColonToken */: // foo:
+ case 54 /* ColonToken */: // foo:
case 23 /* SemicolonToken */: // foo;
- case 52 /* QuestionToken */: // foo?
+ case 53 /* QuestionToken */: // foo?
case 30 /* EqualsEqualsToken */: // foo ==
case 32 /* EqualsEqualsEqualsToken */: // foo ===
case 31 /* ExclamationEqualsToken */: // foo !=
case 33 /* ExclamationEqualsEqualsToken */: // foo !==
- case 50 /* AmpersandAmpersandToken */: // foo &&
- case 51 /* BarBarToken */: // foo ||
- case 47 /* CaretToken */: // foo ^
- case 45 /* AmpersandToken */: // foo &
- case 46 /* BarToken */: // foo |
+ case 51 /* AmpersandAmpersandToken */: // foo &&
+ case 52 /* BarBarToken */: // foo ||
+ case 48 /* CaretToken */: // foo ^
+ case 46 /* AmpersandToken */: // foo &
+ case 47 /* BarToken */: // foo |
case 16 /* CloseBraceToken */: // foo }
case 1 /* EndOfFileToken */:
// these cases can't legally follow a type arg list. However, they're not legal
@@ -10381,11 +10725,11 @@ var ts;
case 9 /* StringLiteral */:
case 11 /* NoSubstitutionTemplateLiteral */:
return parseLiteralNode();
- case 95 /* ThisKeyword */:
- case 93 /* SuperKeyword */:
- case 91 /* NullKeyword */:
- case 97 /* TrueKeyword */:
- case 82 /* FalseKeyword */:
+ case 97 /* ThisKeyword */:
+ case 95 /* SuperKeyword */:
+ case 93 /* NullKeyword */:
+ case 99 /* TrueKeyword */:
+ case 84 /* FalseKeyword */:
return parseTokenNode();
case 17 /* OpenParenToken */:
return parseParenthesizedExpression();
@@ -10393,7 +10737,7 @@ var ts;
return parseArrayLiteralExpression();
case 15 /* OpenBraceToken */:
return parseObjectLiteralExpression();
- case 116 /* AsyncKeyword */:
+ 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.
@@ -10401,14 +10745,14 @@ var ts;
break;
}
return parseFunctionExpression();
- case 71 /* ClassKeyword */:
+ case 73 /* ClassKeyword */:
return parseClassExpression();
- case 85 /* FunctionKeyword */:
+ case 87 /* FunctionKeyword */:
return parseFunctionExpression();
- case 90 /* NewKeyword */:
+ case 92 /* NewKeyword */:
return parseNewExpression();
- case 38 /* SlashToken */:
- case 59 /* SlashEqualsToken */:
+ case 39 /* SlashToken */:
+ case 61 /* SlashEqualsToken */:
if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) {
return parseLiteralNode();
}
@@ -10419,28 +10763,28 @@ var ts;
return parseIdentifier(ts.Diagnostics.Expression_expected);
}
function parseParenthesizedExpression() {
- var node = createNode(170 /* ParenthesizedExpression */);
+ var node = createNode(172 /* ParenthesizedExpression */);
parseExpected(17 /* OpenParenToken */);
node.expression = allowInAnd(parseExpression);
parseExpected(18 /* CloseParenToken */);
return finishNode(node);
}
function parseSpreadElement() {
- var node = createNode(183 /* SpreadElementExpression */);
+ var node = createNode(185 /* SpreadElementExpression */);
parseExpected(22 /* DotDotDotToken */);
node.expression = parseAssignmentExpressionOrHigher();
return finishNode(node);
}
function parseArgumentOrArrayLiteralElement() {
return token === 22 /* DotDotDotToken */ ? parseSpreadElement() :
- token === 24 /* CommaToken */ ? createNode(185 /* OmittedExpression */) :
+ token === 24 /* CommaToken */ ? createNode(187 /* OmittedExpression */) :
parseAssignmentExpressionOrHigher();
}
function parseArgumentExpression() {
return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
}
function parseArrayLiteralExpression() {
- var node = createNode(162 /* ArrayLiteralExpression */);
+ var node = createNode(164 /* ArrayLiteralExpression */);
parseExpected(19 /* OpenBracketToken */);
if (scanner.hasPrecedingLineBreak())
node.flags |= 2048 /* MultiLine */;
@@ -10449,11 +10793,11 @@ var ts;
return finishNode(node);
}
function tryParseAccessorDeclaration(fullStart, decorators, modifiers) {
- if (parseContextualModifier(121 /* GetKeyword */)) {
- return parseAccessorDeclaration(143 /* GetAccessor */, fullStart, decorators, modifiers);
+ if (parseContextualModifier(123 /* GetKeyword */)) {
+ return parseAccessorDeclaration(145 /* GetAccessor */, fullStart, decorators, modifiers);
}
- else if (parseContextualModifier(127 /* SetKeyword */)) {
- return parseAccessorDeclaration(144 /* SetAccessor */, fullStart, decorators, modifiers);
+ else if (parseContextualModifier(129 /* SetKeyword */)) {
+ return parseAccessorDeclaration(146 /* SetAccessor */, fullStart, decorators, modifiers);
}
return undefined;
}
@@ -10470,28 +10814,38 @@ var ts;
var nameToken = token;
var propertyName = parsePropertyName();
// Disallowing of optional property assignments happens in the grammar checker.
- var questionToken = parseOptionalToken(52 /* QuestionToken */);
+ var questionToken = parseOptionalToken(53 /* QuestionToken */);
if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) {
return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken);
}
- // Parse to check if it is short-hand property assignment or normal property assignment
- if ((token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */) && tokenIsIdentifier) {
- var shorthandDeclaration = createNode(244 /* ShorthandPropertyAssignment */, fullStart);
+ // 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(246 /* ShorthandPropertyAssignment */, fullStart);
shorthandDeclaration.name = propertyName;
shorthandDeclaration.questionToken = questionToken;
+ var equalsToken = parseOptionalToken(56 /* EqualsToken */);
+ if (equalsToken) {
+ shorthandDeclaration.equalsToken = equalsToken;
+ shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher);
+ }
return finishNode(shorthandDeclaration);
}
else {
- var propertyAssignment = createNode(243 /* PropertyAssignment */, fullStart);
+ var propertyAssignment = createNode(245 /* PropertyAssignment */, fullStart);
propertyAssignment.name = propertyName;
propertyAssignment.questionToken = questionToken;
- parseExpected(53 /* ColonToken */);
+ parseExpected(54 /* ColonToken */);
propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher);
return finishNode(propertyAssignment);
}
}
function parseObjectLiteralExpression() {
- var node = createNode(163 /* ObjectLiteralExpression */);
+ var node = createNode(165 /* ObjectLiteralExpression */);
parseExpected(15 /* OpenBraceToken */);
if (scanner.hasPrecedingLineBreak()) {
node.flags |= 2048 /* MultiLine */;
@@ -10510,9 +10864,9 @@ var ts;
if (saveDecoratorContext) {
setDecoratorContext(false);
}
- var node = createNode(171 /* FunctionExpression */);
+ var node = createNode(173 /* FunctionExpression */);
setModifiers(node, parseModifiers());
- parseExpected(85 /* FunctionKeyword */);
+ parseExpected(87 /* FunctionKeyword */);
node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */);
var isGenerator = !!node.asteriskToken;
var isAsync = !!(node.flags & 512 /* Async */);
@@ -10521,7 +10875,7 @@ var ts;
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
isAsync ? doInAwaitContext(parseOptionalIdentifier) :
parseOptionalIdentifier();
- fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node);
+ fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node);
node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false);
if (saveDecoratorContext) {
setDecoratorContext(true);
@@ -10532,8 +10886,8 @@ var ts;
return isIdentifier() ? parseIdentifier() : undefined;
}
function parseNewExpression() {
- var node = createNode(167 /* NewExpression */);
- parseExpected(90 /* NewKeyword */);
+ var node = createNode(169 /* NewExpression */);
+ parseExpected(92 /* NewKeyword */);
node.expression = parseMemberExpressionOrHigher();
node.typeArguments = tryParse(parseTypeArgumentsInExpression);
if (node.typeArguments || token === 17 /* OpenParenToken */) {
@@ -10543,7 +10897,7 @@ var ts;
}
// STATEMENTS
function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
- var node = createNode(190 /* Block */);
+ var node = createNode(192 /* Block */);
if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) {
node.statements = parseList(1 /* BlockStatements */, parseStatement);
parseExpected(16 /* CloseBraceToken */);
@@ -10573,25 +10927,25 @@ var ts;
return block;
}
function parseEmptyStatement() {
- var node = createNode(192 /* EmptyStatement */);
+ var node = createNode(194 /* EmptyStatement */);
parseExpected(23 /* SemicolonToken */);
return finishNode(node);
}
function parseIfStatement() {
- var node = createNode(194 /* IfStatement */);
- parseExpected(86 /* IfKeyword */);
+ var node = createNode(196 /* IfStatement */);
+ parseExpected(88 /* IfKeyword */);
parseExpected(17 /* OpenParenToken */);
node.expression = allowInAnd(parseExpression);
parseExpected(18 /* CloseParenToken */);
node.thenStatement = parseStatement();
- node.elseStatement = parseOptional(78 /* ElseKeyword */) ? parseStatement() : undefined;
+ node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined;
return finishNode(node);
}
function parseDoStatement() {
- var node = createNode(195 /* DoStatement */);
- parseExpected(77 /* DoKeyword */);
+ var node = createNode(197 /* DoStatement */);
+ parseExpected(79 /* DoKeyword */);
node.statement = parseStatement();
- parseExpected(102 /* WhileKeyword */);
+ parseExpected(104 /* WhileKeyword */);
parseExpected(17 /* OpenParenToken */);
node.expression = allowInAnd(parseExpression);
parseExpected(18 /* CloseParenToken */);
@@ -10603,8 +10957,8 @@ var ts;
return finishNode(node);
}
function parseWhileStatement() {
- var node = createNode(196 /* WhileStatement */);
- parseExpected(102 /* WhileKeyword */);
+ var node = createNode(198 /* WhileStatement */);
+ parseExpected(104 /* WhileKeyword */);
parseExpected(17 /* OpenParenToken */);
node.expression = allowInAnd(parseExpression);
parseExpected(18 /* CloseParenToken */);
@@ -10613,11 +10967,11 @@ var ts;
}
function parseForOrForInOrForOfStatement() {
var pos = getNodePos();
- parseExpected(84 /* ForKeyword */);
+ parseExpected(86 /* ForKeyword */);
parseExpected(17 /* OpenParenToken */);
var initializer = undefined;
if (token !== 23 /* SemicolonToken */) {
- if (token === 100 /* VarKeyword */ || token === 106 /* LetKeyword */ || token === 72 /* ConstKeyword */) {
+ if (token === 102 /* VarKeyword */ || token === 108 /* LetKeyword */ || token === 74 /* ConstKeyword */) {
initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true);
}
else {
@@ -10625,22 +10979,22 @@ var ts;
}
}
var forOrForInOrForOfStatement;
- if (parseOptional(88 /* InKeyword */)) {
- var forInStatement = createNode(198 /* ForInStatement */, pos);
+ if (parseOptional(90 /* InKeyword */)) {
+ var forInStatement = createNode(200 /* ForInStatement */, pos);
forInStatement.initializer = initializer;
forInStatement.expression = allowInAnd(parseExpression);
parseExpected(18 /* CloseParenToken */);
forOrForInOrForOfStatement = forInStatement;
}
- else if (parseOptional(132 /* OfKeyword */)) {
- var forOfStatement = createNode(199 /* ForOfStatement */, pos);
+ else if (parseOptional(134 /* OfKeyword */)) {
+ var forOfStatement = createNode(201 /* ForOfStatement */, pos);
forOfStatement.initializer = initializer;
forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher);
parseExpected(18 /* CloseParenToken */);
forOrForInOrForOfStatement = forOfStatement;
}
else {
- var forStatement = createNode(197 /* ForStatement */, pos);
+ var forStatement = createNode(199 /* ForStatement */, pos);
forStatement.initializer = initializer;
parseExpected(23 /* SemicolonToken */);
if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) {
@@ -10658,7 +11012,7 @@ var ts;
}
function parseBreakOrContinueStatement(kind) {
var node = createNode(kind);
- parseExpected(kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */);
+ parseExpected(kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */);
if (!canParseSemicolon()) {
node.label = parseIdentifier();
}
@@ -10666,8 +11020,8 @@ var ts;
return finishNode(node);
}
function parseReturnStatement() {
- var node = createNode(202 /* ReturnStatement */);
- parseExpected(92 /* ReturnKeyword */);
+ var node = createNode(204 /* ReturnStatement */);
+ parseExpected(94 /* ReturnKeyword */);
if (!canParseSemicolon()) {
node.expression = allowInAnd(parseExpression);
}
@@ -10675,8 +11029,8 @@ var ts;
return finishNode(node);
}
function parseWithStatement() {
- var node = createNode(203 /* WithStatement */);
- parseExpected(103 /* WithKeyword */);
+ var node = createNode(205 /* WithStatement */);
+ parseExpected(105 /* WithKeyword */);
parseExpected(17 /* OpenParenToken */);
node.expression = allowInAnd(parseExpression);
parseExpected(18 /* CloseParenToken */);
@@ -10684,30 +11038,30 @@ var ts;
return finishNode(node);
}
function parseCaseClause() {
- var node = createNode(239 /* CaseClause */);
- parseExpected(69 /* CaseKeyword */);
+ var node = createNode(241 /* CaseClause */);
+ parseExpected(71 /* CaseKeyword */);
node.expression = allowInAnd(parseExpression);
- parseExpected(53 /* ColonToken */);
+ parseExpected(54 /* ColonToken */);
node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
return finishNode(node);
}
function parseDefaultClause() {
- var node = createNode(240 /* DefaultClause */);
- parseExpected(75 /* DefaultKeyword */);
- parseExpected(53 /* ColonToken */);
+ var node = createNode(242 /* DefaultClause */);
+ parseExpected(77 /* DefaultKeyword */);
+ parseExpected(54 /* ColonToken */);
node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
return finishNode(node);
}
function parseCaseOrDefaultClause() {
- return token === 69 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause();
+ return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause();
}
function parseSwitchStatement() {
- var node = createNode(204 /* SwitchStatement */);
- parseExpected(94 /* SwitchKeyword */);
+ var node = createNode(206 /* SwitchStatement */);
+ parseExpected(96 /* SwitchKeyword */);
parseExpected(17 /* OpenParenToken */);
node.expression = allowInAnd(parseExpression);
parseExpected(18 /* CloseParenToken */);
- var caseBlock = createNode(218 /* CaseBlock */, scanner.getStartPos());
+ var caseBlock = createNode(220 /* CaseBlock */, scanner.getStartPos());
parseExpected(15 /* OpenBraceToken */);
caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause);
parseExpected(16 /* CloseBraceToken */);
@@ -10722,29 +11076,29 @@ var ts;
// 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(206 /* ThrowStatement */);
- parseExpected(96 /* ThrowKeyword */);
+ var node = createNode(208 /* 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(207 /* TryStatement */);
- parseExpected(98 /* TryKeyword */);
+ var node = createNode(209 /* TryStatement */);
+ parseExpected(100 /* TryKeyword */);
node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
- node.catchClause = token === 70 /* CatchKeyword */ ? parseCatchClause() : undefined;
+ 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 === 83 /* FinallyKeyword */) {
- parseExpected(83 /* FinallyKeyword */);
+ if (!node.catchClause || token === 85 /* FinallyKeyword */) {
+ parseExpected(85 /* FinallyKeyword */);
node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
}
return finishNode(node);
}
function parseCatchClause() {
- var result = createNode(242 /* CatchClause */);
- parseExpected(70 /* CatchKeyword */);
+ var result = createNode(244 /* CatchClause */);
+ parseExpected(72 /* CatchKeyword */);
if (parseExpected(17 /* OpenParenToken */)) {
result.variableDeclaration = parseVariableDeclaration();
}
@@ -10753,8 +11107,8 @@ var ts;
return finishNode(result);
}
function parseDebuggerStatement() {
- var node = createNode(208 /* DebuggerStatement */);
- parseExpected(74 /* DebuggerKeyword */);
+ var node = createNode(210 /* DebuggerStatement */);
+ parseExpected(76 /* DebuggerKeyword */);
parseSemicolon();
return finishNode(node);
}
@@ -10764,43 +11118,40 @@ var ts;
// a colon.
var fullStart = scanner.getStartPos();
var expression = allowInAnd(parseExpression);
- if (expression.kind === 67 /* Identifier */ && parseOptional(53 /* ColonToken */)) {
- var labeledStatement = createNode(205 /* LabeledStatement */, fullStart);
+ if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) {
+ var labeledStatement = createNode(207 /* LabeledStatement */, fullStart);
labeledStatement.label = expression;
labeledStatement.statement = parseStatement();
return finishNode(labeledStatement);
}
else {
- var expressionStatement = createNode(193 /* ExpressionStatement */, fullStart);
+ var expressionStatement = createNode(195 /* ExpressionStatement */, fullStart);
expressionStatement.expression = expression;
parseSemicolon();
return finishNode(expressionStatement);
}
}
- function isIdentifierOrKeyword() {
- return token >= 67 /* Identifier */;
- }
function nextTokenIsIdentifierOrKeywordOnSameLine() {
nextToken();
- return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
+ return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsFunctionKeywordOnSameLine() {
nextToken();
- return token === 85 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak();
+ return token === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() {
nextToken();
- return (isIdentifierOrKeyword() || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak();
+ return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration() {
while (true) {
switch (token) {
- case 100 /* VarKeyword */:
- case 106 /* LetKeyword */:
- case 72 /* ConstKeyword */:
- case 85 /* FunctionKeyword */:
- case 71 /* ClassKeyword */:
- case 79 /* EnumKeyword */:
+ 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
@@ -10823,36 +11174,36 @@ var ts;
// I {}
//
// could be legal, it would add complexity for very little gain.
- case 105 /* InterfaceKeyword */:
- case 130 /* TypeKeyword */:
+ case 107 /* InterfaceKeyword */:
+ case 132 /* TypeKeyword */:
return nextTokenIsIdentifierOnSameLine();
- case 123 /* ModuleKeyword */:
- case 124 /* NamespaceKeyword */:
+ case 125 /* ModuleKeyword */:
+ case 126 /* NamespaceKeyword */:
return nextTokenIsIdentifierOrStringLiteralOnSameLine();
- case 116 /* AsyncKeyword */:
- case 120 /* DeclareKeyword */:
+ 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 87 /* ImportKeyword */:
+ case 89 /* ImportKeyword */:
nextToken();
return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ ||
- token === 15 /* OpenBraceToken */ || isIdentifierOrKeyword();
- case 80 /* ExportKeyword */:
+ token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token);
+ case 82 /* ExportKeyword */:
nextToken();
- if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ ||
- token === 15 /* OpenBraceToken */ || token === 75 /* DefaultKeyword */) {
+ if (token === 56 /* EqualsToken */ || token === 37 /* AsteriskToken */ ||
+ token === 15 /* OpenBraceToken */ || token === 77 /* DefaultKeyword */) {
return true;
}
continue;
- case 110 /* PublicKeyword */:
- case 108 /* PrivateKeyword */:
- case 109 /* ProtectedKeyword */:
- case 111 /* StaticKeyword */:
- case 113 /* AbstractKeyword */:
+ case 113 /* StaticKeyword */:
nextToken();
continue;
default:
@@ -10865,47 +11216,47 @@ var ts;
}
function isStartOfStatement() {
switch (token) {
- case 54 /* AtToken */:
+ case 55 /* AtToken */:
case 23 /* SemicolonToken */:
case 15 /* OpenBraceToken */:
- case 100 /* VarKeyword */:
- case 106 /* LetKeyword */:
- case 85 /* FunctionKeyword */:
- case 71 /* ClassKeyword */:
- case 79 /* EnumKeyword */:
- case 86 /* IfKeyword */:
- case 77 /* DoKeyword */:
- case 102 /* WhileKeyword */:
- case 84 /* ForKeyword */:
- case 73 /* ContinueKeyword */:
- case 68 /* BreakKeyword */:
- case 92 /* ReturnKeyword */:
- case 103 /* WithKeyword */:
- case 94 /* SwitchKeyword */:
- case 96 /* ThrowKeyword */:
- case 98 /* TryKeyword */:
- case 74 /* DebuggerKeyword */:
+ 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 70 /* CatchKeyword */:
- case 83 /* FinallyKeyword */:
+ case 72 /* CatchKeyword */:
+ case 85 /* FinallyKeyword */:
return true;
- case 72 /* ConstKeyword */:
- case 80 /* ExportKeyword */:
- case 87 /* ImportKeyword */:
+ case 74 /* ConstKeyword */:
+ case 82 /* ExportKeyword */:
+ case 89 /* ImportKeyword */:
return isStartOfDeclaration();
- case 116 /* AsyncKeyword */:
- case 120 /* DeclareKeyword */:
- case 105 /* InterfaceKeyword */:
- case 123 /* ModuleKeyword */:
- case 124 /* NamespaceKeyword */:
- case 130 /* TypeKeyword */:
+ case 118 /* AsyncKeyword */:
+ case 122 /* DeclareKeyword */:
+ case 107 /* InterfaceKeyword */:
+ case 125 /* ModuleKeyword */:
+ case 126 /* NamespaceKeyword */:
+ case 132 /* TypeKeyword */:
// When these don't start a declaration, they're an identifier in an expression statement
return true;
- case 110 /* PublicKeyword */:
- case 108 /* PrivateKeyword */:
- case 109 /* ProtectedKeyword */:
- case 111 /* StaticKeyword */:
+ 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);
@@ -10928,61 +11279,61 @@ var ts;
return parseEmptyStatement();
case 15 /* OpenBraceToken */:
return parseBlock(/*ignoreMissingOpenBrace*/ false);
- case 100 /* VarKeyword */:
+ case 102 /* VarKeyword */:
return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined);
- case 106 /* LetKeyword */:
+ case 108 /* LetKeyword */:
if (isLetDeclaration()) {
return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined);
}
break;
- case 85 /* FunctionKeyword */:
+ case 87 /* FunctionKeyword */:
return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined);
- case 71 /* ClassKeyword */:
+ case 73 /* ClassKeyword */:
return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined);
- case 86 /* IfKeyword */:
+ case 88 /* IfKeyword */:
return parseIfStatement();
- case 77 /* DoKeyword */:
+ case 79 /* DoKeyword */:
return parseDoStatement();
- case 102 /* WhileKeyword */:
+ case 104 /* WhileKeyword */:
return parseWhileStatement();
- case 84 /* ForKeyword */:
+ case 86 /* ForKeyword */:
return parseForOrForInOrForOfStatement();
- case 73 /* ContinueKeyword */:
- return parseBreakOrContinueStatement(200 /* ContinueStatement */);
- case 68 /* BreakKeyword */:
- return parseBreakOrContinueStatement(201 /* BreakStatement */);
- case 92 /* ReturnKeyword */:
+ case 75 /* ContinueKeyword */:
+ return parseBreakOrContinueStatement(202 /* ContinueStatement */);
+ case 70 /* BreakKeyword */:
+ return parseBreakOrContinueStatement(203 /* BreakStatement */);
+ case 94 /* ReturnKeyword */:
return parseReturnStatement();
- case 103 /* WithKeyword */:
+ case 105 /* WithKeyword */:
return parseWithStatement();
- case 94 /* SwitchKeyword */:
+ case 96 /* SwitchKeyword */:
return parseSwitchStatement();
- case 96 /* ThrowKeyword */:
+ case 98 /* ThrowKeyword */:
return parseThrowStatement();
- case 98 /* TryKeyword */:
+ case 100 /* TryKeyword */:
// Include 'catch' and 'finally' for error recovery.
- case 70 /* CatchKeyword */:
- case 83 /* FinallyKeyword */:
+ case 72 /* CatchKeyword */:
+ case 85 /* FinallyKeyword */:
return parseTryStatement();
- case 74 /* DebuggerKeyword */:
+ case 76 /* DebuggerKeyword */:
return parseDebuggerStatement();
- case 54 /* AtToken */:
+ case 55 /* AtToken */:
return parseDeclaration();
- case 116 /* AsyncKeyword */:
- case 105 /* InterfaceKeyword */:
- case 130 /* TypeKeyword */:
- case 123 /* ModuleKeyword */:
- case 124 /* NamespaceKeyword */:
- case 120 /* DeclareKeyword */:
- case 72 /* ConstKeyword */:
- case 79 /* EnumKeyword */:
- case 80 /* ExportKeyword */:
- case 87 /* ImportKeyword */:
- case 108 /* PrivateKeyword */:
- case 109 /* ProtectedKeyword */:
- case 110 /* PublicKeyword */:
- case 113 /* AbstractKeyword */:
- case 111 /* StaticKeyword */:
+ 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 */:
if (isStartOfDeclaration()) {
return parseDeclaration();
}
@@ -10995,35 +11346,35 @@ var ts;
var decorators = parseDecorators();
var modifiers = parseModifiers();
switch (token) {
- case 100 /* VarKeyword */:
- case 106 /* LetKeyword */:
- case 72 /* ConstKeyword */:
+ case 102 /* VarKeyword */:
+ case 108 /* LetKeyword */:
+ case 74 /* ConstKeyword */:
return parseVariableStatement(fullStart, decorators, modifiers);
- case 85 /* FunctionKeyword */:
+ case 87 /* FunctionKeyword */:
return parseFunctionDeclaration(fullStart, decorators, modifiers);
- case 71 /* ClassKeyword */:
+ case 73 /* ClassKeyword */:
return parseClassDeclaration(fullStart, decorators, modifiers);
- case 105 /* InterfaceKeyword */:
+ case 107 /* InterfaceKeyword */:
return parseInterfaceDeclaration(fullStart, decorators, modifiers);
- case 130 /* TypeKeyword */:
+ case 132 /* TypeKeyword */:
return parseTypeAliasDeclaration(fullStart, decorators, modifiers);
- case 79 /* EnumKeyword */:
+ case 81 /* EnumKeyword */:
return parseEnumDeclaration(fullStart, decorators, modifiers);
- case 123 /* ModuleKeyword */:
- case 124 /* NamespaceKeyword */:
+ case 125 /* ModuleKeyword */:
+ case 126 /* NamespaceKeyword */:
return parseModuleDeclaration(fullStart, decorators, modifiers);
- case 87 /* ImportKeyword */:
+ case 89 /* ImportKeyword */:
return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers);
- case 80 /* ExportKeyword */:
+ case 82 /* ExportKeyword */:
nextToken();
- return token === 75 /* DefaultKeyword */ || token === 55 /* EqualsToken */ ?
+ 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(229 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected);
+ var node = createMissingNode(231 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected);
node.pos = fullStart;
node.decorators = decorators;
setModifiers(node, modifiers);
@@ -11045,24 +11396,24 @@ var ts;
// DECLARATIONS
function parseArrayBindingElement() {
if (token === 24 /* CommaToken */) {
- return createNode(185 /* OmittedExpression */);
+ return createNode(187 /* OmittedExpression */);
}
- var node = createNode(161 /* BindingElement */);
+ var node = createNode(163 /* BindingElement */);
node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */);
node.name = parseIdentifierOrPattern();
node.initializer = parseBindingElementInitializer(/*inParameter*/ false);
return finishNode(node);
}
function parseObjectBindingElement() {
- var node = createNode(161 /* BindingElement */);
+ var node = createNode(163 /* BindingElement */);
// TODO(andersh): Handle computed properties
var tokenIsIdentifier = isIdentifier();
var propertyName = parsePropertyName();
- if (tokenIsIdentifier && token !== 53 /* ColonToken */) {
+ if (tokenIsIdentifier && token !== 54 /* ColonToken */) {
node.name = propertyName;
}
else {
- parseExpected(53 /* ColonToken */);
+ parseExpected(54 /* ColonToken */);
node.propertyName = propertyName;
node.name = parseIdentifierOrPattern();
}
@@ -11070,14 +11421,14 @@ var ts;
return finishNode(node);
}
function parseObjectBindingPattern() {
- var node = createNode(159 /* ObjectBindingPattern */);
+ var node = createNode(161 /* ObjectBindingPattern */);
parseExpected(15 /* OpenBraceToken */);
node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement);
parseExpected(16 /* CloseBraceToken */);
return finishNode(node);
}
function parseArrayBindingPattern() {
- var node = createNode(160 /* ArrayBindingPattern */);
+ var node = createNode(162 /* ArrayBindingPattern */);
parseExpected(19 /* OpenBracketToken */);
node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement);
parseExpected(20 /* CloseBracketToken */);
@@ -11096,7 +11447,7 @@ var ts;
return parseIdentifier();
}
function parseVariableDeclaration() {
- var node = createNode(209 /* VariableDeclaration */);
+ var node = createNode(211 /* VariableDeclaration */);
node.name = parseIdentifierOrPattern();
node.type = parseTypeAnnotation();
if (!isInOrOfKeyword(token)) {
@@ -11105,14 +11456,14 @@ var ts;
return finishNode(node);
}
function parseVariableDeclarationList(inForStatementInitializer) {
- var node = createNode(210 /* VariableDeclarationList */);
+ var node = createNode(212 /* VariableDeclarationList */);
switch (token) {
- case 100 /* VarKeyword */:
+ case 102 /* VarKeyword */:
break;
- case 106 /* LetKeyword */:
+ case 108 /* LetKeyword */:
node.flags |= 16384 /* Let */;
break;
- case 72 /* ConstKeyword */:
+ case 74 /* ConstKeyword */:
node.flags |= 32768 /* Const */;
break;
default:
@@ -11128,7 +11479,7 @@ var ts;
// 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 === 132 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) {
+ if (token === 134 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) {
node.declarations = createMissingList();
}
else {
@@ -11143,7 +11494,7 @@ var ts;
return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */;
}
function parseVariableStatement(fullStart, decorators, modifiers) {
- var node = createNode(191 /* VariableStatement */, fullStart);
+ var node = createNode(193 /* VariableStatement */, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false);
@@ -11151,29 +11502,29 @@ var ts;
return finishNode(node);
}
function parseFunctionDeclaration(fullStart, decorators, modifiers) {
- var node = createNode(211 /* FunctionDeclaration */, fullStart);
+ var node = createNode(213 /* FunctionDeclaration */, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
- parseExpected(85 /* FunctionKeyword */);
+ parseExpected(87 /* FunctionKeyword */);
node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */);
node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier();
var isGenerator = !!node.asteriskToken;
var isAsync = !!(node.flags & 512 /* Async */);
- fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node);
+ fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node);
node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected);
return finishNode(node);
}
function parseConstructorDeclaration(pos, decorators, modifiers) {
- var node = createNode(142 /* Constructor */, pos);
+ var node = createNode(144 /* Constructor */, pos);
node.decorators = decorators;
setModifiers(node, modifiers);
- parseExpected(119 /* ConstructorKeyword */);
- fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node);
+ 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 finishNode(node);
}
function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) {
- var method = createNode(141 /* MethodDeclaration */, fullStart);
+ var method = createNode(143 /* MethodDeclaration */, fullStart);
method.decorators = decorators;
setModifiers(method, modifiers);
method.asteriskToken = asteriskToken;
@@ -11181,12 +11532,12 @@ var ts;
method.questionToken = questionToken;
var isGenerator = !!asteriskToken;
var isAsync = !!(method.flags & 512 /* Async */);
- fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method);
+ fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method);
method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage);
return finishNode(method);
}
function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) {
- var property = createNode(139 /* PropertyDeclaration */, fullStart);
+ var property = createNode(141 /* PropertyDeclaration */, fullStart);
property.decorators = decorators;
setModifiers(property, modifiers);
property.name = name;
@@ -11212,7 +11563,7 @@ var ts;
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(52 /* QuestionToken */);
+ 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);
}
@@ -11228,16 +11579,16 @@ var ts;
node.decorators = decorators;
setModifiers(node, modifiers);
node.name = parsePropertyName();
- fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node);
+ 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 110 /* PublicKeyword */:
- case 108 /* PrivateKeyword */:
- case 109 /* ProtectedKeyword */:
- case 111 /* StaticKeyword */:
+ case 112 /* PublicKeyword */:
+ case 110 /* PrivateKeyword */:
+ case 111 /* ProtectedKeyword */:
+ case 113 /* StaticKeyword */:
return true;
default:
return false;
@@ -11245,7 +11596,7 @@ var ts;
}
function isClassMemberStart() {
var idToken;
- if (token === 54 /* AtToken */) {
+ if (token === 55 /* AtToken */) {
return true;
}
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier.
@@ -11278,7 +11629,7 @@ var ts;
// 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 === 127 /* SetKeyword */ || idToken === 121 /* GetKeyword */) {
+ 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
@@ -11286,9 +11637,9 @@ var ts;
switch (token) {
case 17 /* OpenParenToken */: // Method declaration
case 25 /* LessThanToken */: // Generic Method declaration
- case 53 /* ColonToken */: // Type Annotation for declaration
- case 55 /* EqualsToken */: // Initializer for declaration
- case 52 /* QuestionToken */:
+ case 54 /* ColonToken */: // Type Annotation for declaration
+ case 56 /* EqualsToken */: // Initializer for declaration
+ case 53 /* QuestionToken */:
return true;
default:
// Covers
@@ -11305,14 +11656,14 @@ var ts;
var decorators;
while (true) {
var decoratorStart = getNodePos();
- if (!parseOptional(54 /* AtToken */)) {
+ if (!parseOptional(55 /* AtToken */)) {
break;
}
if (!decorators) {
decorators = [];
decorators.pos = scanner.getStartPos();
}
- var decorator = createNode(137 /* Decorator */, decoratorStart);
+ var decorator = createNode(139 /* Decorator */, decoratorStart);
decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
decorators.push(finishNode(decorator));
}
@@ -11346,7 +11697,7 @@ var ts;
function parseModifiersForArrowFunction() {
var flags = 0;
var modifiers;
- if (token === 116 /* AsyncKeyword */) {
+ if (token === 118 /* AsyncKeyword */) {
var modifierStart = scanner.getStartPos();
var modifierKind = token;
nextToken();
@@ -11361,7 +11712,7 @@ var ts;
}
function parseClassElement() {
if (token === 23 /* SemicolonToken */) {
- var result = createNode(189 /* SemicolonClassElement */);
+ var result = createNode(191 /* SemicolonClassElement */);
nextToken();
return finishNode(result);
}
@@ -11372,7 +11723,7 @@ var ts;
if (accessor) {
return accessor;
}
- if (token === 119 /* ConstructorKeyword */) {
+ if (token === 121 /* ConstructorKeyword */) {
return parseConstructorDeclaration(fullStart, decorators, modifiers);
}
if (isIndexSignature()) {
@@ -11380,7 +11731,7 @@ var ts;
}
// 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 (isIdentifierOrKeyword() ||
+ if (ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 /* StringLiteral */ ||
token === 8 /* NumericLiteral */ ||
token === 37 /* AsteriskToken */ ||
@@ -11389,7 +11740,7 @@ var ts;
}
if (decorators || modifiers) {
// treat this as a property declaration with a missing name.
- var name_7 = createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected);
+ 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.
@@ -11399,17 +11750,17 @@ var ts;
return parseClassDeclarationOrExpression(
/*fullStart*/ scanner.getStartPos(),
/*decorators*/ undefined,
- /*modifiers*/ undefined, 184 /* ClassExpression */);
+ /*modifiers*/ undefined, 186 /* ClassExpression */);
}
function parseClassDeclaration(fullStart, decorators, modifiers) {
- return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212 /* ClassDeclaration */);
+ return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 214 /* ClassDeclaration */);
}
function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) {
var node = createNode(kind, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
- parseExpected(71 /* ClassKeyword */);
- node.name = parseOptionalIdentifier();
+ parseExpected(73 /* ClassKeyword */);
+ node.name = parseNameOfClassDeclarationOrExpression();
node.typeParameters = parseTypeParameters();
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true);
if (parseExpected(15 /* OpenBraceToken */)) {
@@ -11423,6 +11774,19 @@ var ts;
}
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 }
@@ -11435,8 +11799,8 @@ var ts;
return parseList(20 /* HeritageClauses */, parseHeritageClause);
}
function parseHeritageClause() {
- if (token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */) {
- var node = createNode(241 /* HeritageClause */);
+ if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) {
+ var node = createNode(243 /* HeritageClause */);
node.token = token;
nextToken();
node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments);
@@ -11445,7 +11809,7 @@ var ts;
return undefined;
}
function parseExpressionWithTypeArguments() {
- var node = createNode(186 /* ExpressionWithTypeArguments */);
+ var node = createNode(188 /* ExpressionWithTypeArguments */);
node.expression = parseLeftHandSideExpressionOrHigher();
if (token === 25 /* LessThanToken */) {
node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */);
@@ -11453,16 +11817,16 @@ var ts;
return finishNode(node);
}
function isHeritageClause() {
- return token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */;
+ return token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */;
}
function parseClassMembers() {
return parseList(5 /* ClassMembers */, parseClassElement);
}
function parseInterfaceDeclaration(fullStart, decorators, modifiers) {
- var node = createNode(213 /* InterfaceDeclaration */, fullStart);
+ var node = createNode(215 /* InterfaceDeclaration */, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
- parseExpected(105 /* InterfaceKeyword */);
+ parseExpected(107 /* InterfaceKeyword */);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false);
@@ -11470,13 +11834,13 @@ var ts;
return finishNode(node);
}
function parseTypeAliasDeclaration(fullStart, decorators, modifiers) {
- var node = createNode(214 /* TypeAliasDeclaration */, fullStart);
+ var node = createNode(216 /* TypeAliasDeclaration */, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
- parseExpected(130 /* TypeKeyword */);
+ parseExpected(132 /* TypeKeyword */);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
- parseExpected(55 /* EqualsToken */);
+ parseExpected(56 /* EqualsToken */);
node.type = parseType();
parseSemicolon();
return finishNode(node);
@@ -11486,16 +11850,16 @@ var ts;
// ConstantEnumMemberSection, which starts at the beginning of an enum declaration
// or any time an integer literal initializer is encountered.
function parseEnumMember() {
- var node = createNode(245 /* EnumMember */, scanner.getStartPos());
+ var node = createNode(247 /* EnumMember */, scanner.getStartPos());
node.name = parsePropertyName();
node.initializer = allowInAnd(parseNonParameterInitializer);
return finishNode(node);
}
function parseEnumDeclaration(fullStart, decorators, modifiers) {
- var node = createNode(215 /* EnumDeclaration */, fullStart);
+ var node = createNode(217 /* EnumDeclaration */, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
- parseExpected(79 /* EnumKeyword */);
+ parseExpected(81 /* EnumKeyword */);
node.name = parseIdentifier();
if (parseExpected(15 /* OpenBraceToken */)) {
node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember);
@@ -11507,7 +11871,7 @@ var ts;
return finishNode(node);
}
function parseModuleBlock() {
- var node = createNode(217 /* ModuleBlock */, scanner.getStartPos());
+ var node = createNode(219 /* ModuleBlock */, scanner.getStartPos());
if (parseExpected(15 /* OpenBraceToken */)) {
node.statements = parseList(1 /* BlockStatements */, parseStatement);
parseExpected(16 /* CloseBraceToken */);
@@ -11518,18 +11882,21 @@ var ts;
return finishNode(node);
}
function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) {
- var node = createNode(216 /* ModuleDeclaration */, fullStart);
+ var node = createNode(218 /* 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 & 131072 /* Namespace */;
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(21 /* DotToken */)
- ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */)
+ ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag)
: parseModuleBlock();
return finishNode(node);
}
function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) {
- var node = createNode(216 /* ModuleDeclaration */, fullStart);
+ var node = createNode(218 /* ModuleDeclaration */, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
node.name = parseLiteralNode(/*internName*/ true);
@@ -11538,11 +11905,11 @@ var ts;
}
function parseModuleDeclaration(fullStart, decorators, modifiers) {
var flags = modifiers ? modifiers.flags : 0;
- if (parseOptional(124 /* NamespaceKeyword */)) {
+ if (parseOptional(126 /* NamespaceKeyword */)) {
flags |= 131072 /* Namespace */;
}
else {
- parseExpected(123 /* ModuleKeyword */);
+ parseExpected(125 /* ModuleKeyword */);
if (token === 9 /* StringLiteral */) {
return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers);
}
@@ -11550,42 +11917,42 @@ var ts;
return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags);
}
function isExternalModuleReference() {
- return token === 125 /* RequireKeyword */ &&
+ return token === 127 /* RequireKeyword */ &&
lookAhead(nextTokenIsOpenParen);
}
function nextTokenIsOpenParen() {
return nextToken() === 17 /* OpenParenToken */;
}
function nextTokenIsSlash() {
- return nextToken() === 38 /* SlashToken */;
+ return nextToken() === 39 /* SlashToken */;
}
function nextTokenIsCommaOrFromKeyword() {
nextToken();
return token === 24 /* CommaToken */ ||
- token === 131 /* FromKeyword */;
+ token === 133 /* FromKeyword */;
}
function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) {
- parseExpected(87 /* ImportKeyword */);
+ parseExpected(89 /* ImportKeyword */);
var afterImportPos = scanner.getStartPos();
var identifier;
if (isIdentifier()) {
identifier = parseIdentifier();
- if (token !== 24 /* CommaToken */ && token !== 131 /* FromKeyword */) {
+ if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) {
// ImportEquals declaration of type:
// import x = require("mod"); or
// import x = M.x;
- var importEqualsDeclaration = createNode(219 /* ImportEqualsDeclaration */, fullStart);
+ var importEqualsDeclaration = createNode(221 /* ImportEqualsDeclaration */, fullStart);
importEqualsDeclaration.decorators = decorators;
setModifiers(importEqualsDeclaration, modifiers);
importEqualsDeclaration.name = identifier;
- parseExpected(55 /* EqualsToken */);
+ parseExpected(56 /* EqualsToken */);
importEqualsDeclaration.moduleReference = parseModuleReference();
parseSemicolon();
return finishNode(importEqualsDeclaration);
}
}
// Import statement
- var importDeclaration = createNode(220 /* ImportDeclaration */, fullStart);
+ var importDeclaration = createNode(222 /* ImportDeclaration */, fullStart);
importDeclaration.decorators = decorators;
setModifiers(importDeclaration, modifiers);
// ImportDeclaration:
@@ -11595,7 +11962,7 @@ var ts;
token === 37 /* AsteriskToken */ ||
token === 15 /* OpenBraceToken */) {
importDeclaration.importClause = parseImportClause(identifier, afterImportPos);
- parseExpected(131 /* FromKeyword */);
+ parseExpected(133 /* FromKeyword */);
}
importDeclaration.moduleSpecifier = parseModuleSpecifier();
parseSemicolon();
@@ -11608,7 +11975,7 @@ var ts;
// NamedImports
// ImportedDefaultBinding, NameSpaceImport
// ImportedDefaultBinding, NamedImports
- var importClause = createNode(221 /* ImportClause */, fullStart);
+ var importClause = createNode(223 /* ImportClause */, fullStart);
if (identifier) {
// ImportedDefaultBinding:
// ImportedBinding
@@ -11618,7 +11985,7 @@ var ts;
// parse namespace or named imports
if (!importClause.name ||
parseOptional(24 /* CommaToken */)) {
- importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(223 /* NamedImports */);
+ importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(225 /* NamedImports */);
}
return finishNode(importClause);
}
@@ -11628,8 +11995,8 @@ var ts;
: parseEntityName(/*allowReservedWords*/ false);
}
function parseExternalModuleReference() {
- var node = createNode(230 /* ExternalModuleReference */);
- parseExpected(125 /* RequireKeyword */);
+ var node = createNode(232 /* ExternalModuleReference */);
+ parseExpected(127 /* RequireKeyword */);
parseExpected(17 /* OpenParenToken */);
node.expression = parseModuleSpecifier();
parseExpected(18 /* CloseParenToken */);
@@ -11650,9 +12017,9 @@ var ts;
function parseNamespaceImport() {
// NameSpaceImport:
// * as ImportedBinding
- var namespaceImport = createNode(222 /* NamespaceImport */);
+ var namespaceImport = createNode(224 /* NamespaceImport */);
parseExpected(37 /* AsteriskToken */);
- parseExpected(114 /* AsKeyword */);
+ parseExpected(116 /* AsKeyword */);
namespaceImport.name = parseIdentifier();
return finishNode(namespaceImport);
}
@@ -11665,14 +12032,14 @@ var ts;
// ImportsList:
// ImportSpecifier
// ImportsList, ImportSpecifier
- node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 223 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */);
+ node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 225 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */);
return finishNode(node);
}
function parseExportSpecifier() {
- return parseImportOrExportSpecifier(228 /* ExportSpecifier */);
+ return parseImportOrExportSpecifier(230 /* ExportSpecifier */);
}
function parseImportSpecifier() {
- return parseImportOrExportSpecifier(224 /* ImportSpecifier */);
+ return parseImportOrExportSpecifier(226 /* ImportSpecifier */);
}
function parseImportOrExportSpecifier(kind) {
var node = createNode(kind);
@@ -11686,9 +12053,9 @@ var ts;
var checkIdentifierStart = scanner.getTokenPos();
var checkIdentifierEnd = scanner.getTextPos();
var identifierName = parseIdentifierName();
- if (token === 114 /* AsKeyword */) {
+ if (token === 116 /* AsKeyword */) {
node.propertyName = identifierName;
- parseExpected(114 /* AsKeyword */);
+ parseExpected(116 /* AsKeyword */);
checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier();
checkIdentifierStart = scanner.getTokenPos();
checkIdentifierEnd = scanner.getTextPos();
@@ -11697,27 +12064,27 @@ var ts;
else {
node.name = identifierName;
}
- if (kind === 224 /* ImportSpecifier */ && checkIdentifierIsKeyword) {
+ if (kind === 226 /* 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(226 /* ExportDeclaration */, fullStart);
+ var node = createNode(228 /* ExportDeclaration */, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
if (parseOptional(37 /* AsteriskToken */)) {
- parseExpected(131 /* FromKeyword */);
+ parseExpected(133 /* FromKeyword */);
node.moduleSpecifier = parseModuleSpecifier();
}
else {
- node.exportClause = parseNamedImportsOrExports(227 /* NamedExports */);
+ node.exportClause = parseNamedImportsOrExports(229 /* 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 === 131 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) {
- parseExpected(131 /* FromKeyword */);
+ if (token === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) {
+ parseExpected(133 /* FromKeyword */);
node.moduleSpecifier = parseModuleSpecifier();
}
}
@@ -11725,14 +12092,14 @@ var ts;
return finishNode(node);
}
function parseExportAssignment(fullStart, decorators, modifiers) {
- var node = createNode(225 /* ExportAssignment */, fullStart);
+ var node = createNode(227 /* ExportAssignment */, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
- if (parseOptional(55 /* EqualsToken */)) {
+ if (parseOptional(56 /* EqualsToken */)) {
node.isExportEquals = true;
}
else {
- parseExpected(75 /* DefaultKeyword */);
+ parseExpected(77 /* DefaultKeyword */);
}
node.expression = parseAssignmentExpressionOrHigher();
parseSemicolon();
@@ -11798,10 +12165,10 @@ var ts;
function setExternalModuleIndicator(sourceFile) {
sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) {
return node.flags & 1 /* Export */
- || node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */
- || node.kind === 220 /* ImportDeclaration */
- || node.kind === 225 /* ExportAssignment */
- || node.kind === 226 /* ExportDeclaration */
+ || node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */
+ || node.kind === 222 /* ImportDeclaration */
+ || node.kind === 227 /* ExportAssignment */
+ || node.kind === 228 /* ExportDeclaration */
? node
: undefined;
});
@@ -11847,18 +12214,18 @@ var ts;
function isJSDocType() {
switch (token) {
case 37 /* AsteriskToken */:
- case 52 /* QuestionToken */:
+ case 53 /* QuestionToken */:
case 17 /* OpenParenToken */:
case 19 /* OpenBracketToken */:
- case 48 /* ExclamationToken */:
+ case 49 /* ExclamationToken */:
case 15 /* OpenBraceToken */:
- case 85 /* FunctionKeyword */:
+ case 87 /* FunctionKeyword */:
case 22 /* DotDotDotToken */:
- case 90 /* NewKeyword */:
- case 95 /* ThisKeyword */:
+ case 92 /* NewKeyword */:
+ case 97 /* ThisKeyword */:
return true;
}
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
JSDocParser.isJSDocType = isJSDocType;
function parseJSDocTypeExpressionForTests(content, start, length) {
@@ -11876,7 +12243,7 @@ var ts;
scanner.setText(sourceText, start, length);
// Prime the first token for us to start processing.
token = nextToken();
- var result = createNode(247 /* JSDocTypeExpression */);
+ var result = createNode(249 /* JSDocTypeExpression */);
parseExpected(15 /* OpenBraceToken */);
result.type = parseJSDocTopLevelType();
parseExpected(16 /* CloseBraceToken */);
@@ -11886,13 +12253,13 @@ var ts;
JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression;
function parseJSDocTopLevelType() {
var type = parseJSDocType();
- if (token === 46 /* BarToken */) {
- var unionType = createNode(251 /* JSDocUnionType */, type.pos);
+ if (token === 47 /* BarToken */) {
+ var unionType = createNode(253 /* JSDocUnionType */, type.pos);
unionType.types = parseJSDocTypeList(type);
type = finishNode(unionType);
}
- if (token === 55 /* EqualsToken */) {
- var optionalType = createNode(258 /* JSDocOptionalType */, type.pos);
+ if (token === 56 /* EqualsToken */) {
+ var optionalType = createNode(260 /* JSDocOptionalType */, type.pos);
nextToken();
optionalType.type = type;
type = finishNode(optionalType);
@@ -11903,20 +12270,20 @@ var ts;
var type = parseBasicTypeExpression();
while (true) {
if (token === 19 /* OpenBracketToken */) {
- var arrayType = createNode(250 /* JSDocArrayType */, type.pos);
+ var arrayType = createNode(252 /* JSDocArrayType */, type.pos);
arrayType.elementType = type;
nextToken();
parseExpected(20 /* CloseBracketToken */);
type = finishNode(arrayType);
}
- else if (token === 52 /* QuestionToken */) {
- var nullableType = createNode(253 /* JSDocNullableType */, type.pos);
+ else if (token === 53 /* QuestionToken */) {
+ var nullableType = createNode(255 /* JSDocNullableType */, type.pos);
nullableType.type = type;
nextToken();
type = finishNode(nullableType);
}
- else if (token === 48 /* ExclamationToken */) {
- var nonNullableType = createNode(254 /* JSDocNonNullableType */, type.pos);
+ else if (token === 49 /* ExclamationToken */) {
+ var nonNullableType = createNode(256 /* JSDocNonNullableType */, type.pos);
nonNullableType.type = type;
nextToken();
type = finishNode(nonNullableType);
@@ -11931,80 +12298,80 @@ var ts;
switch (token) {
case 37 /* AsteriskToken */:
return parseJSDocAllType();
- case 52 /* QuestionToken */:
+ case 53 /* QuestionToken */:
return parseJSDocUnknownOrNullableType();
case 17 /* OpenParenToken */:
return parseJSDocUnionType();
case 19 /* OpenBracketToken */:
return parseJSDocTupleType();
- case 48 /* ExclamationToken */:
+ case 49 /* ExclamationToken */:
return parseJSDocNonNullableType();
case 15 /* OpenBraceToken */:
return parseJSDocRecordType();
- case 85 /* FunctionKeyword */:
+ case 87 /* FunctionKeyword */:
return parseJSDocFunctionType();
case 22 /* DotDotDotToken */:
return parseJSDocVariadicType();
- case 90 /* NewKeyword */:
+ case 92 /* NewKeyword */:
return parseJSDocConstructorType();
- case 95 /* ThisKeyword */:
+ case 97 /* ThisKeyword */:
return parseJSDocThisType();
- case 115 /* AnyKeyword */:
- case 128 /* StringKeyword */:
- case 126 /* NumberKeyword */:
- case 118 /* BooleanKeyword */:
- case 129 /* SymbolKeyword */:
- case 101 /* VoidKeyword */:
+ case 117 /* AnyKeyword */:
+ case 130 /* StringKeyword */:
+ case 128 /* NumberKeyword */:
+ case 120 /* BooleanKeyword */:
+ case 131 /* SymbolKeyword */:
+ case 103 /* VoidKeyword */:
return parseTokenNode();
}
return parseJSDocTypeReference();
}
function parseJSDocThisType() {
- var result = createNode(262 /* JSDocThisType */);
+ var result = createNode(264 /* JSDocThisType */);
nextToken();
- parseExpected(53 /* ColonToken */);
+ parseExpected(54 /* ColonToken */);
result.type = parseJSDocType();
return finishNode(result);
}
function parseJSDocConstructorType() {
- var result = createNode(261 /* JSDocConstructorType */);
+ var result = createNode(263 /* JSDocConstructorType */);
nextToken();
- parseExpected(53 /* ColonToken */);
+ parseExpected(54 /* ColonToken */);
result.type = parseJSDocType();
return finishNode(result);
}
function parseJSDocVariadicType() {
- var result = createNode(260 /* JSDocVariadicType */);
+ var result = createNode(262 /* JSDocVariadicType */);
nextToken();
result.type = parseJSDocType();
return finishNode(result);
}
function parseJSDocFunctionType() {
- var result = createNode(259 /* JSDocFunctionType */);
+ var result = createNode(261 /* JSDocFunctionType */);
nextToken();
parseExpected(17 /* OpenParenToken */);
result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter);
checkForTrailingComma(result.parameters);
parseExpected(18 /* CloseParenToken */);
- if (token === 53 /* ColonToken */) {
+ if (token === 54 /* ColonToken */) {
nextToken();
result.type = parseJSDocType();
}
return finishNode(result);
}
function parseJSDocParameter() {
- var parameter = createNode(136 /* Parameter */);
+ var parameter = createNode(138 /* Parameter */);
parameter.type = parseJSDocType();
return finishNode(parameter);
}
function parseJSDocOptionalType(type) {
- var result = createNode(258 /* JSDocOptionalType */, type.pos);
+ var result = createNode(260 /* JSDocOptionalType */, type.pos);
nextToken();
result.type = type;
return finishNode(result);
}
function parseJSDocTypeReference() {
- var result = createNode(257 /* JSDocTypeReference */);
+ var result = createNode(259 /* JSDocTypeReference */);
result.name = parseSimplePropertyName();
while (parseOptional(21 /* DotToken */)) {
if (token === 25 /* LessThanToken */) {
@@ -12034,13 +12401,13 @@ var ts;
}
}
function parseQualifiedName(left) {
- var result = createNode(133 /* QualifiedName */, left.pos);
+ var result = createNode(135 /* QualifiedName */, left.pos);
result.left = left;
result.right = parseIdentifierName();
return finishNode(result);
}
function parseJSDocRecordType() {
- var result = createNode(255 /* JSDocRecordType */);
+ var result = createNode(257 /* JSDocRecordType */);
nextToken();
result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember);
checkForTrailingComma(result.members);
@@ -12048,22 +12415,22 @@ var ts;
return finishNode(result);
}
function parseJSDocRecordMember() {
- var result = createNode(256 /* JSDocRecordMember */);
+ var result = createNode(258 /* JSDocRecordMember */);
result.name = parseSimplePropertyName();
- if (token === 53 /* ColonToken */) {
+ if (token === 54 /* ColonToken */) {
nextToken();
result.type = parseJSDocType();
}
return finishNode(result);
}
function parseJSDocNonNullableType() {
- var result = createNode(254 /* JSDocNonNullableType */);
+ var result = createNode(256 /* JSDocNonNullableType */);
nextToken();
result.type = parseJSDocType();
return finishNode(result);
}
function parseJSDocTupleType() {
- var result = createNode(252 /* JSDocTupleType */);
+ var result = createNode(254 /* JSDocTupleType */);
nextToken();
result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType);
checkForTrailingComma(result.types);
@@ -12077,7 +12444,7 @@ var ts;
}
}
function parseJSDocUnionType() {
- var result = createNode(251 /* JSDocUnionType */);
+ var result = createNode(253 /* JSDocUnionType */);
nextToken();
result.types = parseJSDocTypeList(parseJSDocType());
parseExpected(18 /* CloseParenToken */);
@@ -12088,14 +12455,14 @@ var ts;
var types = [];
types.pos = firstType.pos;
types.push(firstType);
- while (parseOptional(46 /* BarToken */)) {
+ while (parseOptional(47 /* BarToken */)) {
types.push(parseJSDocType());
}
types.end = scanner.getStartPos();
return types;
}
function parseJSDocAllType() {
- var result = createNode(248 /* JSDocAllType */);
+ var result = createNode(250 /* JSDocAllType */);
nextToken();
return finishNode(result);
}
@@ -12116,13 +12483,13 @@ var ts;
token === 16 /* CloseBraceToken */ ||
token === 18 /* CloseParenToken */ ||
token === 27 /* GreaterThanToken */ ||
- token === 55 /* EqualsToken */ ||
- token === 46 /* BarToken */) {
- var result = createNode(249 /* JSDocUnknownType */, pos);
+ token === 56 /* EqualsToken */ ||
+ token === 47 /* BarToken */) {
+ var result = createNode(251 /* JSDocUnknownType */, pos);
return finishNode(result);
}
else {
- var result = createNode(253 /* JSDocNullableType */, pos);
+ var result = createNode(255 /* JSDocNullableType */, pos);
result.type = parseJSDocType();
return finishNode(result);
}
@@ -12210,7 +12577,7 @@ var ts;
if (!tags) {
return undefined;
}
- var result = createNode(263 /* JSDocComment */, start);
+ var result = createNode(265 /* JSDocComment */, start);
result.tags = tags;
return finishNode(result, end);
}
@@ -12221,7 +12588,7 @@ var ts;
}
function parseTag() {
ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */);
- var atToken = createNode(54 /* AtToken */, pos - 1);
+ var atToken = createNode(55 /* AtToken */, pos - 1);
atToken.end = pos;
var tagName = scanIdentifier();
if (!tagName) {
@@ -12247,7 +12614,7 @@ var ts;
return undefined;
}
function handleUnknownTag(atToken, tagName) {
- var result = createNode(264 /* JSDocTag */, atToken.pos);
+ var result = createNode(266 /* JSDocTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
return finishNode(result, pos);
@@ -12298,7 +12665,7 @@ var ts;
if (!typeExpression) {
typeExpression = tryParseTypeExpression();
}
- var result = createNode(265 /* JSDocParameterTag */, atToken.pos);
+ var result = createNode(267 /* JSDocParameterTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.preParameterName = preName;
@@ -12308,27 +12675,27 @@ var ts;
return finishNode(result, pos);
}
function handleReturnTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocReturnTag */; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocReturnTag */; })) {
parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text);
}
- var result = createNode(266 /* JSDocReturnTag */, atToken.pos);
+ var result = createNode(268 /* JSDocReturnTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = tryParseTypeExpression();
return finishNode(result, pos);
}
function handleTypeTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTypeTag */; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 269 /* JSDocTypeTag */; })) {
parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text);
}
- var result = createNode(267 /* JSDocTypeTag */, atToken.pos);
+ var result = createNode(269 /* JSDocTypeTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeExpression = tryParseTypeExpression();
return finishNode(result, pos);
}
function handleTemplateTag(atToken, tagName) {
- if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocTemplateTag */; })) {
+ if (ts.forEach(tags, function (t) { return t.kind === 270 /* JSDocTemplateTag */; })) {
parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text);
}
var typeParameters = [];
@@ -12341,7 +12708,7 @@ var ts;
parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected);
return undefined;
}
- var typeParameter = createNode(135 /* TypeParameter */, name_8.pos);
+ var typeParameter = createNode(137 /* TypeParameter */, name_8.pos);
typeParameter.name = name_8;
finishNode(typeParameter, pos);
typeParameters.push(typeParameter);
@@ -12352,7 +12719,7 @@ var ts;
pos++;
}
typeParameters.end = pos;
- var result = createNode(268 /* JSDocTemplateTag */, atToken.pos);
+ var result = createNode(270 /* JSDocTemplateTag */, atToken.pos);
result.atToken = atToken;
result.tagName = tagName;
result.typeParameters = typeParameters;
@@ -12373,7 +12740,7 @@ var ts;
if (startPos === pos) {
return undefined;
}
- var result = createNode(67 /* Identifier */, startPos);
+ var result = createNode(69 /* Identifier */, startPos);
result.text = content.substring(startPos, pos);
return finishNode(result, pos);
}
@@ -12496,7 +12863,7 @@ var ts;
switch (node.kind) {
case 9 /* StringLiteral */:
case 8 /* NumericLiteral */:
- case 67 /* Identifier */:
+ case 69 /* Identifier */:
return true;
}
return false;
@@ -12889,17 +13256,19 @@ var ts;
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 = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */;
var emitResolver = createResolver();
var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined");
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"); },
+ 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; },
@@ -13060,6 +13429,7 @@ var ts;
diagnostics.add(diagnostic);
}
function createSymbol(flags, name) {
+ symbolCount++;
return new Symbol(flags, name);
}
function getExcludedSymbolFlags(flags) {
@@ -13189,10 +13559,10 @@ var ts;
return nodeLinks[nodeId] || (nodeLinks[nodeId] = {});
}
function getSourceFile(node) {
- return ts.getAncestor(node, 246 /* SourceFile */);
+ return ts.getAncestor(node, 248 /* SourceFile */);
}
function isGlobalSourceFile(node) {
- return node.kind === 246 /* SourceFile */ && !ts.isExternalModule(node);
+ return node.kind === 248 /* SourceFile */ && !ts.isExternalModule(node);
}
function getSymbol(symbols, name, meaning) {
if (meaning && ts.hasProperty(symbols, name)) {
@@ -13211,18 +13581,62 @@ var ts;
}
// return undefined if we can't find a symbol.
}
- /** Returns true if node1 is defined before node 2**/
- function isDefinedBefore(node1, node2) {
- var file1 = ts.getSourceFileOfNode(node1);
- var file2 = ts.getSourceFileOfNode(node2);
- if (file1 === file2) {
- return node1.pos <= node2.pos;
+ function isBlockScopedNameDeclaredBeforeUse(declaration, usage) {
+ var declarationFile = ts.getSourceFileOfNode(declaration);
+ var useFile = ts.getSourceFileOfNode(usage);
+ if (declarationFile !== useFile) {
+ if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) {
+ // nodes are in different files and order cannot be determines
+ return true;
+ }
+ var sourceFiles = host.getSourceFiles();
+ return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile);
+ }
+ if (declaration.pos <= usage.pos) {
+ // declaration is before usage
+ // still might be illegal if usage is in the initializer of the variable declaration
+ return declaration.kind !== 211 /* VariableDeclaration */ ||
+ !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
+ }
+ // declaration is after usage
+ // can be legal if usage is deferred (i.e. inside function or in initializer of instance property)
+ return isUsedInFunctionOrNonStaticProperty(declaration, usage);
+ function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) {
+ var container = ts.getEnclosingBlockScopeContainer(declaration);
+ if (declaration.parent.parent.kind === 193 /* VariableStatement */ ||
+ declaration.parent.parent.kind === 199 /* ForStatement */) {
+ // variable statement/for statement case,
+ // use site should not be inside variable declaration (initializer of declaration or binding element)
+ return isSameScopeDescendentOf(usage, declaration, container);
+ }
+ else if (declaration.parent.parent.kind === 201 /* ForOfStatement */ ||
+ declaration.parent.parent.kind === 200 /* ForInStatement */) {
+ // ForIn/ForOf case - use site should not be used in expression part
+ var expression = declaration.parent.parent.expression;
+ return isSameScopeDescendentOf(usage, expression, container);
+ }
}
- if (!compilerOptions.outFile && !compilerOptions.out) {
- return true;
+ function isUsedInFunctionOrNonStaticProperty(declaration, usage) {
+ var container = ts.getEnclosingBlockScopeContainer(declaration);
+ var current = usage;
+ while (current) {
+ if (current === container) {
+ return false;
+ }
+ if (ts.isFunctionLike(current)) {
+ return true;
+ }
+ var initializerOfNonStaticProperty = current.parent &&
+ current.parent.kind === 141 /* PropertyDeclaration */ &&
+ (current.parent.flags & 128 /* Static */) === 0 &&
+ current.parent.initializer === current;
+ if (initializerOfNonStaticProperty) {
+ return true;
+ }
+ current = current.parent;
+ }
+ return false;
}
- var sourceFiles = host.getSourceFiles();
- return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2);
}
// Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
// the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
@@ -13249,13 +13663,13 @@ var ts;
}
}
switch (location.kind) {
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
if (!ts.isExternalModule(location))
break;
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
var moduleExports = getSymbolOfNode(location).exports;
- if (location.kind === 246 /* SourceFile */ ||
- (location.kind === 216 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) {
+ if (location.kind === 248 /* SourceFile */ ||
+ (location.kind === 218 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) {
// It's an external module. Because of module/namespace merging, a module's exports are in scope,
// yet we never want to treat an export specifier as putting a member in scope. Therefore,
// if the name we find is purely an export specifier, it is not actually considered in scope.
@@ -13269,7 +13683,7 @@ var ts;
// which is not the desired behavior.
if (ts.hasProperty(moduleExports, name) &&
moduleExports[name].flags === 8388608 /* Alias */ &&
- ts.getDeclarationOfKind(moduleExports[name], 228 /* ExportSpecifier */)) {
+ ts.getDeclarationOfKind(moduleExports[name], 230 /* ExportSpecifier */)) {
break;
}
result = moduleExports["default"];
@@ -13283,13 +13697,13 @@ var ts;
break loop;
}
break;
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) {
break loop;
}
break;
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
// TypeScript 1.0 spec (April 2014): 8.4.1
// Initializer expressions for instance member variables are evaluated in the scope
// of the class constructor body but are not permitted to reference parameters or
@@ -13306,9 +13720,9 @@ var ts;
}
}
break;
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
- case 213 /* InterfaceDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
+ case 215 /* InterfaceDeclaration */:
if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) {
if (lastLocation && lastLocation.flags & 128 /* Static */) {
// TypeScript 1.0 spec (April 2014): 3.4.1
@@ -13319,7 +13733,7 @@ var ts;
}
break loop;
}
- if (location.kind === 184 /* ClassExpression */ && meaning & 32 /* Class */) {
+ if (location.kind === 186 /* ClassExpression */ && meaning & 32 /* Class */) {
var className = location.name;
if (className && name === className.text) {
result = location.symbol;
@@ -13335,9 +13749,9 @@ var ts;
// [foo()]() { } // <-- Reference to T from class's own computed property
// }
//
- case 134 /* ComputedPropertyName */:
+ case 136 /* ComputedPropertyName */:
grandparent = location.parent.parent;
- if (ts.isClassLike(grandparent) || grandparent.kind === 213 /* InterfaceDeclaration */) {
+ if (ts.isClassLike(grandparent) || grandparent.kind === 215 /* InterfaceDeclaration */) {
// A reference to this grandparent's type parameters would be an error
if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) {
error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
@@ -13345,19 +13759,19 @@ var ts;
}
}
break;
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 211 /* FunctionDeclaration */:
- case 172 /* ArrowFunction */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 213 /* FunctionDeclaration */:
+ case 174 /* ArrowFunction */:
if (meaning & 3 /* Variable */ && name === "arguments") {
result = argumentsSymbol;
break loop;
}
break;
- case 171 /* FunctionExpression */:
+ case 173 /* FunctionExpression */:
if (meaning & 3 /* Variable */ && name === "arguments") {
result = argumentsSymbol;
break loop;
@@ -13370,7 +13784,7 @@ var ts;
}
}
break;
- case 137 /* Decorator */:
+ case 139 /* Decorator */:
// Decorators are resolved at the class declaration. Resolving at the parameter
// or member would result in looking up locals in the method.
//
@@ -13379,7 +13793,7 @@ var ts;
// method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter.
// }
//
- if (location.parent && location.parent.kind === 136 /* Parameter */) {
+ if (location.parent && location.parent.kind === 138 /* Parameter */) {
location = location.parent;
}
//
@@ -13425,8 +13839,11 @@ var ts;
// block - scope variable and namespace module. However, only when we
// try to resolve name in /*1*/ which is used in variable position,
// we want to check for block- scoped
- if (meaning & 2 /* BlockScopedVariable */ && result.flags & 2 /* BlockScopedVariable */) {
- checkResolvedBlockScopedVariable(result, errorLocation);
+ if (meaning & 2 /* BlockScopedVariable */) {
+ var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
+ if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) {
+ checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
+ }
}
}
return result;
@@ -13436,32 +13853,7 @@ var ts;
// Block-scoped variables cannot be used before their definition
var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; });
ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
- // first check if usage is lexically located after the declaration
- var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation);
- if (!isUsedBeforeDeclaration) {
- // lexical check succeeded however code still can be illegal.
- // - block scoped variables cannot be used in its initializers
- // let x = x; // illegal but usage is lexically after definition
- // - in ForIn/ForOf statements variable cannot be contained in expression part
- // for (let x in x)
- // for (let x of x)
- // climb up to the variable declaration skipping binding patterns
- var variableDeclaration = ts.getAncestor(declaration, 209 /* VariableDeclaration */);
- var container = ts.getEnclosingBlockScopeContainer(variableDeclaration);
- if (variableDeclaration.parent.parent.kind === 191 /* VariableStatement */ ||
- variableDeclaration.parent.parent.kind === 197 /* ForStatement */) {
- // variable statement/for statement case,
- // use site should not be inside variable declaration (initializer of declaration or binding element)
- isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container);
- }
- else if (variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */ ||
- variableDeclaration.parent.parent.kind === 198 /* ForInStatement */) {
- // ForIn/ForOf case - use site should not be used in expression part
- var expression = variableDeclaration.parent.parent.expression;
- isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container);
- }
- }
- if (isUsedBeforeDeclaration) {
+ if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 211 /* VariableDeclaration */), errorLocation)) {
error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name));
}
}
@@ -13482,10 +13874,10 @@ var ts;
}
function getAnyImportSyntax(node) {
if (ts.isAliasSymbolDeclaration(node)) {
- if (node.kind === 219 /* ImportEqualsDeclaration */) {
+ if (node.kind === 221 /* ImportEqualsDeclaration */) {
return node;
}
- while (node && node.kind !== 220 /* ImportDeclaration */) {
+ while (node && node.kind !== 222 /* ImportDeclaration */) {
node = node.parent;
}
return node;
@@ -13495,7 +13887,7 @@ var ts;
return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; });
}
function getTargetOfImportEqualsDeclaration(node) {
- if (node.moduleReference.kind === 230 /* ExternalModuleReference */) {
+ if (node.moduleReference.kind === 232 /* ExternalModuleReference */) {
return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node)));
}
return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node);
@@ -13602,17 +13994,17 @@ var ts;
}
function getTargetOfAliasDeclaration(node) {
switch (node.kind) {
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
return getTargetOfImportEqualsDeclaration(node);
- case 221 /* ImportClause */:
+ case 223 /* ImportClause */:
return getTargetOfImportClause(node);
- case 222 /* NamespaceImport */:
+ case 224 /* NamespaceImport */:
return getTargetOfNamespaceImport(node);
- case 224 /* ImportSpecifier */:
+ case 226 /* ImportSpecifier */:
return getTargetOfImportSpecifier(node);
- case 228 /* ExportSpecifier */:
+ case 230 /* ExportSpecifier */:
return getTargetOfExportSpecifier(node);
- case 225 /* ExportAssignment */:
+ case 227 /* ExportAssignment */:
return getTargetOfExportAssignment(node);
}
}
@@ -13657,11 +14049,11 @@ var ts;
if (!links.referenced) {
links.referenced = true;
var node = getDeclarationOfAliasSymbol(symbol);
- if (node.kind === 225 /* ExportAssignment */) {
+ if (node.kind === 227 /* ExportAssignment */) {
// export default
checkExpressionCached(node.expression);
}
- else if (node.kind === 228 /* ExportSpecifier */) {
+ else if (node.kind === 230 /* ExportSpecifier */) {
// export { } or export { as foo }
checkExpressionCached(node.propertyName || node.name);
}
@@ -13674,7 +14066,7 @@ var ts;
// This function is only for imports with entity names
function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) {
if (!importDeclaration) {
- importDeclaration = ts.getAncestor(entityName, 219 /* ImportEqualsDeclaration */);
+ importDeclaration = ts.getAncestor(entityName, 221 /* ImportEqualsDeclaration */);
ts.Debug.assert(importDeclaration !== undefined);
}
// There are three things we might try to look for. In the following examples,
@@ -13683,17 +14075,17 @@ var ts;
// import a = |b|; // Namespace
// import a = |b.c|; // Value, type, namespace
// import a = |b.c|.d; // Namespace
- if (entityName.kind === 67 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
+ if (entityName.kind === 69 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
entityName = entityName.parent;
}
// Check for case 1 and 3 in the above example
- if (entityName.kind === 67 /* Identifier */ || entityName.parent.kind === 133 /* QualifiedName */) {
+ if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 135 /* QualifiedName */) {
return resolveEntityName(entityName, 1536 /* Namespace */);
}
else {
// Case 2 in above example
// entityName.kind could be a QualifiedName or a Missing identifier
- ts.Debug.assert(entityName.parent.kind === 219 /* ImportEqualsDeclaration */);
+ ts.Debug.assert(entityName.parent.kind === 221 /* ImportEqualsDeclaration */);
return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */);
}
}
@@ -13706,16 +14098,16 @@ var ts;
return undefined;
}
var symbol;
- if (name.kind === 67 /* Identifier */) {
+ if (name.kind === 69 /* Identifier */) {
var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0;
symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name);
if (!symbol) {
return undefined;
}
}
- else if (name.kind === 133 /* QualifiedName */ || name.kind === 164 /* PropertyAccessExpression */) {
- var left = name.kind === 133 /* QualifiedName */ ? name.left : name.expression;
- var right = name.kind === 133 /* QualifiedName */ ? name.right : name.name;
+ else if (name.kind === 135 /* QualifiedName */ || name.kind === 166 /* PropertyAccessExpression */) {
+ var left = name.kind === 135 /* QualifiedName */ ? name.left : name.expression;
+ var right = name.kind === 135 /* QualifiedName */ ? name.right : name.name;
var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors);
if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) {
return undefined;
@@ -13734,11 +14126,6 @@ var ts;
ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0, "Should never get an instantiated symbol here.");
return symbol.flags & meaning ? symbol : resolveAlias(symbol);
}
- 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) === "..\\";
- }
function resolveExternalModuleName(location, moduleReferenceExpression) {
if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) {
return;
@@ -13748,10 +14135,10 @@ var ts;
// Module names are escaped in our symbol table. However, string literal values aren't.
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text);
- if (!moduleName) {
+ if (moduleName === undefined) {
return;
}
- var isRelative = isExternalModuleNameRelative(moduleName);
+ var isRelative = ts.isExternalModuleNameRelative(moduleName);
if (!isRelative) {
var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */);
if (symbol) {
@@ -13867,7 +14254,7 @@ var ts;
var members = node.members;
for (var _i = 0; _i < members.length; _i++) {
var member = members[_i];
- if (member.kind === 142 /* Constructor */ && ts.nodeIsPresent(member.body)) {
+ if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) {
return member;
}
}
@@ -13937,17 +14324,17 @@ var ts;
}
}
switch (location_1.kind) {
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
if (!ts.isExternalModule(location_1)) {
break;
}
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
if (result = callback(getSymbolOfNode(location_1).exports)) {
return result;
}
break;
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
if (result = callback(getSymbolOfNode(location_1).members)) {
return result;
}
@@ -13988,7 +14375,7 @@ var ts;
return ts.forEachValue(symbols, function (symbolFromSymbolTable) {
if (symbolFromSymbolTable.flags & 8388608 /* Alias */
&& symbolFromSymbolTable.name !== "export="
- && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) {
+ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) {
if (!useOnlyExternalAliasing ||
// Is this external alias, then use it to name
ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) {
@@ -14025,7 +14412,7 @@ var ts;
return true;
}
// Qualify if the symbol from symbol table has same meaning as expected
- symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
+ symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 230 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
if (symbolFromSymbolTable.flags & meaning) {
qualify = true;
return true;
@@ -14098,8 +14485,8 @@ var ts;
}
}
function hasExternalModuleSymbol(declaration) {
- return (declaration.kind === 216 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) ||
- (declaration.kind === 246 /* SourceFile */ && ts.isExternalModule(declaration));
+ return (declaration.kind === 218 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) ||
+ (declaration.kind === 248 /* SourceFile */ && ts.isExternalModule(declaration));
}
function hasVisibleDeclarations(symbol) {
var aliasesToMakeVisible;
@@ -14135,12 +14522,12 @@ var ts;
function isEntityNameVisible(entityName, enclosingDeclaration) {
// get symbol of the first identifier of the entityName
var meaning;
- if (entityName.parent.kind === 152 /* TypeQuery */) {
+ if (entityName.parent.kind === 154 /* TypeQuery */) {
// Typeof value
meaning = 107455 /* Value */ | 1048576 /* ExportValue */;
}
- else if (entityName.kind === 133 /* QualifiedName */ || entityName.kind === 164 /* PropertyAccessExpression */ ||
- entityName.parent.kind === 219 /* ImportEqualsDeclaration */) {
+ else if (entityName.kind === 135 /* QualifiedName */ || entityName.kind === 166 /* PropertyAccessExpression */ ||
+ entityName.parent.kind === 221 /* ImportEqualsDeclaration */) {
// Left identifier from type reference or TypeAlias
// Entity name of the import declaration
meaning = 1536 /* Namespace */;
@@ -14195,10 +14582,10 @@ var ts;
function getTypeAliasForTypeLiteral(type) {
if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) {
var node = type.symbol.declarations[0].parent;
- while (node.kind === 158 /* ParenthesizedType */) {
+ while (node.kind === 160 /* ParenthesizedType */) {
node = node.parent;
}
- if (node.kind === 214 /* TypeAliasDeclaration */) {
+ if (node.kind === 216 /* TypeAliasDeclaration */) {
return getSymbolOfNode(node);
}
}
@@ -14212,10 +14599,10 @@ var ts;
return ts.declarationNameToString(declaration.name);
}
switch (declaration.kind) {
- case 184 /* ClassExpression */:
+ case 186 /* ClassExpression */:
return "(Anonymous class)";
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
return "(Anonymous function)";
}
}
@@ -14298,6 +14685,7 @@ var ts;
}
function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, symbolStack) {
var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */;
+ var inObjectTypeLiteral = false;
return writeType(type, globalFlags);
function writeType(type, flags) {
// Write undefined/null type as any
@@ -14307,6 +14695,12 @@ var ts;
? "any"
: type.intrinsicName);
}
+ else if (type.flags & 33554432 /* ThisType */) {
+ if (inObjectTypeLiteral) {
+ writer.reportInaccessibleThisError();
+ }
+ writer.writeKeyword("this");
+ }
else if (type.flags & 4096 /* Reference */) {
writeTypeReference(type, flags);
}
@@ -14348,11 +14742,10 @@ var ts;
writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */);
}
}
- function writeSymbolTypeReference(symbol, typeArguments, pos, end) {
- // Unnamed function expressions, arrow functions, and unnamed class expressions have reserved names that
- // we don't want to display
- if (!isReservedMemberName(symbol.name)) {
- buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */);
+ function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) {
+ // Unnamed function expressions and arrow functions have reserved names that we don't want to display
+ if (symbol.flags & 32 /* Class */ || !isReservedMemberName(symbol.name)) {
+ buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */, 0 /* None */, flags);
}
if (pos < end) {
writePunctuation(writer, 25 /* LessThanToken */);
@@ -14366,7 +14759,7 @@ var ts;
}
}
function writeTypeReference(type, flags) {
- var typeArguments = type.typeArguments;
+ var typeArguments = type.typeArguments || emptyArray;
if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) {
writeType(typeArguments[0], 64 /* InElementType */);
writePunctuation(writer, 19 /* OpenBracketToken */);
@@ -14390,12 +14783,13 @@ var ts;
// When type parameters are their own type arguments for the whole group (i.e. we have
// the default outer type arguments), we don't show the group.
if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
- writeSymbolTypeReference(parent_3, typeArguments, start, i);
+ writeSymbolTypeReference(parent_3, typeArguments, start, i, flags);
writePunctuation(writer, 21 /* DotToken */);
}
}
}
- writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length);
+ var typeParameterCount = (type.target.typeParameters || emptyArray).length;
+ writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags);
}
}
function writeTupleType(type) {
@@ -14407,7 +14801,7 @@ var ts;
if (flags & 64 /* InElementType */) {
writePunctuation(writer, 17 /* OpenParenToken */);
}
- writeTypeList(type.types, type.flags & 16384 /* Union */ ? 46 /* BarToken */ : 45 /* AmpersandToken */);
+ writeTypeList(type.types, type.flags & 16384 /* Union */ ? 47 /* BarToken */ : 46 /* AmpersandToken */);
if (flags & 64 /* InElementType */) {
writePunctuation(writer, 18 /* CloseParenToken */);
}
@@ -14431,7 +14825,7 @@ var ts;
}
else {
// Recursive usage, use any
- writeKeyword(writer, 115 /* AnyKeyword */);
+ writeKeyword(writer, 117 /* AnyKeyword */);
}
}
else {
@@ -14455,7 +14849,7 @@ var ts;
var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) &&
(symbol.parent ||
ts.forEach(symbol.declarations, function (declaration) {
- return declaration.parent.kind === 246 /* SourceFile */ || declaration.parent.kind === 217 /* ModuleBlock */;
+ return declaration.parent.kind === 248 /* SourceFile */ || declaration.parent.kind === 219 /* ModuleBlock */;
}));
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
// typeof is allowed only for static/non local functions
@@ -14465,7 +14859,7 @@ var ts;
}
}
function writeTypeofSymbol(type, typeFormatFlags) {
- writeKeyword(writer, 99 /* TypeOfKeyword */);
+ writeKeyword(writer, 101 /* TypeOfKeyword */);
writeSpace(writer);
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags);
}
@@ -14501,7 +14895,7 @@ var ts;
if (flags & 64 /* InElementType */) {
writePunctuation(writer, 17 /* OpenParenToken */);
}
- writeKeyword(writer, 90 /* NewKeyword */);
+ writeKeyword(writer, 92 /* NewKeyword */);
writeSpace(writer);
buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack);
if (flags & 64 /* InElementType */) {
@@ -14510,6 +14904,8 @@ var ts;
return;
}
}
+ var saveInObjectTypeLiteral = inObjectTypeLiteral;
+ inObjectTypeLiteral = true;
writePunctuation(writer, 15 /* OpenBraceToken */);
writer.writeLine();
writer.increaseIndent();
@@ -14521,7 +14917,7 @@ var ts;
}
for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) {
var signature = _c[_b];
- writeKeyword(writer, 90 /* NewKeyword */);
+ writeKeyword(writer, 92 /* NewKeyword */);
writeSpace(writer);
buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack);
writePunctuation(writer, 23 /* SemicolonToken */);
@@ -14531,11 +14927,11 @@ var ts;
// [x: string]:
writePunctuation(writer, 19 /* OpenBracketToken */);
writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x"));
- writePunctuation(writer, 53 /* ColonToken */);
+ writePunctuation(writer, 54 /* ColonToken */);
writeSpace(writer);
- writeKeyword(writer, 128 /* StringKeyword */);
+ writeKeyword(writer, 130 /* StringKeyword */);
writePunctuation(writer, 20 /* CloseBracketToken */);
- writePunctuation(writer, 53 /* ColonToken */);
+ writePunctuation(writer, 54 /* ColonToken */);
writeSpace(writer);
writeType(resolved.stringIndexType, 0 /* None */);
writePunctuation(writer, 23 /* SemicolonToken */);
@@ -14545,11 +14941,11 @@ var ts;
// [x: number]:
writePunctuation(writer, 19 /* OpenBracketToken */);
writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x"));
- writePunctuation(writer, 53 /* ColonToken */);
+ writePunctuation(writer, 54 /* ColonToken */);
writeSpace(writer);
- writeKeyword(writer, 126 /* NumberKeyword */);
+ writeKeyword(writer, 128 /* NumberKeyword */);
writePunctuation(writer, 20 /* CloseBracketToken */);
- writePunctuation(writer, 53 /* ColonToken */);
+ writePunctuation(writer, 54 /* ColonToken */);
writeSpace(writer);
writeType(resolved.numberIndexType, 0 /* None */);
writePunctuation(writer, 23 /* SemicolonToken */);
@@ -14564,7 +14960,7 @@ var ts;
var signature = signatures[_f];
buildSymbolDisplay(p, writer);
if (p.flags & 536870912 /* Optional */) {
- writePunctuation(writer, 52 /* QuestionToken */);
+ writePunctuation(writer, 53 /* QuestionToken */);
}
buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack);
writePunctuation(writer, 23 /* SemicolonToken */);
@@ -14574,9 +14970,9 @@ var ts;
else {
buildSymbolDisplay(p, writer);
if (p.flags & 536870912 /* Optional */) {
- writePunctuation(writer, 52 /* QuestionToken */);
+ writePunctuation(writer, 53 /* QuestionToken */);
}
- writePunctuation(writer, 53 /* ColonToken */);
+ writePunctuation(writer, 54 /* ColonToken */);
writeSpace(writer);
writeType(t, 0 /* None */);
writePunctuation(writer, 23 /* SemicolonToken */);
@@ -14585,6 +14981,7 @@ var ts;
}
writer.decreaseIndent();
writePunctuation(writer, 16 /* CloseBraceToken */);
+ inObjectTypeLiteral = saveInObjectTypeLiteral;
}
}
function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) {
@@ -14598,7 +14995,7 @@ var ts;
var constraint = getConstraintOfTypeParameter(tp);
if (constraint) {
writeSpace(writer);
- writeKeyword(writer, 81 /* ExtendsKeyword */);
+ writeKeyword(writer, 83 /* ExtendsKeyword */);
writeSpace(writer);
buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack);
}
@@ -14610,9 +15007,9 @@ var ts;
}
appendSymbolNameOnly(p, writer);
if (isOptionalParameter(parameterNode)) {
- writePunctuation(writer, 52 /* QuestionToken */);
+ writePunctuation(writer, 53 /* QuestionToken */);
}
- writePunctuation(writer, 53 /* ColonToken */);
+ writePunctuation(writer, 54 /* ColonToken */);
writeSpace(writer);
buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack);
}
@@ -14659,14 +15056,14 @@ var ts;
writePunctuation(writer, 34 /* EqualsGreaterThanToken */);
}
else {
- writePunctuation(writer, 53 /* ColonToken */);
+ writePunctuation(writer, 54 /* ColonToken */);
}
writeSpace(writer);
var returnType;
if (signature.typePredicate) {
writer.writeParameter(signature.typePredicate.parameterName);
writeSpace(writer);
- writeKeyword(writer, 122 /* IsKeyword */);
+ writeKeyword(writer, 124 /* IsKeyword */);
writeSpace(writer);
returnType = signature.typePredicate.type;
}
@@ -14702,12 +15099,12 @@ var ts;
function isDeclarationVisible(node) {
function getContainingExternalModule(node) {
for (; node; node = node.parent) {
- if (node.kind === 216 /* ModuleDeclaration */) {
+ if (node.kind === 218 /* ModuleDeclaration */) {
if (node.name.kind === 9 /* StringLiteral */) {
return node;
}
}
- else if (node.kind === 246 /* SourceFile */) {
+ else if (node.kind === 248 /* SourceFile */) {
return ts.isExternalModule(node) ? node : undefined;
}
}
@@ -14756,70 +15153,70 @@ var ts;
}
function determineIfDeclarationIsVisible() {
switch (node.kind) {
- case 161 /* BindingElement */:
+ case 163 /* BindingElement */:
return isDeclarationVisible(node.parent.parent);
- case 209 /* VariableDeclaration */:
+ case 211 /* VariableDeclaration */:
if (ts.isBindingPattern(node.name) &&
!node.name.elements.length) {
// If the binding pattern is empty, this variable declaration is not visible
return false;
}
// Otherwise fall through
- case 216 /* ModuleDeclaration */:
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 214 /* TypeAliasDeclaration */:
- case 211 /* FunctionDeclaration */:
- case 215 /* EnumDeclaration */:
- case 219 /* ImportEqualsDeclaration */:
+ case 218 /* ModuleDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
+ case 213 /* FunctionDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
var parent_4 = getDeclarationContainer(node);
// If the node is not exported or it is not ambient module element (except import declaration)
if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) &&
- !(node.kind !== 219 /* ImportEqualsDeclaration */ && parent_4.kind !== 246 /* SourceFile */ && ts.isInAmbientContext(parent_4))) {
+ !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) {
return isGlobalSourceFile(parent_4);
}
// Exported members/ambient module elements (exception import declaration) are visible if parent is visible
return isDeclarationVisible(parent_4);
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
if (node.flags & (32 /* Private */ | 64 /* Protected */)) {
// Private/protected properties/methods are not visible
return false;
}
// Public properties/methods are visible if its parents are visible, so let it fall into next case statement
- case 142 /* Constructor */:
- case 146 /* ConstructSignature */:
- case 145 /* CallSignature */:
- case 147 /* IndexSignature */:
- case 136 /* Parameter */:
- case 217 /* ModuleBlock */:
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
- case 153 /* TypeLiteral */:
- case 149 /* TypeReference */:
- case 154 /* ArrayType */:
- case 155 /* TupleType */:
- case 156 /* UnionType */:
- case 157 /* IntersectionType */:
- case 158 /* ParenthesizedType */:
+ case 144 /* Constructor */:
+ case 148 /* ConstructSignature */:
+ case 147 /* CallSignature */:
+ case 149 /* IndexSignature */:
+ case 138 /* Parameter */:
+ case 219 /* ModuleBlock */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
+ case 155 /* TypeLiteral */:
+ case 151 /* TypeReference */:
+ case 156 /* ArrayType */:
+ case 157 /* TupleType */:
+ case 158 /* UnionType */:
+ case 159 /* IntersectionType */:
+ case 160 /* ParenthesizedType */:
return isDeclarationVisible(node.parent);
// Default binding, import specifier and namespace import is visible
// only on demand so by default it is not visible
- case 221 /* ImportClause */:
- case 222 /* NamespaceImport */:
- case 224 /* ImportSpecifier */:
+ case 223 /* ImportClause */:
+ case 224 /* NamespaceImport */:
+ case 226 /* ImportSpecifier */:
return false;
// Type parameters are always visible
- case 135 /* TypeParameter */:
+ case 137 /* TypeParameter */:
// Source file is always visible
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
return true;
// Export assignements do not create name bindings outside the module
- case 225 /* ExportAssignment */:
+ case 227 /* ExportAssignment */:
return false;
default:
ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind);
@@ -14835,10 +15232,10 @@ var ts;
}
function collectLinkedAliases(node) {
var exportSymbol;
- if (node.parent && node.parent.kind === 225 /* ExportAssignment */) {
+ if (node.parent && node.parent.kind === 227 /* ExportAssignment */) {
exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node);
}
- else if (node.parent.kind === 228 /* ExportSpecifier */) {
+ else if (node.parent.kind === 230 /* ExportSpecifier */) {
var exportSpecifier = node.parent;
exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ?
getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) :
@@ -14930,7 +15327,7 @@ var ts;
node = ts.getRootDeclaration(node);
// Parent chain:
// VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container'
- return node.kind === 209 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent;
+ return node.kind === 211 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent;
}
function getTypeOfPrototypeProperty(prototype) {
// TypeScript 1.0 spec (April 2014): 8.4
@@ -14948,10 +15345,16 @@ var ts;
function isTypeAny(type) {
return type && (type.flags & 1 /* Any */) !== 0;
}
+ // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
+ // assigned by contextual typing.
+ function getTypeForBindingElementParent(node) {
+ var symbol = getSymbolOfNode(node);
+ return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node);
+ }
// Return the inferred type for a binding element
function getTypeForBindingElement(declaration) {
var pattern = declaration.parent;
- var parentType = getTypeForVariableLikeDeclaration(pattern.parent);
+ var parentType = getTypeForBindingElementParent(pattern.parent);
// If parent has the unknown (error) type, then so does this binding element
if (parentType === unknownType) {
return unknownType;
@@ -14966,7 +15369,7 @@ var ts;
return parentType;
}
var type;
- if (pattern.kind === 159 /* ObjectBindingPattern */) {
+ if (pattern.kind === 161 /* ObjectBindingPattern */) {
// Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form)
var name_10 = declaration.propertyName || declaration.name;
// Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature,
@@ -15010,10 +15413,10 @@ var ts;
// Return the inferred type for a variable, parameter, or property declaration
function getTypeForVariableLikeDeclaration(declaration) {
// A variable declared in a for..in statement is always of type any
- if (declaration.parent.parent.kind === 198 /* ForInStatement */) {
+ if (declaration.parent.parent.kind === 200 /* ForInStatement */) {
return anyType;
}
- if (declaration.parent.parent.kind === 199 /* ForOfStatement */) {
+ if (declaration.parent.parent.kind === 201 /* ForOfStatement */) {
// checkRightHandSideOfForOf will return undefined if the for-of expression type was
// missing properties/signatures required to get its iteratedType (like
// [Symbol.iterator] or next). This may be because we accessed properties from anyType,
@@ -15027,11 +15430,11 @@ var ts;
if (declaration.type) {
return getTypeFromTypeNode(declaration.type);
}
- if (declaration.kind === 136 /* Parameter */) {
+ if (declaration.kind === 138 /* Parameter */) {
var func = declaration.parent;
// For a parameter of a set accessor, use the type of the get accessor if one is present
- if (func.kind === 144 /* SetAccessor */ && !ts.hasDynamicName(func)) {
- var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143 /* GetAccessor */);
+ if (func.kind === 146 /* SetAccessor */ && !ts.hasDynamicName(func)) {
+ var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 145 /* GetAccessor */);
if (getter) {
return getReturnTypeOfSignature(getSignatureFromDeclaration(getter));
}
@@ -15047,12 +15450,12 @@ var ts;
return checkExpressionCached(declaration.initializer);
}
// If it is a short-hand property assignment, use the type of the identifier
- if (declaration.kind === 244 /* ShorthandPropertyAssignment */) {
+ if (declaration.kind === 246 /* ShorthandPropertyAssignment */) {
return checkIdentifier(declaration.name);
}
// If the declaration specifies a binding pattern, use the type implied by the binding pattern
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false);
}
// No type specified and nothing can be inferred
return undefined;
@@ -15060,45 +15463,45 @@ var ts;
// Return the type implied by a binding pattern element. This is the type of the initializer of the element if
// one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding
// pattern. Otherwise, it is the type any.
- function getTypeFromBindingElement(element) {
+ function getTypeFromBindingElement(element, includePatternInType) {
if (element.initializer) {
return getWidenedType(checkExpressionCached(element.initializer));
}
if (ts.isBindingPattern(element.name)) {
- return getTypeFromBindingPattern(element.name);
+ return getTypeFromBindingPattern(element.name, includePatternInType);
}
return anyType;
}
// Return the type implied by an object binding pattern
- function getTypeFromObjectBindingPattern(pattern) {
+ function getTypeFromObjectBindingPattern(pattern, includePatternInType) {
var members = {};
ts.forEach(pattern.elements, function (e) {
var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0);
var name = e.propertyName || e.name;
var symbol = createSymbol(flags, name.text);
- symbol.type = getTypeFromBindingElement(e);
+ symbol.type = getTypeFromBindingElement(e, includePatternInType);
+ symbol.bindingElement = e;
members[symbol.name] = symbol;
});
- return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ if (includePatternInType) {
+ result.pattern = pattern;
+ }
+ return result;
}
// Return the type implied by an array binding pattern
- function getTypeFromArrayBindingPattern(pattern) {
- var hasSpreadElement = false;
- var elementTypes = [];
- ts.forEach(pattern.elements, function (e) {
- elementTypes.push(e.kind === 185 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e));
- if (e.dotDotDotToken) {
- hasSpreadElement = true;
- }
- });
- if (!elementTypes.length) {
+ function getTypeFromArrayBindingPattern(pattern, includePatternInType) {
+ var elements = pattern.elements;
+ if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) {
return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType;
}
- else if (hasSpreadElement) {
- var unionOfElements = getUnionType(elementTypes);
- return languageVersion >= 2 /* ES6 */ ? createIterableType(unionOfElements) : createArrayType(unionOfElements);
- }
// If the pattern has at least one element, and no rest element, then it should imply a tuple type.
+ var elementTypes = ts.map(elements, function (e) { return e.kind === 187 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); });
+ if (includePatternInType) {
+ var result = createNewTupleType(elementTypes);
+ result.pattern = pattern;
+ return result;
+ }
return createTupleType(elementTypes);
}
// Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself
@@ -15108,10 +15511,10 @@ var ts;
// used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring
// parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of
// the parameter.
- function getTypeFromBindingPattern(pattern) {
- return pattern.kind === 159 /* ObjectBindingPattern */
- ? getTypeFromObjectBindingPattern(pattern)
- : getTypeFromArrayBindingPattern(pattern);
+ function getTypeFromBindingPattern(pattern, includePatternInType) {
+ return pattern.kind === 161 /* ObjectBindingPattern */
+ ? getTypeFromObjectBindingPattern(pattern, includePatternInType)
+ : getTypeFromArrayBindingPattern(pattern, includePatternInType);
}
// Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type
// specified in a type annotation or inferred from an initializer. However, in the case of a destructuring declaration it
@@ -15131,14 +15534,14 @@ var ts;
// During a normal type check we'll never get to here with a property assignment (the check of the containing
// object literal uses a different path). We exclude widening only so that language services and type verification
// tools see the actual type.
- return declaration.kind !== 243 /* PropertyAssignment */ ? getWidenedType(type) : type;
+ return declaration.kind !== 245 /* PropertyAssignment */ ? getWidenedType(type) : type;
}
// Rest parameters default to type any[], other parameters default to type any
type = declaration.dotDotDotToken ? anyArrayType : anyType;
// Report implicit any errors unless this is a private property within an ambient declaration
if (reportErrors && compilerOptions.noImplicitAny) {
var root = ts.getRootDeclaration(declaration);
- if (!isPrivateWithinAmbient(root) && !(root.kind === 136 /* Parameter */ && isPrivateWithinAmbient(root.parent))) {
+ if (!isPrivateWithinAmbient(root) && !(root.kind === 138 /* Parameter */ && isPrivateWithinAmbient(root.parent))) {
reportImplicitAnyError(declaration, type);
}
}
@@ -15153,11 +15556,11 @@ var ts;
}
// Handle catch clause variables
var declaration = symbol.valueDeclaration;
- if (declaration.parent.kind === 242 /* CatchClause */) {
+ if (declaration.parent.kind === 244 /* CatchClause */) {
return links.type = anyType;
}
// Handle export default expressions
- if (declaration.kind === 225 /* ExportAssignment */) {
+ if (declaration.kind === 227 /* ExportAssignment */) {
return links.type = checkExpression(declaration.expression);
}
// Handle variable, parameter or property
@@ -15185,7 +15588,7 @@ var ts;
}
function getAnnotatedAccessorType(accessor) {
if (accessor) {
- if (accessor.kind === 143 /* GetAccessor */) {
+ if (accessor.kind === 145 /* GetAccessor */) {
return accessor.type && getTypeFromTypeNode(accessor.type);
}
else {
@@ -15201,8 +15604,8 @@ var ts;
if (!pushTypeResolution(symbol, 0 /* Type */)) {
return unknownType;
}
- var getter = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */);
- var setter = ts.getDeclarationOfKind(symbol, 144 /* SetAccessor */);
+ var getter = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */);
+ var setter = ts.getDeclarationOfKind(symbol, 146 /* SetAccessor */);
var type;
// First try to see if the user specified a return type on the get-accessor.
var getterReturnType = getAnnotatedAccessorType(getter);
@@ -15231,7 +15634,7 @@ var ts;
if (!popTypeResolution()) {
type = anyType;
if (compilerOptions.noImplicitAny) {
- var getter_1 = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */);
+ var getter_1 = ts.getDeclarationOfKind(symbol, 145 /* GetAccessor */);
error(getter_1, ts.Diagnostics._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, symbolToString(symbol));
}
}
@@ -15331,9 +15734,9 @@ var ts;
if (!node) {
return typeParameters;
}
- if (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */ ||
- node.kind === 211 /* FunctionDeclaration */ || node.kind === 171 /* FunctionExpression */ ||
- node.kind === 141 /* MethodDeclaration */ || node.kind === 172 /* ArrowFunction */) {
+ if (node.kind === 214 /* ClassDeclaration */ || node.kind === 186 /* ClassExpression */ ||
+ node.kind === 213 /* FunctionDeclaration */ || node.kind === 173 /* FunctionExpression */ ||
+ node.kind === 143 /* MethodDeclaration */ || node.kind === 174 /* ArrowFunction */) {
var declarations = node.typeParameters;
if (declarations) {
return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations);
@@ -15343,7 +15746,7 @@ var ts;
}
// The outer type parameters are those defined by enclosing generic classes, methods, or functions.
function getOuterTypeParametersOfClassOrInterface(symbol) {
- var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */);
+ var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */);
return appendOuterTypeParameters(undefined, declaration);
}
// The local type parameters are the combined set of type parameters from all declarations of the class,
@@ -15352,8 +15755,8 @@ var ts;
var result;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var node = _a[_i];
- if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 212 /* ClassDeclaration */ ||
- node.kind === 184 /* ClassExpression */ || node.kind === 214 /* TypeAliasDeclaration */) {
+ if (node.kind === 215 /* InterfaceDeclaration */ || node.kind === 214 /* ClassDeclaration */ ||
+ node.kind === 186 /* ClassExpression */ || node.kind === 216 /* TypeAliasDeclaration */) {
var declaration = node;
if (declaration.typeParameters) {
result = appendTypeParameters(result, declaration.typeParameters);
@@ -15417,22 +15820,27 @@ var ts;
}
return type.resolvedBaseConstructorType;
}
+ function hasClassBaseType(type) {
+ return !!ts.forEach(getBaseTypes(type), function (t) { return !!(t.symbol.flags & 32 /* Class */); });
+ }
function getBaseTypes(type) {
+ var isClass = type.symbol.flags & 32 /* Class */;
+ var isInterface = type.symbol.flags & 64 /* Interface */;
if (!type.resolvedBaseTypes) {
- if (type.symbol.flags & 32 /* Class */) {
+ if (!isClass && !isInterface) {
+ ts.Debug.fail("type must be class or interface");
+ }
+ if (isClass) {
resolveBaseTypesOfClass(type);
}
- else if (type.symbol.flags & 64 /* Interface */) {
+ if (isInterface) {
resolveBaseTypesOfInterface(type);
}
- else {
- ts.Debug.fail("type must be class or interface");
- }
}
return type.resolvedBaseTypes;
}
function resolveBaseTypesOfClass(type) {
- type.resolvedBaseTypes = emptyArray;
+ type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
var baseContructorType = getBaseConstructorTypeOfClass(type);
if (!(baseContructorType.flags & 80896 /* ObjectType */)) {
return;
@@ -15467,20 +15875,30 @@ var ts;
error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */));
return;
}
- type.resolvedBaseTypes = [baseType];
+ if (type.resolvedBaseTypes === emptyArray) {
+ type.resolvedBaseTypes = [baseType];
+ }
+ else {
+ type.resolvedBaseTypes.push(baseType);
+ }
}
function resolveBaseTypesOfInterface(type) {
- type.resolvedBaseTypes = [];
+ type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
- if (declaration.kind === 213 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) {
+ if (declaration.kind === 215 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) {
for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
var node = _c[_b];
var baseType = getTypeFromTypeNode(node);
if (baseType !== unknownType) {
if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) {
if (type !== baseType && !hasBaseType(baseType, type)) {
- type.resolvedBaseTypes.push(baseType);
+ if (type.resolvedBaseTypes === emptyArray) {
+ type.resolvedBaseTypes = [baseType];
+ }
+ else {
+ type.resolvedBaseTypes.push(baseType);
+ }
}
else {
error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */));
@@ -15494,6 +15912,32 @@ var ts;
}
}
}
+ // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is
+ // true if the interface itself contains no references to "this" in its body, if all base types are interfaces,
+ // and if none of the base interfaces have a "this" type.
+ function isIndependentInterface(symbol) {
+ for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
+ var declaration = _a[_i];
+ if (declaration.kind === 215 /* InterfaceDeclaration */) {
+ if (declaration.flags & 524288 /* ContainsThis */) {
+ return false;
+ }
+ var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration);
+ if (baseTypeNodes) {
+ for (var _b = 0; _b < baseTypeNodes.length; _b++) {
+ var node = baseTypeNodes[_b];
+ if (ts.isSupportedExpressionWithTypeArguments(node)) {
+ var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true);
+ if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
function getDeclaredTypeOfClassOrInterface(symbol) {
var links = getSymbolLinks(symbol);
if (!links.declaredType) {
@@ -15501,7 +15945,12 @@ var ts;
var type = links.declaredType = createObjectType(kind, symbol);
var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol);
var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
- if (outerTypeParameters || localTypeParameters) {
+ // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type
+ // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular,
+ // property types inferred from initializers and method return types inferred from return statements are very hard
+ // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of
+ // "this" references.
+ if (outerTypeParameters || localTypeParameters || kind === 1024 /* Class */ || !isIndependentInterface(symbol)) {
type.flags |= 4096 /* Reference */;
type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters);
type.outerTypeParameters = outerTypeParameters;
@@ -15510,6 +15959,9 @@ var ts;
type.instantiations[getTypeListId(type.typeParameters)] = type;
type.target = type;
type.typeArguments = type.typeParameters;
+ type.thisType = createType(512 /* TypeParameter */ | 33554432 /* ThisType */);
+ type.thisType.symbol = symbol;
+ type.thisType.constraint = getTypeWithThisArgument(type);
}
}
return links.declaredType;
@@ -15522,7 +15974,7 @@ var ts;
if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) {
return unknownType;
}
- var declaration = ts.getDeclarationOfKind(symbol, 214 /* TypeAliasDeclaration */);
+ var declaration = ts.getDeclarationOfKind(symbol, 216 /* TypeAliasDeclaration */);
var type = getTypeFromTypeNode(declaration.type);
if (popTypeResolution()) {
links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
@@ -15555,7 +16007,7 @@ var ts;
if (!links.declaredType) {
var type = createType(512 /* TypeParameter */);
type.symbol = symbol;
- if (!ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).constraint) {
+ if (!ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).constraint) {
type.constraint = noConstraintType;
}
links.declaredType = type;
@@ -15588,6 +16040,79 @@ var ts;
}
return unknownType;
}
+ // A type reference is considered independent if each type argument is considered independent.
+ function isIndependentTypeReference(node) {
+ if (node.typeArguments) {
+ for (var _i = 0, _a = node.typeArguments; _i < _a.length; _i++) {
+ var typeNode = _a[_i];
+ if (!isIndependentType(typeNode)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string
+ // literal type, an array with an element type that is considered independent, or a type reference that is
+ // considered independent.
+ function isIndependentType(node) {
+ switch (node.kind) {
+ case 117 /* AnyKeyword */:
+ case 130 /* StringKeyword */:
+ case 128 /* NumberKeyword */:
+ case 120 /* BooleanKeyword */:
+ case 131 /* SymbolKeyword */:
+ case 103 /* VoidKeyword */:
+ case 9 /* StringLiteral */:
+ return true;
+ case 156 /* ArrayType */:
+ return isIndependentType(node.elementType);
+ case 151 /* TypeReference */:
+ return isIndependentTypeReference(node);
+ }
+ return false;
+ }
+ // A variable-like declaration is considered independent (free of this references) if it has a type annotation
+ // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any).
+ function isIndependentVariableLikeDeclaration(node) {
+ return node.type && isIndependentType(node.type) || !node.type && !node.initializer;
+ }
+ // A function-like declaration is considered independent (free of this references) if it has a return type
+ // annotation that is considered independent and if each parameter is considered independent.
+ function isIndependentFunctionLikeDeclaration(node) {
+ if (node.kind !== 144 /* Constructor */ && (!node.type || !isIndependentType(node.type))) {
+ return false;
+ }
+ for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
+ var parameter = _a[_i];
+ if (!isIndependentVariableLikeDeclaration(parameter)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ // Returns true if the class or interface member given by the symbol is free of "this" references. The
+ // function may return false for symbols that are actually free of "this" references because it is not
+ // feasible to perform a complete analysis in all cases. In particular, property members with types
+ // inferred from their initializers and function members with inferred return types are convervatively
+ // assumed not to be free of "this" references.
+ function isIndependentMember(symbol) {
+ if (symbol.declarations && symbol.declarations.length === 1) {
+ var declaration = symbol.declarations[0];
+ if (declaration) {
+ switch (declaration.kind) {
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ return isIndependentVariableLikeDeclaration(declaration);
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 144 /* Constructor */:
+ return isIndependentFunctionLikeDeclaration(declaration);
+ }
+ }
+ }
+ return false;
+ }
function createSymbolTable(symbols) {
var result = {};
for (var _i = 0; _i < symbols.length; _i++) {
@@ -15596,11 +16121,13 @@ var ts;
}
return result;
}
- function createInstantiatedSymbolTable(symbols, mapper) {
+ // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true,
+ // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation.
+ function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) {
var result = {};
for (var _i = 0; _i < symbols.length; _i++) {
var symbol = symbols[_i];
- result[symbol.name] = instantiateSymbol(symbol, mapper);
+ result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper);
}
return result;
}
@@ -15631,44 +16158,54 @@ var ts;
}
return type;
}
- function resolveClassOrInterfaceMembers(type) {
- var target = resolveDeclaredMembers(type);
- var members = target.symbol.members;
- var callSignatures = target.declaredCallSignatures;
- var constructSignatures = target.declaredConstructSignatures;
- var stringIndexType = target.declaredStringIndexType;
- var numberIndexType = target.declaredNumberIndexType;
- var baseTypes = getBaseTypes(target);
+ function getTypeWithThisArgument(type, thisArgument) {
+ if (type.flags & 4096 /* Reference */) {
+ return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType]));
+ }
+ return type;
+ }
+ function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
+ var mapper = identityMapper;
+ var members = source.symbol.members;
+ var callSignatures = source.declaredCallSignatures;
+ var constructSignatures = source.declaredConstructSignatures;
+ var stringIndexType = source.declaredStringIndexType;
+ var numberIndexType = source.declaredNumberIndexType;
+ if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) {
+ mapper = createTypeMapper(typeParameters, typeArguments);
+ members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1);
+ callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature);
+ constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature);
+ stringIndexType = instantiateType(source.declaredStringIndexType, mapper);
+ numberIndexType = instantiateType(source.declaredNumberIndexType, mapper);
+ }
+ var baseTypes = getBaseTypes(source);
if (baseTypes.length) {
- members = createSymbolTable(target.declaredProperties);
+ if (members === source.symbol.members) {
+ members = createSymbolTable(source.declaredProperties);
+ }
+ var thisArgument = ts.lastOrUndefined(typeArguments);
for (var _i = 0; _i < baseTypes.length; _i++) {
var baseType = baseTypes[_i];
- addInheritedMembers(members, getPropertiesOfObjectType(baseType));
- callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0 /* Call */));
- constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1 /* Construct */));
- stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0 /* String */);
- numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1 /* Number */);
+ var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType;
+ addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType));
+ callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */));
+ constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */));
+ stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */);
+ numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */);
}
}
setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType);
}
+ function resolveClassOrInterfaceMembers(type) {
+ resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray);
+ }
function resolveTypeReferenceMembers(type) {
- var target = resolveDeclaredMembers(type.target);
- var mapper = createTypeMapper(target.typeParameters, type.typeArguments);
- var members = createInstantiatedSymbolTable(target.declaredProperties, mapper);
- var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature);
- var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature);
- var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined;
- var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined;
- ts.forEach(getBaseTypes(target), function (baseType) {
- var instantiatedBaseType = instantiateType(baseType, mapper);
- addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType));
- callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */));
- constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */));
- stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */);
- numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */);
- });
- setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType);
+ var source = resolveDeclaredMembers(type.target);
+ var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]);
+ var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ?
+ type.typeArguments : ts.concatenate(type.typeArguments, [type]);
+ resolveObjectTypeMembers(type, source, typeParameters, typeArguments);
}
function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) {
var sig = new Signature(checker);
@@ -15686,7 +16223,7 @@ var ts;
return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
}
function getDefaultConstructSignatures(classType) {
- if (!getBaseTypes(classType).length) {
+ if (!hasClassBaseType(classType)) {
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)];
}
var baseConstructorType = getBaseConstructorTypeOfClass(classType);
@@ -15717,7 +16254,9 @@ var ts;
return members;
}
function resolveTupleTypeMembers(type) {
- var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true)));
+ var arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true);
+ // Make the tuple type itself the 'this' type by including an extra type argument
+ var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type]));
var members = createTupleTypeMemberSymbols(type.elementTypes);
addInheritedMembers(members, arrayType.properties);
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
@@ -15833,7 +16372,14 @@ var ts;
var constructSignatures;
var stringIndexType;
var numberIndexType;
- if (symbol.flags & 2048 /* TypeLiteral */) {
+ if (type.target) {
+ members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
+ callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature);
+ constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature);
+ stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0 /* String */), type.mapper);
+ numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1 /* Number */), type.mapper);
+ }
+ else if (symbol.flags & 2048 /* TypeLiteral */) {
members = symbol.members;
callSignatures = getSignaturesOfSymbol(members["__call"]);
constructSignatures = getSignaturesOfSymbol(members["__new"]);
@@ -15870,7 +16416,10 @@ var ts;
}
function resolveStructuredTypeMembers(type) {
if (!type.members) {
- if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) {
+ if (type.flags & 4096 /* Reference */) {
+ resolveTypeReferenceMembers(type);
+ }
+ else if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) {
resolveClassOrInterfaceMembers(type);
}
else if (type.flags & 65536 /* Anonymous */) {
@@ -15885,9 +16434,6 @@ var ts;
else if (type.flags & 32768 /* Intersection */) {
resolveIntersectionTypeMembers(type);
}
- else {
- resolveTypeReferenceMembers(type);
- }
}
return type;
}
@@ -16116,7 +16662,9 @@ var ts;
function getSignatureFromDeclaration(declaration) {
var links = getNodeLinks(declaration);
if (!links.resolvedSignature) {
- var classType = declaration.kind === 142 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined;
+ var classType = declaration.kind === 144 /* Constructor */ ?
+ getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
+ : undefined;
var typeParameters = classType ? classType.localTypeParameters :
declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined;
var parameters = [];
@@ -16148,7 +16696,7 @@ var ts;
}
else if (declaration.type) {
returnType = getTypeFromTypeNode(declaration.type);
- if (declaration.type.kind === 148 /* TypePredicate */) {
+ if (declaration.type.kind === 150 /* TypePredicate */) {
var typePredicateNode = declaration.type;
typePredicate = {
parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined,
@@ -16160,8 +16708,8 @@ var ts;
else {
// TypeScript 1.0 spec (April 2014):
// If only one accessor includes a type annotation, the other behaves as if it had the same type annotation.
- if (declaration.kind === 143 /* GetAccessor */ && !ts.hasDynamicName(declaration)) {
- var setter = ts.getDeclarationOfKind(declaration.symbol, 144 /* SetAccessor */);
+ if (declaration.kind === 145 /* GetAccessor */ && !ts.hasDynamicName(declaration)) {
+ var setter = ts.getDeclarationOfKind(declaration.symbol, 146 /* SetAccessor */);
returnType = getAnnotatedAccessorType(setter);
}
if (!returnType && ts.nodeIsMissing(declaration.body)) {
@@ -16179,19 +16727,19 @@ var ts;
for (var i = 0, len = symbol.declarations.length; i < len; i++) {
var node = symbol.declarations[i];
switch (node.kind) {
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
- case 211 /* FunctionDeclaration */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 142 /* Constructor */:
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */:
- case 147 /* IndexSignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
+ case 213 /* FunctionDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 144 /* Constructor */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 149 /* IndexSignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
// Don't include signature if node is the implementation of an overloaded function. A node is considered
// an implementation node if it has a body and the previous node is of the same kind and immediately
// precedes the implementation node (i.e. has the same parent and ends where the implementation starts).
@@ -16268,7 +16816,7 @@ var ts;
// object type literal or interface (using the new keyword). Each way of declaring a constructor
// will result in a different declaration kind.
if (!signature.isolatedSignatureType) {
- var isConstructor = signature.declaration.kind === 142 /* Constructor */ || signature.declaration.kind === 146 /* ConstructSignature */;
+ var isConstructor = signature.declaration.kind === 144 /* Constructor */ || signature.declaration.kind === 148 /* ConstructSignature */;
var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */);
type.members = emptySymbols;
type.properties = emptyArray;
@@ -16282,7 +16830,7 @@ var ts;
return symbol.members["__index"];
}
function getIndexDeclarationOfSymbol(symbol, kind) {
- var syntaxKind = kind === 1 /* Number */ ? 126 /* NumberKeyword */ : 128 /* StringKeyword */;
+ var syntaxKind = kind === 1 /* Number */ ? 128 /* NumberKeyword */ : 130 /* StringKeyword */;
var indexSymbol = getIndexSymbol(symbol);
if (indexSymbol) {
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
@@ -16311,30 +16859,33 @@ var ts;
type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType;
}
else {
- type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135 /* TypeParameter */).constraint);
+ type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 137 /* TypeParameter */).constraint);
}
}
return type.constraint === noConstraintType ? undefined : type.constraint;
}
function getParentSymbolOfTypeParameter(typeParameter) {
- return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135 /* TypeParameter */).parent);
+ return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 137 /* TypeParameter */).parent);
}
function getTypeListId(types) {
- switch (types.length) {
- case 1:
- return "" + types[0].id;
- case 2:
- return types[0].id + "," + types[1].id;
- default:
- var result = "";
- for (var i = 0; i < types.length; i++) {
- if (i > 0) {
- result += ",";
+ if (types) {
+ switch (types.length) {
+ case 1:
+ return "" + types[0].id;
+ case 2:
+ return types[0].id + "," + types[1].id;
+ default:
+ var result = "";
+ for (var i = 0; i < types.length; i++) {
+ if (i > 0) {
+ result += ",";
+ }
+ result += types[i].id;
}
- result += types[i].id;
- }
- return result;
+ return result;
+ }
}
+ return "";
}
// This function is used to propagate certain flags when creating new object type references and union types.
// It is only necessary to do so if a constituent type might be the undefined type, the null type, the type
@@ -16352,7 +16903,7 @@ var ts;
var id = getTypeListId(typeArguments);
var type = target.instantiations[id];
if (!type) {
- var flags = 4096 /* Reference */ | getPropagatingFlagsOfTypes(typeArguments);
+ var flags = 4096 /* Reference */ | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0);
type = target.instantiations[id] = createObjectType(flags, target.symbol);
type.target = target;
type.typeArguments = typeArguments;
@@ -16371,13 +16922,13 @@ var ts;
currentNode = currentNode.parent;
}
// if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal
- links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135 /* TypeParameter */;
+ links.isIllegalTypeReferenceInConstraint = currentNode.kind === 137 /* TypeParameter */;
return links.isIllegalTypeReferenceInConstraint;
}
function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) {
var typeParameterSymbol;
function check(n) {
- if (n.kind === 149 /* TypeReference */ && n.typeName.kind === 67 /* Identifier */) {
+ if (n.kind === 151 /* TypeReference */ && n.typeName.kind === 69 /* Identifier */) {
var links = getNodeLinks(n);
if (links.isIllegalTypeReferenceInConstraint === undefined) {
var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
@@ -16464,7 +17015,7 @@ var ts;
var links = getNodeLinks(node);
if (!links.resolvedType) {
// We only support expressions that are simple qualified names. For other expressions this produces undefined.
- var typeNameOrExpression = node.kind === 149 /* TypeReference */ ? node.typeName :
+ var typeNameOrExpression = node.kind === 151 /* TypeReference */ ? node.typeName :
ts.isSupportedExpressionWithTypeArguments(node) ? node.expression :
undefined;
var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol;
@@ -16496,9 +17047,9 @@ var ts;
for (var _i = 0; _i < declarations.length; _i++) {
var declaration = declarations[_i];
switch (declaration.kind) {
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 215 /* EnumDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 217 /* EnumDeclaration */:
return declaration;
}
}
@@ -16558,17 +17109,17 @@ var ts;
/**
* Instantiates a global type that is generic with some element type, and returns that instantiation.
*/
- function createTypeFromGenericGlobalType(genericGlobalType, elementType) {
- return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType;
+ function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) {
+ return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
}
function createIterableType(elementType) {
- return createTypeFromGenericGlobalType(globalIterableType, elementType);
+ return createTypeFromGenericGlobalType(globalIterableType, [elementType]);
}
function createIterableIteratorType(elementType) {
- return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType);
+ return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]);
}
function createArrayType(elementType) {
- return createTypeFromGenericGlobalType(globalArrayType, elementType);
+ return createTypeFromGenericGlobalType(globalArrayType, [elementType]);
}
function getTypeFromArrayTypeNode(node) {
var links = getNodeLinks(node);
@@ -16579,11 +17130,11 @@ var ts;
}
function createTupleType(elementTypes) {
var id = getTypeListId(elementTypes);
- var type = tupleTypes[id];
- if (!type) {
- type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes));
- type.elementTypes = elementTypes;
- }
+ return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes));
+ }
+ function createNewTupleType(elementTypes) {
+ var type = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes));
+ type.elementTypes = elementTypes;
return type;
}
function getTypeFromTupleTypeNode(node) {
@@ -16740,48 +17291,69 @@ var ts;
}
return links.resolvedType;
}
+ function getThisType(node) {
+ var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
+ var parent = container && container.parent;
+ if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) {
+ if (!(container.flags & 128 /* Static */) &&
+ (container.kind !== 144 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) {
+ return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
+ }
+ }
+ error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
+ return unknownType;
+ }
+ function getTypeFromThisTypeNode(node) {
+ var links = getNodeLinks(node);
+ if (!links.resolvedType) {
+ links.resolvedType = getThisType(node);
+ }
+ return links.resolvedType;
+ }
function getTypeFromTypeNode(node) {
switch (node.kind) {
- case 115 /* AnyKeyword */:
+ case 117 /* AnyKeyword */:
return anyType;
- case 128 /* StringKeyword */:
+ case 130 /* StringKeyword */:
return stringType;
- case 126 /* NumberKeyword */:
+ case 128 /* NumberKeyword */:
return numberType;
- case 118 /* BooleanKeyword */:
+ case 120 /* BooleanKeyword */:
return booleanType;
- case 129 /* SymbolKeyword */:
+ case 131 /* SymbolKeyword */:
return esSymbolType;
- case 101 /* VoidKeyword */:
+ case 103 /* VoidKeyword */:
return voidType;
+ case 97 /* ThisKeyword */:
+ return getTypeFromThisTypeNode(node);
case 9 /* StringLiteral */:
return getTypeFromStringLiteral(node);
- case 149 /* TypeReference */:
+ case 151 /* TypeReference */:
return getTypeFromTypeReference(node);
- case 148 /* TypePredicate */:
+ case 150 /* TypePredicate */:
return booleanType;
- case 186 /* ExpressionWithTypeArguments */:
+ case 188 /* ExpressionWithTypeArguments */:
return getTypeFromTypeReference(node);
- case 152 /* TypeQuery */:
+ case 154 /* TypeQuery */:
return getTypeFromTypeQueryNode(node);
- case 154 /* ArrayType */:
+ case 156 /* ArrayType */:
return getTypeFromArrayTypeNode(node);
- case 155 /* TupleType */:
+ case 157 /* TupleType */:
return getTypeFromTupleTypeNode(node);
- case 156 /* UnionType */:
+ case 158 /* UnionType */:
return getTypeFromUnionTypeNode(node);
- case 157 /* IntersectionType */:
+ case 159 /* IntersectionType */:
return getTypeFromIntersectionTypeNode(node);
- case 158 /* ParenthesizedType */:
+ case 160 /* ParenthesizedType */:
return getTypeFromTypeNode(node.type);
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
- case 153 /* TypeLiteral */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
+ case 155 /* TypeLiteral */:
return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
// This function assumes that an identifier or qualified name is a type expression
// Callers should first ensure this by calling isTypeNode
- case 67 /* Identifier */:
- case 133 /* QualifiedName */:
+ case 69 /* Identifier */:
+ case 135 /* QualifiedName */:
var symbol = getSymbolAtLocation(node);
return symbol && getDeclaredTypeOfSymbol(symbol);
default:
@@ -16885,7 +17457,7 @@ var ts;
type: instantiateType(signature.typePredicate.type, mapper)
};
}
- var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals);
+ var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals);
result.target = signature;
result.mapper = mapper;
return result;
@@ -16923,21 +17495,13 @@ var ts;
}
// Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it
var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol);
- result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
- result.members = createSymbolTable(result.properties);
- result.callSignatures = instantiateList(getSignaturesOfType(type, 0 /* Call */), mapper, instantiateSignature);
- result.constructSignatures = instantiateList(getSignaturesOfType(type, 1 /* Construct */), mapper, instantiateSignature);
- var stringIndexType = getIndexTypeOfType(type, 0 /* String */);
- var numberIndexType = getIndexTypeOfType(type, 1 /* Number */);
- if (stringIndexType)
- result.stringIndexType = instantiateType(stringIndexType, mapper);
- if (numberIndexType)
- result.numberIndexType = instantiateType(numberIndexType, mapper);
+ result.target = type;
+ result.mapper = mapper;
mapper.instantiations[type.id] = result;
return result;
}
function instantiateType(type, mapper) {
- if (mapper !== identityMapper) {
+ if (type && mapper !== identityMapper) {
if (type.flags & 512 /* TypeParameter */) {
return mapper(type);
}
@@ -16963,27 +17527,27 @@ var ts;
// Returns true if the given expression contains (at any level of nesting) a function or arrow expression
// that is subject to contextual typing.
function isContextSensitive(node) {
- ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
+ ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
switch (node.kind) {
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
return isContextSensitiveFunctionLikeDeclaration(node);
- case 163 /* ObjectLiteralExpression */:
+ case 165 /* ObjectLiteralExpression */:
return ts.forEach(node.properties, isContextSensitive);
- case 162 /* ArrayLiteralExpression */:
+ case 164 /* ArrayLiteralExpression */:
return ts.forEach(node.elements, isContextSensitive);
- case 180 /* ConditionalExpression */:
+ case 182 /* ConditionalExpression */:
return isContextSensitive(node.whenTrue) ||
isContextSensitive(node.whenFalse);
- case 179 /* BinaryExpression */:
- return node.operatorToken.kind === 51 /* BarBarToken */ &&
+ case 181 /* BinaryExpression */:
+ return node.operatorToken.kind === 52 /* BarBarToken */ &&
(isContextSensitive(node.left) || isContextSensitive(node.right));
- case 243 /* PropertyAssignment */:
+ case 245 /* PropertyAssignment */:
return isContextSensitive(node.initializer);
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
return isContextSensitiveFunctionLikeDeclaration(node);
- case 170 /* ParenthesizedExpression */:
+ case 172 /* ParenthesizedExpression */:
return isContextSensitive(node.expression);
}
return false;
@@ -17120,7 +17684,9 @@ var ts;
// and intersection types are further deconstructed on the target side, we don't want to
// make the check again (as it might fail for a partial target type). Therefore we obtain
// the regular source type and proceed with that.
- source = getRegularTypeOfObjectLiteral(source);
+ if (target.flags & 49152 /* UnionOrIntersection */) {
+ source = getRegularTypeOfObjectLiteral(source);
+ }
}
var saveErrorInfo = errorInfo;
// Note that the "each" checks must precede the "some" checks to produce the correct results
@@ -17165,7 +17731,7 @@ var ts;
else {
if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) {
// We have type references to same target type, see if relationship holds for all type arguments
- if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) {
+ if (result = typeArgumentsRelatedTo(source, target, reportErrors)) {
return result;
}
}
@@ -17194,7 +17760,7 @@ var ts;
if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) {
if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) {
// We have type references to same target type, see if all type arguments are identical
- if (result = typesRelatedTo(source.typeArguments, target.typeArguments, /*reportErrors*/ false)) {
+ if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) {
return result;
}
}
@@ -17311,9 +17877,14 @@ var ts;
}
return result;
}
- function typesRelatedTo(sources, targets, reportErrors) {
+ function typeArgumentsRelatedTo(source, target, reportErrors) {
+ var sources = source.typeArguments || emptyArray;
+ var targets = target.typeArguments || emptyArray;
+ if (sources.length !== targets.length && relation === identityRelation) {
+ return 0 /* False */;
+ }
var result = -1 /* True */;
- for (var i = 0, len = sources.length; i < len; i++) {
+ for (var i = 0; i < targets.length; i++) {
var related = isRelatedTo(sources[i], targets[i], reportErrors);
if (!related) {
return 0 /* False */;
@@ -17531,7 +18102,7 @@ var ts;
if (kind === 1 /* Construct */) {
// Only want to compare the construct signatures for abstractness guarantees.
// Because the "abstractness" of a class is the same across all construct signatures
- // (internally we are checking the corresponding declaration), it is enough to perform
+ // (internally we are checking the corresponding declaration), it is enough to perform
// the check and report an error once over all pairs of source and target construct signatures.
//
// sourceSig and targetSig are (possibly) undefined.
@@ -17568,8 +18139,8 @@ var ts;
return result;
function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) {
if (sourceSig && targetSig) {
- var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212 /* ClassDeclaration */);
- var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212 /* ClassDeclaration */);
+ var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
+ var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
if (!sourceDecl) {
// If the source object isn't itself a class declaration, it can be freely assigned, regardless
// of whether the constructed object is abstract or not.
@@ -17579,8 +18150,8 @@ var ts;
var targetErasedSignature = getErasedSignature(targetSig);
var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
- var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212 /* ClassDeclaration */);
- var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212 /* ClassDeclaration */);
+ var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
+ var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */;
var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */;
if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) {
@@ -17840,11 +18411,10 @@ var ts;
// M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N
source = getErasedSignature(source);
target = getErasedSignature(target);
- var sourceLen = source.parameters.length;
var targetLen = target.parameters.length;
for (var i = 0; i < targetLen; i++) {
- var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]);
- var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]);
+ var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]);
+ var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]);
var related = compareTypes(s, t);
if (!related) {
return 0 /* False */;
@@ -17856,6 +18426,9 @@ var ts;
}
return result;
}
+ function isRestParameterIndex(signature, parameterIndex) {
+ return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1;
+ }
function isSupertypeOfEach(candidate, types) {
for (var _i = 0; _i < types.length; _i++) {
var type = types[_i];
@@ -17929,6 +18502,7 @@ var ts;
regularType.constructSignatures = type.constructSignatures;
regularType.stringIndexType = type.stringIndexType;
regularType.numberIndexType = type.numberIndexType;
+ type.regularType = regularType;
}
return regularType;
}
@@ -18030,22 +18604,22 @@ var ts;
var typeAsString = typeToString(getWidenedType(type));
var diagnostic;
switch (declaration.kind) {
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type;
break;
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
diagnostic = declaration.dotDotDotToken ?
ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type :
ts.Diagnostics.Parameter_0_implicitly_has_an_1_type;
break;
- case 211 /* FunctionDeclaration */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
+ case 213 /* FunctionDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
if (!declaration.name) {
error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
return;
@@ -18155,9 +18729,10 @@ var ts;
}
else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) {
// If source and target are references to the same generic type, infer from type arguments
- var sourceTypes = source.typeArguments;
- var targetTypes = target.typeArguments;
- for (var i = 0; i < sourceTypes.length; i++) {
+ var sourceTypes = source.typeArguments || emptyArray;
+ var targetTypes = target.typeArguments || emptyArray;
+ var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
+ for (var i = 0; i < count; i++) {
inferFromTypes(sourceTypes[i], targetTypes[i]);
}
}
@@ -18335,10 +18910,10 @@ var ts;
// The expression is restricted to a single identifier or a sequence of identifiers separated by periods
while (node) {
switch (node.kind) {
- case 152 /* TypeQuery */:
+ case 154 /* TypeQuery */:
return true;
- case 67 /* Identifier */:
- case 133 /* QualifiedName */:
+ case 69 /* Identifier */:
+ case 135 /* QualifiedName */:
node = node.parent;
continue;
default:
@@ -18384,12 +18959,12 @@ var ts;
}
return links.assignmentChecks[symbol.id] = isAssignedIn(node);
function isAssignedInBinaryExpression(node) {
- if (node.operatorToken.kind >= 55 /* FirstAssignment */ && node.operatorToken.kind <= 66 /* LastAssignment */) {
+ if (node.operatorToken.kind >= 56 /* FirstAssignment */ && node.operatorToken.kind <= 68 /* LastAssignment */) {
var n = node.left;
- while (n.kind === 170 /* ParenthesizedExpression */) {
+ while (n.kind === 172 /* ParenthesizedExpression */) {
n = n.expression;
}
- if (n.kind === 67 /* Identifier */ && getResolvedSymbol(n) === symbol) {
+ if (n.kind === 69 /* Identifier */ && getResolvedSymbol(n) === symbol) {
return true;
}
}
@@ -18403,55 +18978,55 @@ var ts;
}
function isAssignedIn(node) {
switch (node.kind) {
- case 179 /* BinaryExpression */:
+ case 181 /* BinaryExpression */:
return isAssignedInBinaryExpression(node);
- case 209 /* VariableDeclaration */:
- case 161 /* BindingElement */:
+ case 211 /* VariableDeclaration */:
+ case 163 /* BindingElement */:
return isAssignedInVariableDeclaration(node);
- case 159 /* ObjectBindingPattern */:
- case 160 /* ArrayBindingPattern */:
- case 162 /* ArrayLiteralExpression */:
- case 163 /* ObjectLiteralExpression */:
- case 164 /* PropertyAccessExpression */:
- case 165 /* ElementAccessExpression */:
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
- case 169 /* TypeAssertionExpression */:
- case 187 /* AsExpression */:
- case 170 /* ParenthesizedExpression */:
- case 177 /* PrefixUnaryExpression */:
- case 173 /* DeleteExpression */:
- case 176 /* AwaitExpression */:
- case 174 /* TypeOfExpression */:
- case 175 /* VoidExpression */:
- case 178 /* PostfixUnaryExpression */:
- case 182 /* YieldExpression */:
- case 180 /* ConditionalExpression */:
- case 183 /* SpreadElementExpression */:
- case 190 /* Block */:
- case 191 /* VariableStatement */:
- case 193 /* ExpressionStatement */:
- case 194 /* IfStatement */:
- case 195 /* DoStatement */:
- case 196 /* WhileStatement */:
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 202 /* ReturnStatement */:
- case 203 /* WithStatement */:
- case 204 /* SwitchStatement */:
- case 239 /* CaseClause */:
- case 240 /* DefaultClause */:
- case 205 /* LabeledStatement */:
- case 206 /* ThrowStatement */:
- case 207 /* TryStatement */:
- case 242 /* CatchClause */:
- case 231 /* JsxElement */:
- case 232 /* JsxSelfClosingElement */:
- case 236 /* JsxAttribute */:
- case 237 /* JsxSpreadAttribute */:
- case 233 /* JsxOpeningElement */:
- case 238 /* JsxExpression */:
+ case 161 /* ObjectBindingPattern */:
+ case 162 /* ArrayBindingPattern */:
+ case 164 /* ArrayLiteralExpression */:
+ case 165 /* ObjectLiteralExpression */:
+ case 166 /* PropertyAccessExpression */:
+ case 167 /* ElementAccessExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
+ case 171 /* TypeAssertionExpression */:
+ case 189 /* AsExpression */:
+ case 172 /* ParenthesizedExpression */:
+ case 179 /* PrefixUnaryExpression */:
+ case 175 /* DeleteExpression */:
+ case 178 /* AwaitExpression */:
+ case 176 /* TypeOfExpression */:
+ case 177 /* VoidExpression */:
+ case 180 /* PostfixUnaryExpression */:
+ case 184 /* YieldExpression */:
+ case 182 /* ConditionalExpression */:
+ case 185 /* SpreadElementExpression */:
+ case 192 /* Block */:
+ case 193 /* VariableStatement */:
+ case 195 /* ExpressionStatement */:
+ case 196 /* IfStatement */:
+ case 197 /* DoStatement */:
+ case 198 /* WhileStatement */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 204 /* ReturnStatement */:
+ case 205 /* WithStatement */:
+ case 206 /* SwitchStatement */:
+ case 241 /* CaseClause */:
+ case 242 /* DefaultClause */:
+ case 207 /* LabeledStatement */:
+ case 208 /* ThrowStatement */:
+ case 209 /* TryStatement */:
+ case 244 /* CatchClause */:
+ case 233 /* JsxElement */:
+ case 234 /* JsxSelfClosingElement */:
+ case 238 /* JsxAttribute */:
+ case 239 /* JsxSpreadAttribute */:
+ case 235 /* JsxOpeningElement */:
+ case 240 /* JsxExpression */:
return ts.forEachChild(node, isAssignedIn);
}
return false;
@@ -18468,37 +19043,37 @@ var ts;
node = node.parent;
var narrowedType = type;
switch (node.kind) {
- case 194 /* IfStatement */:
+ case 196 /* IfStatement */:
// In a branch of an if statement, narrow based on controlling expression
if (child !== node.expression) {
narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement);
}
break;
- case 180 /* ConditionalExpression */:
+ case 182 /* ConditionalExpression */:
// In a branch of a conditional expression, narrow based on controlling condition
if (child !== node.condition) {
narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue);
}
break;
- case 179 /* BinaryExpression */:
+ case 181 /* BinaryExpression */:
// In the right operand of an && or ||, narrow based on left operand
if (child === node.right) {
- if (node.operatorToken.kind === 50 /* AmpersandAmpersandToken */) {
+ if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) {
narrowedType = narrowType(type, node.left, /*assumeTrue*/ true);
}
- else if (node.operatorToken.kind === 51 /* BarBarToken */) {
+ else if (node.operatorToken.kind === 52 /* BarBarToken */) {
narrowedType = narrowType(type, node.left, /*assumeTrue*/ false);
}
}
break;
- case 246 /* SourceFile */:
- case 216 /* ModuleDeclaration */:
- case 211 /* FunctionDeclaration */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 142 /* Constructor */:
+ case 248 /* SourceFile */:
+ case 218 /* ModuleDeclaration */:
+ case 213 /* FunctionDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 144 /* Constructor */:
// Stop at the first containing function or module declaration
break loop;
}
@@ -18515,12 +19090,12 @@ var ts;
return type;
function narrowTypeByEquality(type, expr, assumeTrue) {
// Check that we have 'typeof ' on the left and string literal on the right
- if (expr.left.kind !== 174 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) {
+ if (expr.left.kind !== 176 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) {
return type;
}
var left = expr.left;
var right = expr.right;
- if (left.expression.kind !== 67 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) {
+ if (left.expression.kind !== 69 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) {
return type;
}
var typeInfo = primitiveTypeInfo[right.text];
@@ -18580,7 +19155,7 @@ var ts;
}
function narrowTypeByInstanceof(type, expr, assumeTrue) {
// Check that type is not any, assumed result is true, and we have variable symbol on the left
- if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) {
+ if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 69 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) {
return type;
}
// Check that right operand is a function type with a prototype property
@@ -18652,27 +19227,27 @@ var ts;
// will be a subtype or the same type as the argument.
function narrowType(type, expr, assumeTrue) {
switch (expr.kind) {
- case 166 /* CallExpression */:
+ case 168 /* CallExpression */:
return narrowTypeByTypePredicate(type, expr, assumeTrue);
- case 170 /* ParenthesizedExpression */:
+ case 172 /* ParenthesizedExpression */:
return narrowType(type, expr.expression, assumeTrue);
- case 179 /* BinaryExpression */:
+ case 181 /* BinaryExpression */:
var operator = expr.operatorToken.kind;
if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) {
return narrowTypeByEquality(type, expr, assumeTrue);
}
- else if (operator === 50 /* AmpersandAmpersandToken */) {
+ else if (operator === 51 /* AmpersandAmpersandToken */) {
return narrowTypeByAnd(type, expr, assumeTrue);
}
- else if (operator === 51 /* BarBarToken */) {
+ else if (operator === 52 /* BarBarToken */) {
return narrowTypeByOr(type, expr, assumeTrue);
}
- else if (operator === 89 /* InstanceOfKeyword */) {
+ else if (operator === 91 /* InstanceOfKeyword */) {
return narrowTypeByInstanceof(type, expr, assumeTrue);
}
break;
- case 177 /* PrefixUnaryExpression */:
- if (expr.operator === 48 /* ExclamationToken */) {
+ case 179 /* PrefixUnaryExpression */:
+ if (expr.operator === 49 /* ExclamationToken */) {
return narrowType(type, expr.operand, !assumeTrue);
}
break;
@@ -18690,7 +19265,7 @@ var ts;
// can explicitly bound arguments objects
if (symbol === argumentsSymbol) {
var container = ts.getContainingFunction(node);
- if (container.kind === 172 /* ArrowFunction */) {
+ if (container.kind === 174 /* ArrowFunction */) {
if (languageVersion < 2 /* ES6 */) {
error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
}
@@ -18721,7 +19296,7 @@ var ts;
function checkBlockScopedBindingCapturedInLoop(node, symbol) {
if (languageVersion >= 2 /* ES6 */ ||
(symbol.flags & 2 /* BlockScopedVariable */) === 0 ||
- symbol.valueDeclaration.parent.kind === 242 /* CatchClause */) {
+ symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) {
return;
}
// - check if binding is used in some function
@@ -18730,12 +19305,12 @@ var ts;
// nesting structure:
// (variable declaration or binding element) -> variable declaration list -> container
var container = symbol.valueDeclaration;
- while (container.kind !== 210 /* VariableDeclarationList */) {
+ while (container.kind !== 212 /* VariableDeclarationList */) {
container = container.parent;
}
// get the parent of variable declaration list
container = container.parent;
- if (container.kind === 191 /* VariableStatement */) {
+ if (container.kind === 193 /* VariableStatement */) {
// if parent is variable statement - get its parent
container = container.parent;
}
@@ -18755,7 +19330,7 @@ var ts;
}
function captureLexicalThis(node, container) {
getNodeLinks(node).flags |= 2 /* LexicalThis */;
- if (container.kind === 139 /* PropertyDeclaration */ || container.kind === 142 /* Constructor */) {
+ if (container.kind === 141 /* PropertyDeclaration */ || container.kind === 144 /* Constructor */) {
var classNode = container.parent;
getNodeLinks(classNode).flags |= 4 /* CaptureThis */;
}
@@ -18769,32 +19344,32 @@ var ts;
var container = ts.getThisContainer(node, /* includeArrowFunctions */ true);
var needToCaptureLexicalThis = false;
// Now skip arrow functions to get the "real" owner of 'this'.
- if (container.kind === 172 /* ArrowFunction */) {
+ if (container.kind === 174 /* ArrowFunction */) {
container = ts.getThisContainer(container, /* includeArrowFunctions */ false);
// When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code
needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */);
}
switch (container.kind) {
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
// do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks
break;
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
// do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks
break;
- case 142 /* Constructor */:
+ case 144 /* Constructor */:
if (isInConstructorArgumentInitializer(node, container)) {
error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments);
}
break;
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
if (container.flags & 128 /* Static */) {
error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer);
}
break;
- case 134 /* ComputedPropertyName */:
+ case 136 /* ComputedPropertyName */:
error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
break;
}
@@ -18803,35 +19378,35 @@ var ts;
}
if (ts.isClassLike(container.parent)) {
var symbol = getSymbolOfNode(container.parent);
- return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol);
+ return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
}
return anyType;
}
function isInConstructorArgumentInitializer(node, constructorDecl) {
for (var n = node; n && n !== constructorDecl; n = n.parent) {
- if (n.kind === 136 /* Parameter */) {
+ if (n.kind === 138 /* Parameter */) {
return true;
}
}
return false;
}
function checkSuperExpression(node) {
- var isCallExpression = node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node;
+ var isCallExpression = node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node;
var classDeclaration = ts.getContainingClass(node);
var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration));
var baseClassType = classType && getBaseTypes(classType)[0];
var container = ts.getSuperContainer(node, /*includeFunctions*/ true);
var needToCaptureLexicalThis = false;
if (!isCallExpression) {
- // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting
- while (container && container.kind === 172 /* ArrowFunction */) {
+ // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting
+ while (container && container.kind === 174 /* ArrowFunction */) {
container = ts.getSuperContainer(container, /*includeFunctions*/ true);
needToCaptureLexicalThis = languageVersion < 2 /* ES6 */;
}
}
var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
var nodeCheckFlag = 0;
- // always set NodeCheckFlags for 'super' expression node
+ // always set NodeCheckFlags for 'super' expression node
if (canUseSuperExpression) {
if ((container.flags & 128 /* Static */) || isCallExpression) {
nodeCheckFlag = 512 /* SuperStatic */;
@@ -18854,7 +19429,7 @@ var ts;
return unknownType;
}
if (!canUseSuperExpression) {
- if (container && container.kind === 134 /* ComputedPropertyName */) {
+ if (container && container.kind === 136 /* ComputedPropertyName */) {
error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
}
else if (isCallExpression) {
@@ -18865,7 +19440,7 @@ var ts;
}
return unknownType;
}
- if (container.kind === 142 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) {
+ if (container.kind === 144 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) {
// issue custom error message for super property access in constructor arguments (to be aligned with old compiler)
error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
return unknownType;
@@ -18880,7 +19455,7 @@ var ts;
if (isCallExpression) {
// TS 1.0 SPEC (April 2014): 4.8.1
// Super calls are only permitted in constructors of derived classes
- return container.kind === 142 /* Constructor */;
+ return container.kind === 144 /* Constructor */;
}
else {
// TS 1.0 SPEC (April 2014)
@@ -18890,19 +19465,19 @@ var ts;
// topmost container must be something that is directly nested in the class declaration
if (container && ts.isClassLike(container.parent)) {
if (container.flags & 128 /* Static */) {
- return container.kind === 141 /* MethodDeclaration */ ||
- container.kind === 140 /* MethodSignature */ ||
- container.kind === 143 /* GetAccessor */ ||
- container.kind === 144 /* SetAccessor */;
+ return container.kind === 143 /* MethodDeclaration */ ||
+ container.kind === 142 /* MethodSignature */ ||
+ container.kind === 145 /* GetAccessor */ ||
+ container.kind === 146 /* SetAccessor */;
}
else {
- return container.kind === 141 /* MethodDeclaration */ ||
- container.kind === 140 /* MethodSignature */ ||
- container.kind === 143 /* GetAccessor */ ||
- container.kind === 144 /* SetAccessor */ ||
- container.kind === 139 /* PropertyDeclaration */ ||
- container.kind === 138 /* PropertySignature */ ||
- container.kind === 142 /* Constructor */;
+ return container.kind === 143 /* MethodDeclaration */ ||
+ container.kind === 142 /* MethodSignature */ ||
+ container.kind === 145 /* GetAccessor */ ||
+ container.kind === 146 /* SetAccessor */ ||
+ container.kind === 141 /* PropertyDeclaration */ ||
+ container.kind === 140 /* PropertySignature */ ||
+ container.kind === 144 /* Constructor */;
}
}
}
@@ -18911,8 +19486,8 @@ var ts;
}
// Return contextual type of parameter or undefined if no contextual type is available
function getContextuallyTypedParameterType(parameter) {
- if (isFunctionExpressionOrArrowFunction(parameter.parent)) {
- var func = parameter.parent;
+ var func = parameter.parent;
+ if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) {
if (isContextSensitive(func)) {
var contextualSignature = getContextualSignature(func);
if (contextualSignature) {
@@ -18923,8 +19498,9 @@ var ts;
return getTypeAtPosition(contextualSignature, indexOfParameter);
}
// If last parameter is contextually rest parameter get its type
- if (indexOfParameter === (func.parameters.length - 1) &&
- funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) {
+ if (funcHasRestParameters &&
+ indexOfParameter === (func.parameters.length - 1) &&
+ isRestParameterIndex(contextualSignature, func.parameters.length - 1)) {
return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters));
}
}
@@ -18943,14 +19519,14 @@ var ts;
if (declaration.type) {
return getTypeFromTypeNode(declaration.type);
}
- if (declaration.kind === 136 /* Parameter */) {
+ if (declaration.kind === 138 /* Parameter */) {
var type = getContextuallyTypedParameterType(declaration);
if (type) {
return type;
}
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true);
}
}
return undefined;
@@ -18976,7 +19552,7 @@ var ts;
}
function isInParameterInitializerBeforeContainingFunction(node) {
while (node.parent && !ts.isFunctionLike(node.parent)) {
- if (node.parent.kind === 136 /* Parameter */ && node.parent.initializer === node) {
+ if (node.parent.kind === 138 /* Parameter */ && node.parent.initializer === node) {
return true;
}
node = node.parent;
@@ -18987,8 +19563,8 @@ var ts;
// If the containing function has a return type annotation, is a constructor, or is a get accessor whose
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
if (functionDecl.type ||
- functionDecl.kind === 142 /* Constructor */ ||
- functionDecl.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144 /* SetAccessor */))) {
+ functionDecl.kind === 144 /* Constructor */ ||
+ functionDecl.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 146 /* SetAccessor */))) {
return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl));
}
// Otherwise, if the containing function is contextually typed by a function type with exactly one call signature
@@ -19010,7 +19586,7 @@ var ts;
return undefined;
}
function getContextualTypeForSubstitutionExpression(template, substitutionExpression) {
- if (template.parent.kind === 168 /* TaggedTemplateExpression */) {
+ if (template.parent.kind === 170 /* TaggedTemplateExpression */) {
return getContextualTypeForArgument(template.parent, substitutionExpression);
}
return undefined;
@@ -19018,13 +19594,13 @@ var ts;
function getContextualTypeForBinaryOperand(node) {
var binaryExpression = node.parent;
var operator = binaryExpression.operatorToken.kind;
- if (operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) {
+ if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) {
// In an assignment expression, the right operand is contextually typed by the type of the left operand.
if (node === binaryExpression.right) {
return checkExpression(binaryExpression.left);
}
}
- else if (operator === 51 /* BarBarToken */) {
+ else if (operator === 52 /* BarBarToken */) {
// When an || expression has a contextual type, the operands are contextually typed by that type. When an ||
// expression has no contextual type, the right operand is contextually typed by the type of the left operand.
var type = getContextualType(binaryExpression);
@@ -19131,7 +19707,7 @@ var ts;
}
function getContextualTypeForJsxExpression(expr) {
// Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions)
- if (expr.parent.kind === 236 /* JsxAttribute */) {
+ if (expr.parent.kind === 238 /* JsxAttribute */) {
var attrib = expr.parent;
var attrsType = getJsxElementAttributesType(attrib.parent);
if (!attrsType || isTypeAny(attrsType)) {
@@ -19141,7 +19717,7 @@ var ts;
return getTypeOfPropertyOfType(attrsType, attrib.name.text);
}
}
- if (expr.kind === 237 /* JsxSpreadAttribute */) {
+ if (expr.kind === 239 /* JsxSpreadAttribute */) {
return getJsxElementAttributesType(expr.parent);
}
return undefined;
@@ -19162,38 +19738,38 @@ var ts;
}
var parent = node.parent;
switch (parent.kind) {
- case 209 /* VariableDeclaration */:
- case 136 /* Parameter */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 161 /* BindingElement */:
+ case 211 /* VariableDeclaration */:
+ case 138 /* Parameter */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 163 /* BindingElement */:
return getContextualTypeForInitializerExpression(node);
- case 172 /* ArrowFunction */:
- case 202 /* ReturnStatement */:
+ case 174 /* ArrowFunction */:
+ case 204 /* ReturnStatement */:
return getContextualTypeForReturnExpression(node);
- case 182 /* YieldExpression */:
+ case 184 /* YieldExpression */:
return getContextualTypeForYieldOperand(parent);
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
return getContextualTypeForArgument(parent, node);
- case 169 /* TypeAssertionExpression */:
- case 187 /* AsExpression */:
+ case 171 /* TypeAssertionExpression */:
+ case 189 /* AsExpression */:
return getTypeFromTypeNode(parent.type);
- case 179 /* BinaryExpression */:
+ case 181 /* BinaryExpression */:
return getContextualTypeForBinaryOperand(node);
- case 243 /* PropertyAssignment */:
+ case 245 /* PropertyAssignment */:
return getContextualTypeForObjectLiteralElement(parent);
- case 162 /* ArrayLiteralExpression */:
+ case 164 /* ArrayLiteralExpression */:
return getContextualTypeForElementExpression(node);
- case 180 /* ConditionalExpression */:
+ case 182 /* ConditionalExpression */:
return getContextualTypeForConditionalOperand(node);
- case 188 /* TemplateSpan */:
- ts.Debug.assert(parent.parent.kind === 181 /* TemplateExpression */);
+ case 190 /* TemplateSpan */:
+ ts.Debug.assert(parent.parent.kind === 183 /* TemplateExpression */);
return getContextualTypeForSubstitutionExpression(parent.parent, node);
- case 170 /* ParenthesizedExpression */:
+ case 172 /* ParenthesizedExpression */:
return getContextualType(parent);
- case 238 /* JsxExpression */:
- case 237 /* JsxSpreadAttribute */:
+ case 240 /* JsxExpression */:
+ case 239 /* JsxSpreadAttribute */:
return getContextualTypeForJsxExpression(parent);
}
return undefined;
@@ -19210,7 +19786,7 @@ var ts;
}
}
function isFunctionExpressionOrArrowFunction(node) {
- return node.kind === 171 /* FunctionExpression */ || node.kind === 172 /* ArrowFunction */;
+ return node.kind === 173 /* FunctionExpression */ || node.kind === 174 /* ArrowFunction */;
}
function getContextualSignatureForFunctionLikeDeclaration(node) {
// Only function expressions, arrow functions, and object literal methods are contextually typed.
@@ -19224,7 +19800,7 @@ var ts;
// all identical ignoring their return type, the result is same signature but with return type as
// union type of return types from these signatures
function getContextualSignature(node) {
- ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
+ ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
var type = ts.isObjectLiteralMethod(node)
? getContextualTypeForObjectLiteralMethod(node)
: getContextualType(node);
@@ -19287,13 +19863,13 @@ var ts;
// an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'.
function isAssignmentTarget(node) {
var parent = node.parent;
- if (parent.kind === 179 /* BinaryExpression */ && parent.operatorToken.kind === 55 /* EqualsToken */ && parent.left === node) {
+ if (parent.kind === 181 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) {
return true;
}
- if (parent.kind === 243 /* PropertyAssignment */) {
+ if (parent.kind === 245 /* PropertyAssignment */) {
return isAssignmentTarget(parent.parent);
}
- if (parent.kind === 162 /* ArrayLiteralExpression */) {
+ if (parent.kind === 164 /* ArrayLiteralExpression */) {
return isAssignmentTarget(parent);
}
return false;
@@ -19308,17 +19884,18 @@ var ts;
var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
}
+ function hasDefaultValue(node) {
+ return (node.kind === 163 /* BindingElement */ && !!node.initializer) ||
+ (node.kind === 181 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */);
+ }
function checkArrayLiteral(node, contextualMapper) {
var elements = node.elements;
- if (!elements.length) {
- return createArrayType(undefinedType);
- }
var hasSpreadElement = false;
var elementTypes = [];
var inDestructuringPattern = isAssignmentTarget(node);
for (var _i = 0; _i < elements.length; _i++) {
var e = elements[_i];
- if (inDestructuringPattern && e.kind === 183 /* SpreadElementExpression */) {
+ if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) {
// Given the following situation:
// var c: {};
// [...c] = ["", 0];
@@ -19342,18 +19919,45 @@ var ts;
var type = checkExpression(e, contextualMapper);
elementTypes.push(type);
}
- hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */;
+ hasSpreadElement = hasSpreadElement || e.kind === 185 /* SpreadElementExpression */;
}
if (!hasSpreadElement) {
+ // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such
+ // that we get the same behavior for "var [x, y] = []" and "[x, y] = []".
+ if (inDestructuringPattern && elementTypes.length) {
+ var type = createNewTupleType(elementTypes);
+ type.pattern = node;
+ return type;
+ }
var contextualType = getContextualType(node);
- if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
- return createTupleType(elementTypes);
+ if (contextualType && contextualTypeIsTupleLikeType(contextualType)) {
+ var pattern = contextualType.pattern;
+ // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting
+ // tuple type with the corresponding binding or assignment element types to make the lengths equal.
+ if (pattern && (pattern.kind === 162 /* ArrayBindingPattern */ || pattern.kind === 164 /* ArrayLiteralExpression */)) {
+ var patternElements = pattern.elements;
+ for (var i = elementTypes.length; i < patternElements.length; i++) {
+ var patternElement = patternElements[i];
+ if (hasDefaultValue(patternElement)) {
+ elementTypes.push(contextualType.elementTypes[i]);
+ }
+ else {
+ if (patternElement.kind !== 187 /* OmittedExpression */) {
+ error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ elementTypes.push(unknownType);
+ }
+ }
+ }
+ if (elementTypes.length) {
+ return createTupleType(elementTypes);
+ }
}
}
- return createArrayType(getUnionType(elementTypes));
+ return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType);
}
function isNumericName(name) {
- return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text);
+ return name.kind === 136 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text);
}
function isNumericComputedName(name) {
// It seems odd to consider an expression of type Any to result in a numeric name,
@@ -19403,31 +20007,54 @@ var ts;
return links.resolvedType;
}
function checkObjectLiteral(node, contextualMapper) {
+ var inDestructuringPattern = isAssignmentTarget(node);
// Grammar checking
- checkGrammarObjectLiteralExpression(node);
+ checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
var propertiesTable = {};
var propertiesArray = [];
var contextualType = getContextualType(node);
+ var contextualTypeHasPattern = contextualType && contextualType.pattern &&
+ (contextualType.pattern.kind === 161 /* ObjectBindingPattern */ || contextualType.pattern.kind === 165 /* ObjectLiteralExpression */);
var typeFlags = 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var memberDecl = _a[_i];
var member = memberDecl.symbol;
- if (memberDecl.kind === 243 /* PropertyAssignment */ ||
- memberDecl.kind === 244 /* ShorthandPropertyAssignment */ ||
+ if (memberDecl.kind === 245 /* PropertyAssignment */ ||
+ memberDecl.kind === 246 /* ShorthandPropertyAssignment */ ||
ts.isObjectLiteralMethod(memberDecl)) {
var type = void 0;
- if (memberDecl.kind === 243 /* PropertyAssignment */) {
+ if (memberDecl.kind === 245 /* PropertyAssignment */) {
type = checkPropertyAssignment(memberDecl, contextualMapper);
}
- else if (memberDecl.kind === 141 /* MethodDeclaration */) {
+ else if (memberDecl.kind === 143 /* MethodDeclaration */) {
type = checkObjectLiteralMethod(memberDecl, contextualMapper);
}
else {
- ts.Debug.assert(memberDecl.kind === 244 /* ShorthandPropertyAssignment */);
+ ts.Debug.assert(memberDecl.kind === 246 /* ShorthandPropertyAssignment */);
type = checkExpression(memberDecl.name, contextualMapper);
}
typeFlags |= type.flags;
var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name);
+ if (inDestructuringPattern) {
+ // If object literal is an assignment pattern and if the assignment pattern specifies a default value
+ // for the property, make the property optional.
+ var isOptional = (memberDecl.kind === 245 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) ||
+ (memberDecl.kind === 246 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer);
+ if (isOptional) {
+ prop.flags |= 536870912 /* Optional */;
+ }
+ }
+ else if (contextualTypeHasPattern) {
+ // If object literal is contextually typed by the implied type of a binding pattern, and if the
+ // binding pattern specifies a default value for the property, make the property optional.
+ var impliedProp = getPropertyOfType(contextualType, member.name);
+ if (impliedProp) {
+ prop.flags |= impliedProp.flags & 536870912 /* Optional */;
+ }
+ else if (!compilerOptions.suppressExcessPropertyErrors) {
+ error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
+ }
+ }
prop.declarations = member.declarations;
prop.parent = member.parent;
if (member.valueDeclaration) {
@@ -19443,7 +20070,7 @@ var ts;
// an ordinary function declaration(section 6.1) with no parameters.
// A set accessor declaration is processed in the same manner
// as an ordinary function declaration with a single parameter and a Void return type.
- ts.Debug.assert(memberDecl.kind === 143 /* GetAccessor */ || memberDecl.kind === 144 /* SetAccessor */);
+ ts.Debug.assert(memberDecl.kind === 145 /* GetAccessor */ || memberDecl.kind === 146 /* SetAccessor */);
checkAccessorDeclaration(memberDecl);
}
if (!ts.hasDynamicName(memberDecl)) {
@@ -19451,11 +20078,28 @@ var ts;
}
propertiesArray.push(member);
}
+ // If object literal is contextually typed by the implied type of a binding pattern, augment the result
+ // type with those properties for which the binding pattern specifies a default value.
+ if (contextualTypeHasPattern) {
+ for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
+ var prop = _c[_b];
+ if (!ts.hasProperty(propertiesTable, prop.name)) {
+ if (!(prop.flags & 536870912 /* Optional */)) {
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ propertiesTable[prop.name] = prop;
+ propertiesArray.push(prop);
+ }
+ }
+ }
var stringIndexType = getIndexType(0 /* String */);
var numberIndexType = getIndexType(1 /* Number */);
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */;
result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */);
+ if (inDestructuringPattern) {
+ result.pattern = node;
+ }
return result;
function getIndexType(kind) {
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
@@ -19488,7 +20132,7 @@ var ts;
if (lhs.kind !== rhs.kind) {
return false;
}
- if (lhs.kind === 67 /* Identifier */) {
+ if (lhs.kind === 69 /* Identifier */) {
return lhs.text === rhs.text;
}
return lhs.right.text === rhs.right.text &&
@@ -19509,18 +20153,18 @@ var ts;
for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
var child = _a[_i];
switch (child.kind) {
- case 238 /* JsxExpression */:
+ case 240 /* JsxExpression */:
checkJsxExpression(child);
break;
- case 231 /* JsxElement */:
+ case 233 /* JsxElement */:
checkJsxElement(child);
break;
- case 232 /* JsxSelfClosingElement */:
+ case 234 /* JsxSelfClosingElement */:
checkJsxSelfClosingElement(child);
break;
default:
// No checks for JSX Text
- ts.Debug.assert(child.kind === 234 /* JsxText */);
+ ts.Debug.assert(child.kind === 236 /* JsxText */);
}
}
return jsxElementType || anyType;
@@ -19536,7 +20180,7 @@ var ts;
* Returns true iff React would emit this tag name as a string rather than an identifier or qualified name
*/
function isJsxIntrinsicIdentifier(tagName) {
- if (tagName.kind === 133 /* QualifiedName */) {
+ if (tagName.kind === 135 /* QualifiedName */) {
return false;
}
else {
@@ -19655,12 +20299,14 @@ var ts;
// Look up the value in the current scope
if (valueSymbol && valueSymbol !== unknownSymbol) {
links.jsxFlags |= 4 /* ClassElement */;
- getSymbolLinks(valueSymbol).referenced = true;
+ if (valueSymbol.flags & 8388608 /* Alias */) {
+ markAliasSymbolAsReferenced(valueSymbol);
+ }
}
return valueSymbol || unknownSymbol;
}
function resolveJsxTagName(node) {
- if (node.tagName.kind === 67 /* Identifier */) {
+ if (node.tagName.kind === 69 /* Identifier */) {
var tag = node.tagName;
var sym = getResolvedSymbol(tag);
return sym.exportSymbol || sym;
@@ -19845,11 +20491,11 @@ var ts;
// thus should have their types ignored
var sawSpreadedAny = false;
for (var i = node.attributes.length - 1; i >= 0; i--) {
- if (node.attributes[i].kind === 236 /* JsxAttribute */) {
+ if (node.attributes[i].kind === 238 /* JsxAttribute */) {
checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable);
}
else {
- ts.Debug.assert(node.attributes[i].kind === 237 /* JsxSpreadAttribute */);
+ ts.Debug.assert(node.attributes[i].kind === 239 /* JsxSpreadAttribute */);
var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable);
if (isTypeAny(spreadType)) {
sawSpreadedAny = true;
@@ -19879,7 +20525,7 @@ var ts;
// If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized
// '.prototype' property as well as synthesized tuple index properties.
function getDeclarationKindFromSymbol(s) {
- return s.valueDeclaration ? s.valueDeclaration.kind : 139 /* PropertyDeclaration */;
+ return s.valueDeclaration ? s.valueDeclaration.kind : 141 /* PropertyDeclaration */;
}
function getDeclarationFlagsFromSymbol(s) {
return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0;
@@ -19895,8 +20541,8 @@ var ts;
function checkClassPropertyAccess(node, left, type, prop) {
var flags = getDeclarationFlagsFromSymbol(prop);
var declaringClass = getDeclaredTypeOfSymbol(prop.parent);
- if (left.kind === 93 /* SuperKeyword */) {
- var errorNode = node.kind === 164 /* PropertyAccessExpression */ ?
+ if (left.kind === 95 /* SuperKeyword */) {
+ var errorNode = node.kind === 166 /* PropertyAccessExpression */ ?
node.name :
node.right;
// TS 1.0 spec (April 2014): 4.8.2
@@ -19906,7 +20552,7 @@ var ts;
// - In a static member function or static member accessor
// where this references the constructor function object of a derived class,
// a super property access is permitted and must specify a public static member function of the base class.
- if (getDeclarationKindFromSymbol(prop) !== 141 /* MethodDeclaration */) {
+ if (getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) {
// `prop` refers to a *property* declared in the super class
// rather than a *method*, so it does not satisfy the above criteria.
error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
@@ -19939,7 +20585,7 @@ var ts;
}
// Property is known to be protected at this point
// All protected properties of a supertype are accessible in a super access
- if (left.kind === 93 /* SuperKeyword */) {
+ if (left.kind === 95 /* SuperKeyword */) {
return true;
}
// A protected property is accessible in the declaring class and classes derived from it
@@ -19952,6 +20598,10 @@ var ts;
return true;
}
// An instance property must be accessed through an instance of the enclosing class
+ if (type.flags & 33554432 /* ThisType */) {
+ // get the original type -- represented as the type constraint of the 'this' type
+ type = getConstraintOfTypeParameter(type);
+ }
// TODO: why is the first part of this check here?
if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) {
error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
@@ -19978,18 +20628,18 @@ var ts;
var prop = getPropertyOfType(apparentType, right.text);
if (!prop) {
if (right.text) {
- error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type));
+ error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type.flags & 33554432 /* ThisType */ ? apparentType : type));
}
return unknownType;
}
getNodeLinks(node).resolvedSymbol = prop;
if (prop.parent && prop.parent.flags & 32 /* Class */) {
- checkClassPropertyAccess(node, left, type, prop);
+ checkClassPropertyAccess(node, left, apparentType, prop);
}
return getTypeOfSymbol(prop);
}
function isValidPropertyAccess(node, propertyName) {
- var left = node.kind === 164 /* PropertyAccessExpression */
+ var left = node.kind === 166 /* PropertyAccessExpression */
? node.expression
: node.left;
var type = checkExpression(left);
@@ -20005,7 +20655,7 @@ var ts;
// Grammar checking
if (!node.argumentExpression) {
var sourceFile = getSourceFile(node);
- if (node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node) {
+ if (node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node) {
var start = ts.skipTrivia(sourceFile.text, node.expression.end);
var end = node.end;
grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead);
@@ -20077,6 +20727,7 @@ var ts;
}
/**
* If indexArgumentExpression is a string literal or number literal, returns its text.
+ * If indexArgumentExpression is a constant value, returns its string value.
* If indexArgumentExpression is a well known symbol, returns the property name corresponding
* to this symbol, as long as it is a proper symbol reference.
* Otherwise, returns undefined.
@@ -20085,6 +20736,12 @@ var ts;
if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) {
return indexArgumentExpression.text;
}
+ if (indexArgumentExpression.kind === 167 /* ElementAccessExpression */ || indexArgumentExpression.kind === 166 /* PropertyAccessExpression */) {
+ var value = getConstantValue(indexArgumentExpression);
+ if (value !== undefined) {
+ return value.toString();
+ }
+ }
if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) {
var rightHandSideName = indexArgumentExpression.name.text;
return ts.getPropertyNameForKnownSymbolName(rightHandSideName);
@@ -20134,10 +20791,10 @@ var ts;
return true;
}
function resolveUntypedCall(node) {
- if (node.kind === 168 /* TaggedTemplateExpression */) {
+ if (node.kind === 170 /* TaggedTemplateExpression */) {
checkExpression(node.template);
}
- else if (node.kind !== 137 /* Decorator */) {
+ else if (node.kind !== 139 /* Decorator */) {
ts.forEach(node.arguments, function (argument) {
checkExpression(argument);
});
@@ -20203,7 +20860,7 @@ var ts;
function getSpreadArgumentIndex(args) {
for (var i = 0; i < args.length; i++) {
var arg = args[i];
- if (arg && arg.kind === 183 /* SpreadElementExpression */) {
+ if (arg && arg.kind === 185 /* SpreadElementExpression */) {
return i;
}
}
@@ -20215,13 +20872,13 @@ var ts;
var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments
var isDecorator;
var spreadArgIndex = -1;
- if (node.kind === 168 /* TaggedTemplateExpression */) {
+ if (node.kind === 170 /* TaggedTemplateExpression */) {
var tagExpression = node;
// Even if the call is incomplete, we'll have a missing expression as our last argument,
// so we can say the count is just the arg list length
adjustedArgCount = args.length;
typeArguments = undefined;
- if (tagExpression.template.kind === 181 /* TemplateExpression */) {
+ if (tagExpression.template.kind === 183 /* TemplateExpression */) {
// If a tagged template expression lacks a tail literal, the call is incomplete.
// Specifically, a template only can end in a TemplateTail or a Missing literal.
var templateExpression = tagExpression.template;
@@ -20238,7 +20895,7 @@ var ts;
callIsIncomplete = !!templateLiteral.isUnterminated;
}
}
- else if (node.kind === 137 /* Decorator */) {
+ else if (node.kind === 139 /* Decorator */) {
isDecorator = true;
typeArguments = undefined;
adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature);
@@ -20247,7 +20904,7 @@ var ts;
var callExpression = node;
if (!callExpression.arguments) {
// This only happens when we have something of the form: 'new C'
- ts.Debug.assert(callExpression.kind === 167 /* NewExpression */);
+ ts.Debug.assert(callExpression.kind === 169 /* NewExpression */);
return signature.minArgumentCount === 0;
}
// For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument.
@@ -20267,7 +20924,7 @@ var ts;
// If spread arguments are present, check that they correspond to a rest parameter. If so, no
// further checking is necessary.
if (spreadArgIndex >= 0) {
- return signature.hasRestParameter && spreadArgIndex >= signature.parameters.length - 1;
+ return isRestParameterIndex(signature, spreadArgIndex);
}
// Too many arguments implies incorrect arity.
if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) {
@@ -20326,7 +20983,7 @@ var ts;
for (var i = 0; i < argCount; i++) {
var arg = getEffectiveArgument(node, args, i);
// If the effective argument is 'undefined', then it is an argument that is present but is synthetic.
- if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) {
+ if (arg === undefined || arg.kind !== 187 /* OmittedExpression */) {
var paramType = getTypeAtPosition(signature, i);
var argType = getEffectiveArgumentType(node, i, arg);
// If the effective argument type is 'undefined', there is no synthetic type
@@ -20385,7 +21042,7 @@ var ts;
for (var i = 0; i < argCount; i++) {
var arg = getEffectiveArgument(node, args, i);
// If the effective argument is 'undefined', then it is an argument that is present but is synthetic.
- if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) {
+ if (arg === undefined || arg.kind !== 187 /* OmittedExpression */) {
// Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter)
var paramType = getTypeAtPosition(signature, i);
var argType = getEffectiveArgumentType(node, i, arg);
@@ -20417,16 +21074,16 @@ var ts;
*/
function getEffectiveCallArguments(node) {
var args;
- if (node.kind === 168 /* TaggedTemplateExpression */) {
+ if (node.kind === 170 /* TaggedTemplateExpression */) {
var template = node.template;
args = [undefined];
- if (template.kind === 181 /* TemplateExpression */) {
+ if (template.kind === 183 /* TemplateExpression */) {
ts.forEach(template.templateSpans, function (span) {
args.push(span.expression);
});
}
}
- else if (node.kind === 137 /* Decorator */) {
+ else if (node.kind === 139 /* Decorator */) {
// For a decorator, we return undefined as we will determine
// the number and types of arguments for a decorator using
// `getEffectiveArgumentCount` and `getEffectiveArgumentType` below.
@@ -20451,25 +21108,29 @@ var ts;
* Otherwise, the argument count is the length of the 'args' array.
*/
function getEffectiveArgumentCount(node, args, signature) {
- if (node.kind === 137 /* Decorator */) {
+ if (node.kind === 139 /* Decorator */) {
switch (node.parent.kind) {
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
// A class decorator will have one argument (see `ClassDecorator` in core.d.ts)
return 1;
- case 139 /* PropertyDeclaration */:
+ case 141 /* PropertyDeclaration */:
// A property declaration decorator will have two arguments (see
// `PropertyDecorator` in core.d.ts)
return 2;
- case 141 /* MethodDeclaration */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
+ case 143 /* MethodDeclaration */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
// A method or accessor declaration decorator will have two or three arguments (see
// `PropertyDecorator` and `MethodDecorator` in core.d.ts)
+ // If we are emitting decorators for ES3, we will only pass two arguments.
+ if (languageVersion === 0 /* ES3 */) {
+ return 2;
+ }
// If the method decorator signature only accepts a target and a key, we will only
// type check those arguments.
return signature.parameters.length >= 3 ? 3 : 2;
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
// A parameter declaration decorator will have three arguments (see
// `ParameterDecorator` in core.d.ts)
return 3;
@@ -20493,35 +21154,33 @@ var ts;
*/
function getEffectiveDecoratorFirstArgumentType(node) {
// The first argument to a decorator is its `target`.
- switch (node.kind) {
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
- // For a class decorator, the `target` is the type of the class (e.g. the
- // "static" or "constructor" side of the class)
+ if (node.kind === 214 /* ClassDeclaration */) {
+ // For a class decorator, the `target` is the type of the class (e.g. the
+ // "static" or "constructor" side of the class)
+ var classSymbol = getSymbolOfNode(node);
+ return getTypeOfSymbol(classSymbol);
+ }
+ if (node.kind === 138 /* Parameter */) {
+ // For a parameter decorator, the `target` is the parent type of the
+ // parameter's containing method.
+ node = node.parent;
+ if (node.kind === 144 /* Constructor */) {
var classSymbol = getSymbolOfNode(node);
return getTypeOfSymbol(classSymbol);
- case 136 /* Parameter */:
- // For a parameter decorator, the `target` is the parent type of the
- // parameter's containing method.
- node = node.parent;
- if (node.kind === 142 /* Constructor */) {
- var classSymbol_1 = getSymbolOfNode(node);
- return getTypeOfSymbol(classSymbol_1);
- }
- // fall-through
- case 139 /* PropertyDeclaration */:
- case 141 /* MethodDeclaration */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- // For a property or method decorator, the `target` is the
- // "static"-side type of the parent of the member if the member is
- // declared "static"; otherwise, it is the "instance"-side type of the
- // parent of the member.
- return getParentTypeOfClassElement(node);
- default:
- ts.Debug.fail("Unsupported decorator target.");
- return unknownType;
+ }
}
+ if (node.kind === 141 /* PropertyDeclaration */ ||
+ node.kind === 143 /* MethodDeclaration */ ||
+ node.kind === 145 /* GetAccessor */ ||
+ node.kind === 146 /* SetAccessor */) {
+ // For a property or method decorator, the `target` is the
+ // "static"-side type of the parent of the member if the member is
+ // declared "static"; otherwise, it is the "instance"-side type of the
+ // parent of the member.
+ return getParentTypeOfClassElement(node);
+ }
+ ts.Debug.fail("Unsupported decorator target.");
+ return unknownType;
}
/**
* Returns the effective type for the second argument to a decorator.
@@ -20540,49 +21199,46 @@ var ts;
*/
function getEffectiveDecoratorSecondArgumentType(node) {
// The second argument to a decorator is its `propertyKey`
- switch (node.kind) {
- case 212 /* ClassDeclaration */:
- ts.Debug.fail("Class decorators should not have a second synthetic argument.");
- return unknownType;
- case 136 /* Parameter */:
- node = node.parent;
- if (node.kind === 142 /* Constructor */) {
- // For a constructor parameter decorator, the `propertyKey` will be `undefined`.
- return anyType;
- }
- // For a non-constructor parameter decorator, the `propertyKey` will be either
- // a string or a symbol, based on the name of the parameter's containing method.
- // fall-through
- case 139 /* PropertyDeclaration */:
- case 141 /* MethodDeclaration */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- // The `propertyKey` for a property or method decorator will be a
- // string literal type if the member name is an identifier, number, or string;
- // otherwise, if the member name is a computed property name it will
- // be either string or symbol.
- var element = node;
- switch (element.name.kind) {
- case 67 /* Identifier */:
- case 8 /* NumericLiteral */:
- case 9 /* StringLiteral */:
- return getStringLiteralType(element.name);
- case 134 /* ComputedPropertyName */:
- var nameType = checkComputedPropertyName(element.name);
- if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) {
- return nameType;
- }
- else {
- return stringType;
- }
- default:
- ts.Debug.fail("Unsupported property name.");
- return unknownType;
- }
- default:
- ts.Debug.fail("Unsupported decorator target.");
- return unknownType;
+ if (node.kind === 214 /* ClassDeclaration */) {
+ ts.Debug.fail("Class decorators should not have a second synthetic argument.");
+ return unknownType;
+ }
+ if (node.kind === 138 /* Parameter */) {
+ node = node.parent;
+ if (node.kind === 144 /* Constructor */) {
+ // For a constructor parameter decorator, the `propertyKey` will be `undefined`.
+ return anyType;
+ }
+ }
+ if (node.kind === 141 /* PropertyDeclaration */ ||
+ node.kind === 143 /* MethodDeclaration */ ||
+ node.kind === 145 /* GetAccessor */ ||
+ node.kind === 146 /* SetAccessor */) {
+ // The `propertyKey` for a property or method decorator will be a
+ // string literal type if the member name is an identifier, number, or string;
+ // otherwise, if the member name is a computed property name it will
+ // be either string or symbol.
+ var element = node;
+ switch (element.name.kind) {
+ case 69 /* Identifier */:
+ case 8 /* NumericLiteral */:
+ case 9 /* StringLiteral */:
+ return getStringLiteralType(element.name);
+ case 136 /* ComputedPropertyName */:
+ var nameType = checkComputedPropertyName(element.name);
+ if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) {
+ return nameType;
+ }
+ else {
+ return stringType;
+ }
+ default:
+ ts.Debug.fail("Unsupported property name.");
+ return unknownType;
+ }
}
+ ts.Debug.fail("Unsupported decorator target.");
+ return unknownType;
}
/**
* Returns the effective argument type for the third argument to a decorator.
@@ -20594,27 +21250,28 @@ var ts;
function getEffectiveDecoratorThirdArgumentType(node) {
// The third argument to a decorator is either its `descriptor` for a method decorator
// or its `parameterIndex` for a paramter decorator
- switch (node.kind) {
- case 212 /* ClassDeclaration */:
- ts.Debug.fail("Class decorators should not have a third synthetic argument.");
- return unknownType;
- case 136 /* Parameter */:
- // The `parameterIndex` for a parameter decorator is always a number
- return numberType;
- case 139 /* PropertyDeclaration */:
- ts.Debug.fail("Property decorators should not have a third synthetic argument.");
- return unknownType;
- case 141 /* MethodDeclaration */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor`
- // for the type of the member.
- var propertyType = getTypeOfNode(node);
- return createTypedPropertyDescriptorType(propertyType);
- default:
- ts.Debug.fail("Unsupported decorator target.");
- return unknownType;
+ if (node.kind === 214 /* ClassDeclaration */) {
+ ts.Debug.fail("Class decorators should not have a third synthetic argument.");
+ return unknownType;
+ }
+ if (node.kind === 138 /* Parameter */) {
+ // The `parameterIndex` for a parameter decorator is always a number
+ return numberType;
+ }
+ if (node.kind === 141 /* PropertyDeclaration */) {
+ ts.Debug.fail("Property decorators should not have a third synthetic argument.");
+ return unknownType;
+ }
+ if (node.kind === 143 /* MethodDeclaration */ ||
+ node.kind === 145 /* GetAccessor */ ||
+ node.kind === 146 /* SetAccessor */) {
+ // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor`
+ // for the type of the member.
+ var propertyType = getTypeOfNode(node);
+ return createTypedPropertyDescriptorType(propertyType);
}
+ ts.Debug.fail("Unsupported decorator target.");
+ return unknownType;
}
/**
* Returns the effective argument type for the provided argument to a decorator.
@@ -20639,10 +21296,10 @@ var ts;
// Decorators provide special arguments, a tagged template expression provides
// a special first argument, and string literals get string literal types
// unless we're reporting errors
- if (node.kind === 137 /* Decorator */) {
+ if (node.kind === 139 /* Decorator */) {
return getEffectiveDecoratorArgumentType(node, argIndex);
}
- else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) {
+ else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) {
return globalTemplateStringsArrayType;
}
// This is not a synthetic argument, so we return 'undefined'
@@ -20654,8 +21311,8 @@ var ts;
*/
function getEffectiveArgument(node, args, argIndex) {
// For a decorator or the first argument of a tagged template expression we return undefined.
- if (node.kind === 137 /* Decorator */ ||
- (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */)) {
+ if (node.kind === 139 /* Decorator */ ||
+ (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */)) {
return undefined;
}
return args[argIndex];
@@ -20664,11 +21321,11 @@ var ts;
* Gets the error node to use when reporting errors for an effective argument.
*/
function getEffectiveArgumentErrorNode(node, argIndex, arg) {
- if (node.kind === 137 /* Decorator */) {
+ if (node.kind === 139 /* Decorator */) {
// For a decorator, we use the expression of the decorator for error reporting.
return node.expression;
}
- else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) {
+ else if (argIndex === 0 && node.kind === 170 /* TaggedTemplateExpression */) {
// For a the first argument of a tagged template expression, we use the template of the tag for error reporting.
return node.template;
}
@@ -20677,13 +21334,13 @@ var ts;
}
}
function resolveCall(node, signatures, candidatesOutArray, headMessage) {
- var isTaggedTemplate = node.kind === 168 /* TaggedTemplateExpression */;
- var isDecorator = node.kind === 137 /* Decorator */;
+ var isTaggedTemplate = node.kind === 170 /* TaggedTemplateExpression */;
+ var isDecorator = node.kind === 139 /* Decorator */;
var typeArguments;
if (!isTaggedTemplate && !isDecorator) {
typeArguments = node.typeArguments;
// We already perform checking on the type arguments on the class declaration itself.
- if (node.expression.kind !== 93 /* SuperKeyword */) {
+ if (node.expression.kind !== 95 /* SuperKeyword */) {
ts.forEach(typeArguments, checkSourceElement);
}
}
@@ -20890,7 +21547,7 @@ var ts;
}
}
function resolveCallExpression(node, candidatesOutArray) {
- if (node.expression.kind === 93 /* SuperKeyword */) {
+ if (node.expression.kind === 95 /* SuperKeyword */) {
var superType = checkSuperExpression(node.expression);
if (superType !== unknownType) {
// In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated
@@ -20964,7 +21621,7 @@ var ts;
// Note, only class declarations can be declared abstract.
// In the case of a merged class-module or class-interface declaration,
// only the class declaration node will have the Abstract flag set.
- var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212 /* ClassDeclaration */);
+ var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
if (valueDecl && valueDecl.flags & 256 /* Abstract */) {
error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name));
return resolveErrorCall(node);
@@ -21023,16 +21680,16 @@ var ts;
*/
function getDiagnosticHeadMessageForDecoratorResolution(node) {
switch (node.parent.kind) {
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression;
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression;
- case 139 /* PropertyDeclaration */:
+ case 141 /* PropertyDeclaration */:
return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression;
- case 141 /* MethodDeclaration */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
+ case 143 /* MethodDeclaration */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression;
}
}
@@ -21069,16 +21726,16 @@ var ts;
// to correctly fill the candidatesOutArray.
if (!links.resolvedSignature || candidatesOutArray) {
links.resolvedSignature = anySignature;
- if (node.kind === 166 /* CallExpression */) {
+ if (node.kind === 168 /* CallExpression */) {
links.resolvedSignature = resolveCallExpression(node, candidatesOutArray);
}
- else if (node.kind === 167 /* NewExpression */) {
+ else if (node.kind === 169 /* NewExpression */) {
links.resolvedSignature = resolveNewExpression(node, candidatesOutArray);
}
- else if (node.kind === 168 /* TaggedTemplateExpression */) {
+ else if (node.kind === 170 /* TaggedTemplateExpression */) {
links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray);
}
- else if (node.kind === 137 /* Decorator */) {
+ else if (node.kind === 139 /* Decorator */) {
links.resolvedSignature = resolveDecorator(node, candidatesOutArray);
}
else {
@@ -21096,15 +21753,15 @@ var ts;
// Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true
checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments);
var signature = getResolvedSignature(node);
- if (node.expression.kind === 93 /* SuperKeyword */) {
+ if (node.expression.kind === 95 /* SuperKeyword */) {
return voidType;
}
- if (node.kind === 167 /* NewExpression */) {
+ if (node.kind === 169 /* NewExpression */) {
var declaration = signature.declaration;
if (declaration &&
- declaration.kind !== 142 /* Constructor */ &&
- declaration.kind !== 146 /* ConstructSignature */ &&
- declaration.kind !== 151 /* ConstructorType */) {
+ declaration.kind !== 144 /* Constructor */ &&
+ declaration.kind !== 148 /* ConstructSignature */ &&
+ declaration.kind !== 153 /* ConstructorType */) {
// When resolved signature is a call signature (and not a construct signature) the result type is any
if (compilerOptions.noImplicitAny) {
error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
@@ -21140,16 +21797,32 @@ var ts;
var contextualParameterType = getTypeAtPosition(context, i);
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
}
- if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) {
+ if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) {
var parameter = ts.lastOrUndefined(signature.parameters);
var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters));
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
}
}
+ // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
+ // the destructured type into the contained binding elements.
+ function assignBindingElementTypes(node) {
+ if (ts.isBindingPattern(node.name)) {
+ for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) {
+ var element = _a[_i];
+ if (element.kind !== 187 /* OmittedExpression */) {
+ if (element.name.kind === 69 /* Identifier */) {
+ getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
+ }
+ assignBindingElementTypes(element);
+ }
+ }
+ }
+ }
function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) {
var links = getSymbolLinks(parameter);
if (!links.type) {
links.type = instantiateType(contextualType, mapper);
+ assignBindingElementTypes(parameter.valueDeclaration);
}
else if (isInferentialContext(mapper)) {
// Even if the parameter already has a type, it might be because it was given a type while
@@ -21201,7 +21874,7 @@ var ts;
}
var isAsync = ts.isAsyncFunctionLike(func);
var type;
- if (func.body.kind !== 190 /* Block */) {
+ if (func.body.kind !== 192 /* Block */) {
type = checkExpressionCached(func.body, contextualMapper);
if (isAsync) {
// From within an async function you can return either a non-promise value or a promise. Any
@@ -21320,7 +21993,7 @@ var ts;
});
}
function bodyContainsSingleThrowStatement(body) {
- return (body.statements.length === 1) && (body.statements[0].kind === 206 /* ThrowStatement */);
+ return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */);
}
// TypeScript Specification 1.0 (6.3) - July 2014
// An explicitly typed function whose return type isn't the Void or the Any type
@@ -21335,7 +22008,7 @@ var ts;
return;
}
// If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check.
- if (ts.nodeIsMissing(func.body) || func.body.kind !== 190 /* Block */) {
+ if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) {
return;
}
var bodyBlock = func.body;
@@ -21353,10 +22026,10 @@ var ts;
error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement);
}
function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) {
- ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
+ ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
// Grammar checking
var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
- if (!hasGrammarError && node.kind === 171 /* FunctionExpression */) {
+ if (!hasGrammarError && node.kind === 173 /* FunctionExpression */) {
checkGrammarForGenerator(node);
}
// The identityMapper object is used to indicate that function expressions are wildcards
@@ -21399,14 +22072,14 @@ var ts;
}
}
}
- if (produceDiagnostics && node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) {
+ if (produceDiagnostics && node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) {
checkCollisionWithCapturedSuperVariable(node, node.name);
checkCollisionWithCapturedThisVariable(node, node.name);
}
return type;
}
function checkFunctionExpressionOrObjectLiteralMethodBody(node) {
- ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
+ ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
var isAsync = ts.isAsyncFunctionLike(node);
if (isAsync) {
emitAwaiter = true;
@@ -21428,7 +22101,7 @@ var ts;
// checkFunctionExpressionBodies). So it must be done now.
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
}
- if (node.body.kind === 190 /* Block */) {
+ if (node.body.kind === 192 /* Block */) {
checkSourceElement(node.body);
}
else {
@@ -21474,24 +22147,24 @@ var ts;
// and property accesses(section 4.10).
// All other expression constructs described in this chapter are classified as values.
switch (n.kind) {
- case 67 /* Identifier */: {
+ case 69 /* Identifier */: {
var symbol = findSymbol(n);
// TypeScript 1.0 spec (April 2014): 4.3
// An identifier expression that references a variable or parameter is classified as a reference.
// An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment).
return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0;
}
- case 164 /* PropertyAccessExpression */: {
+ case 166 /* PropertyAccessExpression */: {
var symbol = findSymbol(n);
// TypeScript 1.0 spec (April 2014): 4.10
// A property access expression is always classified as a reference.
// NOTE (not in spec): assignment to enum members should not be allowed
return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0;
}
- case 165 /* ElementAccessExpression */:
- // old compiler doesn't check indexed assess
+ case 167 /* ElementAccessExpression */:
+ // old compiler doesn't check indexed access
return true;
- case 170 /* ParenthesizedExpression */:
+ case 172 /* ParenthesizedExpression */:
return isReferenceOrErrorExpression(n.expression);
default:
return false;
@@ -21499,12 +22172,12 @@ var ts;
}
function isConstVariableReference(n) {
switch (n.kind) {
- case 67 /* Identifier */:
- case 164 /* PropertyAccessExpression */: {
+ case 69 /* Identifier */:
+ case 166 /* PropertyAccessExpression */: {
var symbol = findSymbol(n);
return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0;
}
- case 165 /* ElementAccessExpression */: {
+ case 167 /* ElementAccessExpression */: {
var index = n.argumentExpression;
var symbol = findSymbol(n.expression);
if (symbol && index && index.kind === 9 /* StringLiteral */) {
@@ -21514,7 +22187,7 @@ var ts;
}
return false;
}
- case 170 /* ParenthesizedExpression */:
+ case 172 /* ParenthesizedExpression */:
return isConstVariableReference(n.expression);
default:
return false;
@@ -21560,15 +22233,15 @@ var ts;
switch (node.operator) {
case 35 /* PlusToken */:
case 36 /* MinusToken */:
- case 49 /* TildeToken */:
+ case 50 /* TildeToken */:
if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) {
error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
}
return numberType;
- case 48 /* ExclamationToken */:
+ case 49 /* ExclamationToken */:
return booleanType;
- case 40 /* PlusPlusToken */:
- case 41 /* MinusMinusToken */:
+ case 41 /* PlusPlusToken */:
+ case 42 /* MinusMinusToken */:
var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type);
if (ok) {
// run check only if former checks succeeded to avoid reporting cascading errors
@@ -21628,31 +22301,31 @@ var ts;
function isConstEnumSymbol(symbol) {
return (symbol.flags & 128 /* ConstEnum */) !== 0;
}
- function checkInstanceOfExpression(node, leftType, rightType) {
+ function checkInstanceOfExpression(left, right, leftType, rightType) {
// TypeScript 1.0 spec (April 2014): 4.15.4
// The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type,
// and the right operand to be of type Any or a subtype of the 'Function' interface type.
// The result is always of the Boolean primitive type.
// NOTE: do not raise error if leftType is unknown as related error was already reported
if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) {
- error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
+ error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
// NOTE: do not raise error if right is unknown as related error was already reported
if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
- error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type);
+ error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type);
}
return booleanType;
}
- function checkInExpression(node, leftType, rightType) {
+ function checkInExpression(left, right, leftType, rightType) {
// TypeScript 1.0 spec (April 2014): 4.15.5
// The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type,
// and the right operand to be of type Any, an object type, or a type parameter type.
// The result is always of the Boolean primitive type.
if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) {
- error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
+ error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
}
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) {
- error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
+ error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
return booleanType;
}
@@ -21660,7 +22333,7 @@ var ts;
var properties = node.properties;
for (var _i = 0; _i < properties.length; _i++) {
var p = properties[_i];
- if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) {
+ if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) {
// TODO(andersh): Computed property support
var name_13 = p.name;
var type = isTypeAny(sourceType)
@@ -21669,7 +22342,12 @@ var ts;
isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1 /* Number */) ||
getIndexTypeOfType(sourceType, 0 /* String */);
if (type) {
- checkDestructuringAssignment(p.initializer || name_13, type);
+ if (p.kind === 246 /* ShorthandPropertyAssignment */) {
+ checkDestructuringAssignment(p, type);
+ }
+ else {
+ checkDestructuringAssignment(p.initializer || name_13, type);
+ }
}
else {
error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13));
@@ -21689,8 +22367,8 @@ var ts;
var elements = node.elements;
for (var i = 0; i < elements.length; i++) {
var e = elements[i];
- if (e.kind !== 185 /* OmittedExpression */) {
- if (e.kind !== 183 /* SpreadElementExpression */) {
+ if (e.kind !== 187 /* OmittedExpression */) {
+ if (e.kind !== 185 /* SpreadElementExpression */) {
var propName = "" + i;
var type = isTypeAny(sourceType)
? sourceType
@@ -21715,7 +22393,7 @@ var ts;
}
else {
var restExpression = e.expression;
- if (restExpression.kind === 179 /* BinaryExpression */ && restExpression.operatorToken.kind === 55 /* EqualsToken */) {
+ if (restExpression.kind === 181 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) {
error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
}
else {
@@ -21727,15 +22405,26 @@ var ts;
}
return sourceType;
}
- function checkDestructuringAssignment(target, sourceType, contextualMapper) {
- if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) {
+ function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) {
+ var target;
+ if (exprOrAssignment.kind === 246 /* ShorthandPropertyAssignment */) {
+ var prop = exprOrAssignment;
+ if (prop.objectAssignmentInitializer) {
+ checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper);
+ }
+ target = exprOrAssignment.name;
+ }
+ else {
+ target = exprOrAssignment;
+ }
+ if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) {
checkBinaryExpression(target, contextualMapper);
target = target.left;
}
- if (target.kind === 163 /* ObjectLiteralExpression */) {
+ if (target.kind === 165 /* ObjectLiteralExpression */) {
return checkObjectLiteralAssignment(target, sourceType, contextualMapper);
}
- if (target.kind === 162 /* ArrayLiteralExpression */) {
+ if (target.kind === 164 /* ArrayLiteralExpression */) {
return checkArrayLiteralAssignment(target, sourceType, contextualMapper);
}
return checkReferenceAssignment(target, sourceType, contextualMapper);
@@ -21748,34 +22437,39 @@ var ts;
return sourceType;
}
function checkBinaryExpression(node, contextualMapper) {
- var operator = node.operatorToken.kind;
- if (operator === 55 /* EqualsToken */ && (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) {
- return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper);
+ return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node);
+ }
+ function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) {
+ var operator = operatorToken.kind;
+ if (operator === 56 /* EqualsToken */ && (left.kind === 165 /* ObjectLiteralExpression */ || left.kind === 164 /* ArrayLiteralExpression */)) {
+ return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper);
}
- var leftType = checkExpression(node.left, contextualMapper);
- var rightType = checkExpression(node.right, contextualMapper);
+ var leftType = checkExpression(left, contextualMapper);
+ var rightType = checkExpression(right, contextualMapper);
switch (operator) {
case 37 /* AsteriskToken */:
- case 58 /* AsteriskEqualsToken */:
- case 38 /* SlashToken */:
- case 59 /* SlashEqualsToken */:
- case 39 /* PercentToken */:
- case 60 /* PercentEqualsToken */:
+ case 38 /* AsteriskAsteriskToken */:
+ case 59 /* AsteriskEqualsToken */:
+ case 60 /* AsteriskAsteriskEqualsToken */:
+ case 39 /* SlashToken */:
+ case 61 /* SlashEqualsToken */:
+ case 40 /* PercentToken */:
+ case 62 /* PercentEqualsToken */:
case 36 /* MinusToken */:
- case 57 /* MinusEqualsToken */:
- case 42 /* LessThanLessThanToken */:
- case 61 /* LessThanLessThanEqualsToken */:
- case 43 /* GreaterThanGreaterThanToken */:
- case 62 /* GreaterThanGreaterThanEqualsToken */:
- case 44 /* GreaterThanGreaterThanGreaterThanToken */:
- case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
- case 46 /* BarToken */:
- case 65 /* BarEqualsToken */:
- case 47 /* CaretToken */:
- case 66 /* CaretEqualsToken */:
- case 45 /* AmpersandToken */:
- case 64 /* AmpersandEqualsToken */:
- // TypeScript 1.0 spec (April 2014): 4.15.1
+ case 58 /* MinusEqualsToken */:
+ case 43 /* LessThanLessThanToken */:
+ case 63 /* LessThanLessThanEqualsToken */:
+ case 44 /* GreaterThanGreaterThanToken */:
+ case 64 /* GreaterThanGreaterThanEqualsToken */:
+ case 45 /* GreaterThanGreaterThanGreaterThanToken */:
+ case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 47 /* BarToken */:
+ case 67 /* BarEqualsToken */:
+ case 48 /* CaretToken */:
+ case 68 /* CaretEqualsToken */:
+ case 46 /* AmpersandToken */:
+ case 66 /* AmpersandEqualsToken */:
+ // TypeScript 1.0 spec (April 2014): 4.19.1
// These operators require their operands to be of type Any, the Number primitive type,
// or an enum type. Operands of an enum type are treated
// as having the primitive type Number. If one operand is the null or undefined value,
@@ -21790,21 +22484,21 @@ var ts;
// try and return them a helpful suggestion
if ((leftType.flags & 8 /* Boolean */) &&
(rightType.flags & 8 /* Boolean */) &&
- (suggestedOperator = getSuggestedBooleanOperator(node.operatorToken.kind)) !== undefined) {
- error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operatorToken.kind), ts.tokenToString(suggestedOperator));
+ (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) {
+ error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator));
}
else {
// otherwise just check each operand separately and report errors as normal
- var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
- var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
+ var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
+ var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
if (leftOk && rightOk) {
checkAssignmentOperator(numberType);
}
}
return numberType;
case 35 /* PlusToken */:
- case 56 /* PlusEqualsToken */:
- // TypeScript 1.0 spec (April 2014): 4.15.2
+ case 57 /* PlusEqualsToken */:
+ // TypeScript 1.0 spec (April 2014): 4.19.2
// The binary + operator requires both operands to be of the Number primitive type or an enum type,
// or at least one of the operands to be of type Any or the String primitive type.
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
@@ -21837,7 +22531,7 @@ var ts;
reportOperatorError();
return anyType;
}
- if (operator === 56 /* PlusEqualsToken */) {
+ if (operator === 57 /* PlusEqualsToken */) {
checkAssignmentOperator(resultType);
}
return resultType;
@@ -21857,15 +22551,15 @@ var ts;
reportOperatorError();
}
return booleanType;
- case 89 /* InstanceOfKeyword */:
- return checkInstanceOfExpression(node, leftType, rightType);
- case 88 /* InKeyword */:
- return checkInExpression(node, leftType, rightType);
- case 50 /* AmpersandAmpersandToken */:
+ case 91 /* InstanceOfKeyword */:
+ return checkInstanceOfExpression(left, right, leftType, rightType);
+ case 90 /* InKeyword */:
+ return checkInExpression(left, right, leftType, rightType);
+ case 51 /* AmpersandAmpersandToken */:
return rightType;
- case 51 /* BarBarToken */:
+ case 52 /* BarBarToken */:
return getUnionType([leftType, rightType]);
- case 55 /* EqualsToken */:
+ case 56 /* EqualsToken */:
checkAssignmentOperator(rightType);
return getRegularTypeOfObjectLiteral(rightType);
case 24 /* CommaToken */:
@@ -21873,8 +22567,8 @@ var ts;
}
// Return true if there was no error, false if there was an error.
function checkForDisallowedESSymbolOperand(operator) {
- var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? node.left :
- someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? node.right :
+ var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? left :
+ someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? right :
undefined;
if (offendingSymbolOperand) {
error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator));
@@ -21884,37 +22578,37 @@ var ts;
}
function getSuggestedBooleanOperator(operator) {
switch (operator) {
- case 46 /* BarToken */:
- case 65 /* BarEqualsToken */:
- return 51 /* BarBarToken */;
- case 47 /* CaretToken */:
- case 66 /* CaretEqualsToken */:
+ case 47 /* BarToken */:
+ case 67 /* BarEqualsToken */:
+ return 52 /* BarBarToken */;
+ case 48 /* CaretToken */:
+ case 68 /* CaretEqualsToken */:
return 33 /* ExclamationEqualsEqualsToken */;
- case 45 /* AmpersandToken */:
- case 64 /* AmpersandEqualsToken */:
- return 50 /* AmpersandAmpersandToken */;
+ case 46 /* AmpersandToken */:
+ case 66 /* AmpersandEqualsToken */:
+ return 51 /* AmpersandAmpersandToken */;
default:
return undefined;
}
}
function checkAssignmentOperator(valueType) {
- if (produceDiagnostics && operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) {
+ if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) {
// TypeScript 1.0 spec (April 2014): 4.17
// An assignment of the form
// VarExpr = ValueExpr
// requires VarExpr to be classified as a reference
// A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1)
// and the type of the non - compound operation to be assignable to the type of VarExpr.
- var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant);
+ var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant);
// Use default messages
if (ok) {
// to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported
- checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined);
+ checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined);
}
}
}
function reportOperatorError() {
- error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operatorToken.kind), typeToString(leftType), typeToString(rightType));
+ error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType));
}
}
function isYieldExpressionInClass(node) {
@@ -22005,7 +22699,7 @@ var ts;
// Do not use hasDynamicName here, because that returns false for well known symbols.
// We want to perform checkComputedPropertyName for all computed properties, including
// well known symbols.
- if (node.name.kind === 134 /* ComputedPropertyName */) {
+ if (node.name.kind === 136 /* ComputedPropertyName */) {
checkComputedPropertyName(node.name);
}
return checkExpression(node.initializer, contextualMapper);
@@ -22016,7 +22710,7 @@ var ts;
// Do not use hasDynamicName here, because that returns false for well known symbols.
// We want to perform checkComputedPropertyName for all computed properties, including
// well known symbols.
- if (node.name.kind === 134 /* ComputedPropertyName */) {
+ if (node.name.kind === 136 /* ComputedPropertyName */) {
checkComputedPropertyName(node.name);
}
var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper);
@@ -22046,7 +22740,7 @@ var ts;
// contextually typed function and arrow expressions in the initial phase.
function checkExpression(node, contextualMapper) {
var type;
- if (node.kind === 133 /* QualifiedName */) {
+ if (node.kind === 135 /* QualifiedName */) {
type = checkQualifiedName(node);
}
else {
@@ -22058,9 +22752,9 @@ var ts;
// - 'left' in property access
// - 'object' in indexed access
// - target in rhs of import statement
- var ok = (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.expression === node) ||
- (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.expression === node) ||
- ((node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node));
+ var ok = (node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.expression === node) ||
+ (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.expression === node) ||
+ ((node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node));
if (!ok) {
error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment);
}
@@ -22074,78 +22768,78 @@ var ts;
}
function checkExpressionWorker(node, contextualMapper) {
switch (node.kind) {
- case 67 /* Identifier */:
+ case 69 /* Identifier */:
return checkIdentifier(node);
- case 95 /* ThisKeyword */:
+ case 97 /* ThisKeyword */:
return checkThisExpression(node);
- case 93 /* SuperKeyword */:
+ case 95 /* SuperKeyword */:
return checkSuperExpression(node);
- case 91 /* NullKeyword */:
+ case 93 /* NullKeyword */:
return nullType;
- case 97 /* TrueKeyword */:
- case 82 /* FalseKeyword */:
+ case 99 /* TrueKeyword */:
+ case 84 /* FalseKeyword */:
return booleanType;
case 8 /* NumericLiteral */:
return checkNumericLiteral(node);
- case 181 /* TemplateExpression */:
+ case 183 /* TemplateExpression */:
return checkTemplateExpression(node);
case 9 /* StringLiteral */:
case 11 /* NoSubstitutionTemplateLiteral */:
return stringType;
case 10 /* RegularExpressionLiteral */:
return globalRegExpType;
- case 162 /* ArrayLiteralExpression */:
+ case 164 /* ArrayLiteralExpression */:
return checkArrayLiteral(node, contextualMapper);
- case 163 /* ObjectLiteralExpression */:
+ case 165 /* ObjectLiteralExpression */:
return checkObjectLiteral(node, contextualMapper);
- case 164 /* PropertyAccessExpression */:
+ case 166 /* PropertyAccessExpression */:
return checkPropertyAccessExpression(node);
- case 165 /* ElementAccessExpression */:
+ case 167 /* ElementAccessExpression */:
return checkIndexedAccess(node);
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
return checkCallExpression(node);
- case 168 /* TaggedTemplateExpression */:
+ case 170 /* TaggedTemplateExpression */:
return checkTaggedTemplateExpression(node);
- case 170 /* ParenthesizedExpression */:
+ case 172 /* ParenthesizedExpression */:
return checkExpression(node.expression, contextualMapper);
- case 184 /* ClassExpression */:
+ case 186 /* ClassExpression */:
return checkClassExpression(node);
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper);
- case 174 /* TypeOfExpression */:
+ case 176 /* TypeOfExpression */:
return checkTypeOfExpression(node);
- case 169 /* TypeAssertionExpression */:
- case 187 /* AsExpression */:
+ case 171 /* TypeAssertionExpression */:
+ case 189 /* AsExpression */:
return checkAssertion(node);
- case 173 /* DeleteExpression */:
+ case 175 /* DeleteExpression */:
return checkDeleteExpression(node);
- case 175 /* VoidExpression */:
+ case 177 /* VoidExpression */:
return checkVoidExpression(node);
- case 176 /* AwaitExpression */:
+ case 178 /* AwaitExpression */:
return checkAwaitExpression(node);
- case 177 /* PrefixUnaryExpression */:
+ case 179 /* PrefixUnaryExpression */:
return checkPrefixUnaryExpression(node);
- case 178 /* PostfixUnaryExpression */:
+ case 180 /* PostfixUnaryExpression */:
return checkPostfixUnaryExpression(node);
- case 179 /* BinaryExpression */:
+ case 181 /* BinaryExpression */:
return checkBinaryExpression(node, contextualMapper);
- case 180 /* ConditionalExpression */:
+ case 182 /* ConditionalExpression */:
return checkConditionalExpression(node, contextualMapper);
- case 183 /* SpreadElementExpression */:
+ case 185 /* SpreadElementExpression */:
return checkSpreadElementExpression(node, contextualMapper);
- case 185 /* OmittedExpression */:
+ case 187 /* OmittedExpression */:
return undefinedType;
- case 182 /* YieldExpression */:
+ case 184 /* YieldExpression */:
return checkYieldExpression(node);
- case 238 /* JsxExpression */:
+ case 240 /* JsxExpression */:
return checkJsxExpression(node);
- case 231 /* JsxElement */:
+ case 233 /* JsxElement */:
return checkJsxElement(node);
- case 232 /* JsxSelfClosingElement */:
+ case 234 /* JsxSelfClosingElement */:
return checkJsxSelfClosingElement(node);
- case 233 /* JsxOpeningElement */:
+ case 235 /* JsxOpeningElement */:
ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement");
}
return unknownType;
@@ -22174,7 +22868,7 @@ var ts;
var func = ts.getContainingFunction(node);
if (node.flags & 112 /* AccessibilityModifier */) {
func = ts.getContainingFunction(node);
- if (!(func.kind === 142 /* Constructor */ && ts.nodeIsPresent(func.body))) {
+ if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) {
error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
}
}
@@ -22191,15 +22885,15 @@ var ts;
if (!node.asteriskToken || !node.body) {
return false;
}
- return node.kind === 141 /* MethodDeclaration */ ||
- node.kind === 211 /* FunctionDeclaration */ ||
- node.kind === 171 /* FunctionExpression */;
+ return node.kind === 143 /* MethodDeclaration */ ||
+ node.kind === 213 /* FunctionDeclaration */ ||
+ node.kind === 173 /* FunctionExpression */;
}
function getTypePredicateParameterIndex(parameterList, parameter) {
if (parameterList) {
for (var i = 0; i < parameterList.length; i++) {
var param = parameterList[i];
- if (param.name.kind === 67 /* Identifier */ &&
+ if (param.name.kind === 69 /* Identifier */ &&
param.name.text === parameter.text) {
return i;
}
@@ -22209,31 +22903,31 @@ var ts;
}
function isInLegalTypePredicatePosition(node) {
switch (node.parent.kind) {
- case 172 /* ArrowFunction */:
- case 145 /* CallSignature */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 150 /* FunctionType */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 174 /* ArrowFunction */:
+ case 147 /* CallSignature */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 152 /* FunctionType */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
return node === node.parent.type;
}
return false;
}
function checkSignatureDeclaration(node) {
// Grammar checking
- if (node.kind === 147 /* IndexSignature */) {
+ if (node.kind === 149 /* IndexSignature */) {
checkGrammarIndexSignature(node);
}
- else if (node.kind === 150 /* FunctionType */ || node.kind === 211 /* FunctionDeclaration */ || node.kind === 151 /* ConstructorType */ ||
- node.kind === 145 /* CallSignature */ || node.kind === 142 /* Constructor */ ||
- node.kind === 146 /* ConstructSignature */) {
+ else if (node.kind === 152 /* FunctionType */ || node.kind === 213 /* FunctionDeclaration */ || node.kind === 153 /* ConstructorType */ ||
+ node.kind === 147 /* CallSignature */ || node.kind === 144 /* Constructor */ ||
+ node.kind === 148 /* ConstructSignature */) {
checkGrammarFunctionLikeDeclaration(node);
}
checkTypeParameters(node.typeParameters);
ts.forEach(node.parameters, checkParameter);
if (node.type) {
- if (node.type.kind === 148 /* TypePredicate */) {
+ if (node.type.kind === 150 /* TypePredicate */) {
var typePredicate = getSignatureFromDeclaration(node).typePredicate;
var typePredicateNode = node.type;
if (isInLegalTypePredicatePosition(typePredicateNode)) {
@@ -22252,19 +22946,19 @@ var ts;
if (hasReportedError) {
break;
}
- if (param.name.kind === 159 /* ObjectBindingPattern */ ||
- param.name.kind === 160 /* ArrayBindingPattern */) {
+ if (param.name.kind === 161 /* ObjectBindingPattern */ ||
+ param.name.kind === 162 /* ArrayBindingPattern */) {
(function checkBindingPattern(pattern) {
for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
var element = _a[_i];
- if (element.name.kind === 67 /* Identifier */ &&
+ if (element.name.kind === 69 /* Identifier */ &&
element.name.text === typePredicate.parameterName) {
error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName);
hasReportedError = true;
break;
}
- else if (element.name.kind === 160 /* ArrayBindingPattern */ ||
- element.name.kind === 159 /* ObjectBindingPattern */) {
+ else if (element.name.kind === 162 /* ArrayBindingPattern */ ||
+ element.name.kind === 161 /* ObjectBindingPattern */) {
checkBindingPattern(element.name);
}
}
@@ -22288,10 +22982,10 @@ var ts;
checkCollisionWithArgumentsInGeneratedCode(node);
if (compilerOptions.noImplicitAny && !node.type) {
switch (node.kind) {
- case 146 /* ConstructSignature */:
+ case 148 /* ConstructSignature */:
error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
break;
- case 145 /* CallSignature */:
+ case 147 /* CallSignature */:
error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
break;
}
@@ -22319,7 +23013,7 @@ var ts;
checkSpecializedSignatureDeclaration(node);
}
function checkTypeForDuplicateIndexSignatures(node) {
- if (node.kind === 213 /* InterfaceDeclaration */) {
+ if (node.kind === 215 /* InterfaceDeclaration */) {
var nodeSymbol = getSymbolOfNode(node);
// in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration
// to prevent this run check only for the first declaration of a given kind
@@ -22339,7 +23033,7 @@ var ts;
var declaration = decl;
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
switch (declaration.parameters[0].type.kind) {
- case 128 /* StringKeyword */:
+ case 130 /* StringKeyword */:
if (!seenStringIndexer) {
seenStringIndexer = true;
}
@@ -22347,7 +23041,7 @@ var ts;
error(declaration, ts.Diagnostics.Duplicate_string_index_signature);
}
break;
- case 126 /* NumberKeyword */:
+ case 128 /* NumberKeyword */:
if (!seenNumericIndexer) {
seenNumericIndexer = true;
}
@@ -22396,7 +23090,7 @@ var ts;
return;
}
function isSuperCallExpression(n) {
- return n.kind === 166 /* CallExpression */ && n.expression.kind === 93 /* SuperKeyword */;
+ return n.kind === 168 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */;
}
function containsSuperCallAsComputedPropertyName(n) {
return n.name && containsSuperCall(n.name);
@@ -22414,15 +23108,15 @@ var ts;
return ts.forEachChild(n, containsSuperCall);
}
function markThisReferencesAsErrors(n) {
- if (n.kind === 95 /* ThisKeyword */) {
+ if (n.kind === 97 /* ThisKeyword */) {
error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
}
- else if (n.kind !== 171 /* FunctionExpression */ && n.kind !== 211 /* FunctionDeclaration */) {
+ else if (n.kind !== 173 /* FunctionExpression */ && n.kind !== 213 /* FunctionDeclaration */) {
ts.forEachChild(n, markThisReferencesAsErrors);
}
}
function isInstancePropertyWithInitializer(n) {
- return n.kind === 139 /* PropertyDeclaration */ &&
+ return n.kind === 141 /* PropertyDeclaration */ &&
!(n.flags & 128 /* Static */) &&
!!n.initializer;
}
@@ -22452,7 +23146,7 @@ var ts;
var superCallStatement;
for (var _i = 0; _i < statements.length; _i++) {
var statement = statements[_i];
- if (statement.kind === 193 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) {
+ if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) {
superCallStatement = statement;
break;
}
@@ -22478,7 +23172,7 @@ var ts;
if (produceDiagnostics) {
// Grammar checking accessors
checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name);
- if (node.kind === 143 /* GetAccessor */) {
+ if (node.kind === 145 /* GetAccessor */) {
if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) {
error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement);
}
@@ -22486,7 +23180,7 @@ var ts;
if (!ts.hasDynamicName(node)) {
// TypeScript 1.0 spec (April 2014): 8.4.3
// Accessors for the same member name must specify the same accessibility.
- var otherKind = node.kind === 143 /* GetAccessor */ ? 144 /* SetAccessor */ : 143 /* GetAccessor */;
+ var otherKind = node.kind === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */;
var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind);
if (otherAccessor) {
if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) {
@@ -22582,9 +23276,9 @@ var ts;
var signaturesToCheck;
// Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer.
// Use declaring type to obtain full list of signatures.
- if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213 /* InterfaceDeclaration */) {
- ts.Debug.assert(signatureDeclarationNode.kind === 145 /* CallSignature */ || signatureDeclarationNode.kind === 146 /* ConstructSignature */);
- var signatureKind = signatureDeclarationNode.kind === 145 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */;
+ if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 215 /* InterfaceDeclaration */) {
+ ts.Debug.assert(signatureDeclarationNode.kind === 147 /* CallSignature */ || signatureDeclarationNode.kind === 148 /* ConstructSignature */);
+ var signatureKind = signatureDeclarationNode.kind === 147 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */;
var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent);
var containingType = getDeclaredTypeOfSymbol(containingSymbol);
signaturesToCheck = getSignaturesOfType(containingType, signatureKind);
@@ -22602,7 +23296,12 @@ var ts;
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedNodeFlags(n);
- if (n.parent.kind !== 213 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) {
+ // children of classes (even ambient classes) should not be marked as ambient or export
+ // because those flags have no useful semantics there.
+ if (n.parent.kind !== 215 /* InterfaceDeclaration */ &&
+ n.parent.kind !== 214 /* ClassDeclaration */ &&
+ n.parent.kind !== 186 /* ClassExpression */ &&
+ ts.isInAmbientContext(n)) {
if (!(flags & 2 /* Ambient */)) {
// It is nested in an ambient context, which means it is automatically exported
flags |= 1 /* Export */;
@@ -22687,11 +23386,16 @@ var ts;
var errorNode_1 = subsequentNode.name || subsequentNode;
// TODO(jfreeman): These are methods, so handle computed name case
if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) {
- // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members
- ts.Debug.assert(node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */);
- ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */));
- var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static;
- error(errorNode_1, diagnostic);
+ var reportError = (node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) &&
+ (node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */);
+ // we can get here in two cases
+ // 1. mixed static and instance class members
+ // 2. something with the same name was defined before the set of overloads that prevents them from merging
+ // here we'll report error only for the first case since for second we should already report error in binder
+ if (reportError) {
+ var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static;
+ error(errorNode_1, diagnostic);
+ }
return;
}
else if (ts.nodeIsPresent(subsequentNode.body)) {
@@ -22724,7 +23428,7 @@ var ts;
var current = declarations[_i];
var node = current;
var inAmbientContext = ts.isInAmbientContext(node);
- var inAmbientContextOrInterface = node.parent.kind === 213 /* InterfaceDeclaration */ || node.parent.kind === 153 /* TypeLiteral */ || inAmbientContext;
+ var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext;
if (inAmbientContextOrInterface) {
// check if declarations are consecutive only if they are non-ambient
// 1. ambient declarations can be interleaved
@@ -22735,7 +23439,7 @@ var ts;
// 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one
previousDeclaration = undefined;
}
- if (node.kind === 211 /* FunctionDeclaration */ || node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */ || node.kind === 142 /* Constructor */) {
+ if (node.kind === 213 /* FunctionDeclaration */ || node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */ || node.kind === 144 /* Constructor */) {
var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
someNodeFlags |= currentNodeFlags;
allNodeFlags &= currentNodeFlags;
@@ -22875,16 +23579,16 @@ var ts;
}
function getDeclarationSpaces(d) {
switch (d.kind) {
- case 213 /* InterfaceDeclaration */:
+ case 215 /* InterfaceDeclaration */:
return 2097152 /* ExportType */;
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */
? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */
: 4194304 /* ExportNamespace */;
- case 212 /* ClassDeclaration */:
- case 215 /* EnumDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 217 /* EnumDeclaration */:
return 2097152 /* ExportType */ | 1048576 /* ExportValue */;
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
var result = 0;
var target = resolveAlias(getSymbolOfNode(d));
ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); });
@@ -22895,7 +23599,8 @@ var ts;
}
}
function checkNonThenableType(type, location, message) {
- if (!(type.flags & 1 /* Any */) && isTypeAssignableTo(type, getGlobalThenableType())) {
+ type = getWidenedType(type);
+ if (!isTypeAny(type) && isTypeAssignableTo(type, getGlobalThenableType())) {
if (location) {
if (!message) {
message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member;
@@ -23096,9 +23801,12 @@ var ts;
// type as a value. As such, we will just return unknownType;
return unknownType;
}
- var promiseConstructor = getMergedSymbol(promiseType.symbol);
+ var promiseConstructor = getNodeLinks(node.type).resolvedSymbol;
if (!promiseConstructor || !symbolIsValue(promiseConstructor)) {
- error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType));
+ var typeName = promiseConstructor
+ ? symbolToString(promiseConstructor)
+ : typeToString(promiseType);
+ error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName);
return unknownType;
}
// Validate the promise constructor type.
@@ -23128,22 +23836,22 @@ var ts;
var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
var errorInfo;
switch (node.parent.kind) {
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
var classSymbol = getSymbolOfNode(node.parent);
var classConstructorType = getTypeOfSymbol(classSymbol);
expectedReturnType = getUnionType([classConstructorType, voidType]);
break;
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
expectedReturnType = voidType;
errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
break;
- case 139 /* PropertyDeclaration */:
+ case 141 /* PropertyDeclaration */:
expectedReturnType = voidType;
errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
break;
- case 141 /* MethodDeclaration */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
+ case 143 /* MethodDeclaration */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
var methodType = getTypeOfNode(node.parent);
var descriptorType = createTypedPropertyDescriptorType(methodType);
expectedReturnType = getUnionType([descriptorType, voidType]);
@@ -23156,9 +23864,9 @@ var ts;
// When we are emitting type metadata for decorators, we need to try to check the type
// as if it were an expression so that we can emit the type in a value position when we
// serialize the type metadata.
- if (node && node.kind === 149 /* TypeReference */) {
+ if (node && node.kind === 151 /* TypeReference */) {
var root = getFirstIdentifier(node.typeName);
- var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */;
+ var meaning = root.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */;
// Resolve type so we know which symbol is referenced
var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
// Resolved symbol is alias
@@ -23177,19 +23885,19 @@ var ts;
*/
function checkTypeAnnotationAsExpression(node) {
switch (node.kind) {
- case 139 /* PropertyDeclaration */:
+ case 141 /* PropertyDeclaration */:
checkTypeNodeAsExpression(node.type);
break;
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
checkTypeNodeAsExpression(node.type);
break;
- case 141 /* MethodDeclaration */:
+ case 143 /* MethodDeclaration */:
checkTypeNodeAsExpression(node.type);
break;
- case 143 /* GetAccessor */:
+ case 145 /* GetAccessor */:
checkTypeNodeAsExpression(node.type);
break;
- case 144 /* SetAccessor */:
+ case 146 /* SetAccessor */:
checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node));
break;
}
@@ -23218,25 +23926,25 @@ var ts;
if (compilerOptions.emitDecoratorMetadata) {
// we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator.
switch (node.kind) {
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
var constructor = ts.getFirstConstructorWithBody(node);
if (constructor) {
checkParameterTypeAnnotationsAsExpressions(constructor);
}
break;
- case 141 /* MethodDeclaration */:
+ case 143 /* MethodDeclaration */:
checkParameterTypeAnnotationsAsExpressions(node);
// fall-through
- case 144 /* SetAccessor */:
- case 143 /* GetAccessor */:
- case 139 /* PropertyDeclaration */:
- case 136 /* Parameter */:
+ case 146 /* SetAccessor */:
+ case 145 /* GetAccessor */:
+ case 141 /* PropertyDeclaration */:
+ case 138 /* Parameter */:
checkTypeAnnotationAsExpression(node);
break;
}
}
emitDecorate = true;
- if (node.kind === 136 /* Parameter */) {
+ if (node.kind === 138 /* Parameter */) {
emitParam = true;
}
ts.forEach(node.decorators, checkDecorator);
@@ -23254,15 +23962,12 @@ var ts;
checkSignatureDeclaration(node);
var isAsync = ts.isAsyncFunctionLike(node);
if (isAsync) {
- if (!compilerOptions.experimentalAsyncFunctions) {
- error(node, ts.Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning);
- }
emitAwaiter = true;
}
// Do not use hasDynamicName here, because that returns false for well known symbols.
// We want to perform checkComputedPropertyName for all computed properties, including
// well known symbols.
- if (node.name && node.name.kind === 134 /* ComputedPropertyName */) {
+ if (node.name && node.name.kind === 136 /* ComputedPropertyName */) {
// This check will account for methods in class/interface declarations,
// as well as accessors in classes/object literals
checkComputedPropertyName(node.name);
@@ -23311,11 +24016,11 @@ var ts;
}
function checkBlock(node) {
// Grammar checking for SyntaxKind.Block
- if (node.kind === 190 /* Block */) {
+ if (node.kind === 192 /* Block */) {
checkGrammarStatementInAmbientContext(node);
}
ts.forEach(node.statements, checkSourceElement);
- if (ts.isFunctionBlock(node) || node.kind === 217 /* ModuleBlock */) {
+ if (ts.isFunctionBlock(node) || node.kind === 219 /* ModuleBlock */) {
checkFunctionAndClassExpressionBodies(node);
}
}
@@ -23334,12 +24039,12 @@ var ts;
if (!(identifier && identifier.text === name)) {
return false;
}
- if (node.kind === 139 /* PropertyDeclaration */ ||
- node.kind === 138 /* PropertySignature */ ||
- node.kind === 141 /* MethodDeclaration */ ||
- node.kind === 140 /* MethodSignature */ ||
- node.kind === 143 /* GetAccessor */ ||
- node.kind === 144 /* SetAccessor */) {
+ if (node.kind === 141 /* PropertyDeclaration */ ||
+ node.kind === 140 /* PropertySignature */ ||
+ node.kind === 143 /* MethodDeclaration */ ||
+ node.kind === 142 /* MethodSignature */ ||
+ node.kind === 145 /* GetAccessor */ ||
+ node.kind === 146 /* SetAccessor */) {
// it is ok to have member named '_super' or '_this' - member access is always qualified
return false;
}
@@ -23348,7 +24053,7 @@ var ts;
return false;
}
var root = ts.getRootDeclaration(node);
- if (root.kind === 136 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) {
+ if (root.kind === 138 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) {
// just an overload - no codegen impact
return false;
}
@@ -23364,7 +24069,7 @@ var ts;
var current = node;
while (current) {
if (getNodeCheckFlags(current) & 4 /* CaptureThis */) {
- var isDeclaration_1 = node.kind !== 67 /* Identifier */;
+ var isDeclaration_1 = node.kind !== 69 /* Identifier */;
if (isDeclaration_1) {
error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference);
}
@@ -23387,7 +24092,7 @@ var ts;
return;
}
if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) {
- var isDeclaration_2 = node.kind !== 67 /* Identifier */;
+ var isDeclaration_2 = node.kind !== 69 /* Identifier */;
if (isDeclaration_2) {
error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference);
}
@@ -23401,12 +24106,12 @@ var ts;
return;
}
// Uninstantiated modules shouldnt do this check
- if (node.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
+ if (node.kind === 218 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
return;
}
// In case of variable declaration, node.parent is variable statement so look at the variable statement's parent
var parent = getDeclarationContainer(node);
- if (parent.kind === 246 /* SourceFile */ && ts.isExternalModule(parent)) {
+ if (parent.kind === 248 /* SourceFile */ && ts.isExternalModule(parent)) {
// If the declaration happens to be in external module, report error that require and exports are reserved keywords
error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name));
}
@@ -23441,7 +24146,7 @@ var ts;
// skip variable declarations that don't have initializers
// NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern
// so we'll always treat binding elements as initialized
- if (node.kind === 209 /* VariableDeclaration */ && !node.initializer) {
+ if (node.kind === 211 /* VariableDeclaration */ && !node.initializer) {
return;
}
var symbol = getSymbolOfNode(node);
@@ -23451,17 +24156,17 @@ var ts;
localDeclarationSymbol !== symbol &&
localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) {
if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) {
- var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210 /* VariableDeclarationList */);
- var container = varDeclList.parent.kind === 191 /* VariableStatement */ && varDeclList.parent.parent
+ var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */);
+ var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent
? varDeclList.parent.parent
: undefined;
// names of block-scoped and function scoped variables can collide only
// if block scoped variable is defined in the function\module\source file scope (because of variable hoisting)
var namesShareScope = container &&
- (container.kind === 190 /* Block */ && ts.isFunctionLike(container.parent) ||
- container.kind === 217 /* ModuleBlock */ ||
- container.kind === 216 /* ModuleDeclaration */ ||
- container.kind === 246 /* SourceFile */);
+ (container.kind === 192 /* Block */ && ts.isFunctionLike(container.parent) ||
+ container.kind === 219 /* ModuleBlock */ ||
+ container.kind === 218 /* ModuleDeclaration */ ||
+ container.kind === 248 /* SourceFile */);
// here we know that function scoped variable is shadowed by block scoped one
// if they are defined in the same scope - binder has already reported redeclaration error
// otherwise if variable has an initializer - show error that initialization will fail
@@ -23476,18 +24181,18 @@ var ts;
}
// Check that a parameter initializer contains no references to parameters declared to the right of itself
function checkParameterInitializer(node) {
- if (ts.getRootDeclaration(node).kind !== 136 /* Parameter */) {
+ if (ts.getRootDeclaration(node).kind !== 138 /* Parameter */) {
return;
}
var func = ts.getContainingFunction(node);
visit(node.initializer);
function visit(n) {
- if (n.kind === 67 /* Identifier */) {
+ if (n.kind === 69 /* Identifier */) {
var referencedSymbol = getNodeLinks(n).resolvedSymbol;
// check FunctionLikeDeclaration.locals (stores parameters\function local variable)
// if it contains entry with a specified name and if this entry matches the resolved symbol
if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) {
- if (referencedSymbol.valueDeclaration.kind === 136 /* Parameter */) {
+ if (referencedSymbol.valueDeclaration.kind === 138 /* Parameter */) {
if (referencedSymbol.valueDeclaration === node) {
error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name));
return;
@@ -23513,7 +24218,7 @@ var ts;
// Do not use hasDynamicName here, because that returns false for well known symbols.
// We want to perform checkComputedPropertyName for all computed properties, including
// well known symbols.
- if (node.name.kind === 134 /* ComputedPropertyName */) {
+ if (node.name.kind === 136 /* ComputedPropertyName */) {
checkComputedPropertyName(node.name);
if (node.initializer) {
checkExpressionCached(node.initializer);
@@ -23524,7 +24229,7 @@ var ts;
ts.forEach(node.name.elements, checkSourceElement);
}
// For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body
- if (node.initializer && ts.getRootDeclaration(node).kind === 136 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
+ if (node.initializer && ts.getRootDeclaration(node).kind === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
return;
}
@@ -23556,10 +24261,10 @@ var ts;
checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined);
}
}
- if (node.kind !== 139 /* PropertyDeclaration */ && node.kind !== 138 /* PropertySignature */) {
+ if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) {
// We know we don't have a binding pattern or computed name here
checkExportsOnMergedDeclarations(node);
- if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) {
+ if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) {
checkVarDeclaredNamesNotShadowed(node);
}
checkCollisionWithCapturedSuperVariable(node, node.name);
@@ -23582,7 +24287,7 @@ var ts;
}
function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) {
// We only disallow modifier on a method declaration if it is a property of object-literal-expression
- if (node.modifiers && node.parent.kind === 163 /* ObjectLiteralExpression */) {
+ if (node.modifiers && node.parent.kind === 165 /* ObjectLiteralExpression */) {
if (ts.isAsyncFunctionLike(node)) {
if (node.modifiers.length > 1) {
return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
@@ -23620,12 +24325,12 @@ var ts;
function checkForStatement(node) {
// Grammar checking
if (!checkGrammarStatementInAmbientContext(node)) {
- if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) {
+ if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) {
checkGrammarVariableDeclarationList(node.initializer);
}
}
if (node.initializer) {
- if (node.initializer.kind === 210 /* VariableDeclarationList */) {
+ if (node.initializer.kind === 212 /* VariableDeclarationList */) {
ts.forEach(node.initializer.declarations, checkVariableDeclaration);
}
else {
@@ -23645,14 +24350,14 @@ var ts;
// via checkRightHandSideOfForOf.
// If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference.
// Then check that the RHS is assignable to it.
- if (node.initializer.kind === 210 /* VariableDeclarationList */) {
+ if (node.initializer.kind === 212 /* VariableDeclarationList */) {
checkForInOrForOfVariableDeclaration(node);
}
else {
var varExpr = node.initializer;
var iteratedType = checkRightHandSideOfForOf(node.expression);
// There may be a destructuring assignment on the left side
- if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) {
+ if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) {
// iteratedType may be undefined. In this case, we still want to check the structure of
// varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like
// to short circuit the type relation checking as much as possible, so we pass the unknownType.
@@ -23681,7 +24386,7 @@ var ts;
// for (let VarDecl in Expr) Statement
// VarDecl must be a variable declaration without a type annotation that declares a variable of type Any,
// and Expr must be an expression of type Any, an object type, or a type parameter type.
- if (node.initializer.kind === 210 /* VariableDeclarationList */) {
+ if (node.initializer.kind === 212 /* VariableDeclarationList */) {
var variable = node.initializer.declarations[0];
if (variable && ts.isBindingPattern(variable.name)) {
error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
@@ -23695,7 +24400,7 @@ var ts;
// and Expr must be an expression of type Any, an object type, or a type parameter type.
var varExpr = node.initializer;
var leftType = checkExpression(varExpr);
- if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) {
+ if (varExpr.kind === 164 /* ArrayLiteralExpression */ || varExpr.kind === 165 /* ObjectLiteralExpression */) {
error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
}
else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) {
@@ -23934,7 +24639,7 @@ var ts;
// TODO: Check that target label is valid
}
function isGetAccessorWithAnnotatatedSetAccessor(node) {
- return !!(node.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144 /* SetAccessor */)));
+ return !!(node.kind === 145 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 146 /* SetAccessor */)));
}
function checkReturnStatement(node) {
// Grammar checking
@@ -23957,10 +24662,10 @@ var ts;
// for generators.
return;
}
- if (func.kind === 144 /* SetAccessor */) {
+ if (func.kind === 146 /* SetAccessor */) {
error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value);
}
- else if (func.kind === 142 /* Constructor */) {
+ else if (func.kind === 144 /* Constructor */) {
if (!isTypeAssignableTo(exprType, returnType)) {
error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
}
@@ -23969,7 +24674,12 @@ var ts;
if (ts.isAsyncFunctionLike(func)) {
var promisedType = getPromisedType(returnType);
var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
- checkTypeAssignableTo(awaitedType, promisedType, node.expression);
+ if (promisedType) {
+ // If the function has a return type, but promisedType is
+ // undefined, an error will be reported in checkAsyncFunctionReturnType
+ // so we don't need to report one here.
+ checkTypeAssignableTo(awaitedType, promisedType, node.expression);
+ }
}
else {
checkTypeAssignableTo(exprType, returnType, node.expression);
@@ -23996,7 +24706,7 @@ var ts;
var expressionType = checkExpression(node.expression);
ts.forEach(node.caseBlock.clauses, function (clause) {
// Grammar check for duplicate default clauses, skip if we already report duplicate default clause
- if (clause.kind === 240 /* DefaultClause */ && !hasDuplicateDefaultClause) {
+ if (clause.kind === 242 /* DefaultClause */ && !hasDuplicateDefaultClause) {
if (firstDefaultClause === undefined) {
firstDefaultClause = clause;
}
@@ -24008,7 +24718,7 @@ var ts;
hasDuplicateDefaultClause = true;
}
}
- if (produceDiagnostics && clause.kind === 239 /* CaseClause */) {
+ if (produceDiagnostics && clause.kind === 241 /* CaseClause */) {
var caseClause = clause;
// TypeScript 1.0 spec (April 2014):5.9
// In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression.
@@ -24029,7 +24739,7 @@ var ts;
if (ts.isFunctionLike(current)) {
break;
}
- if (current.kind === 205 /* LabeledStatement */ && current.label.text === node.label.text) {
+ if (current.kind === 207 /* LabeledStatement */ && current.label.text === node.label.text) {
var sourceFile = ts.getSourceFileOfNode(node);
grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label));
break;
@@ -24059,7 +24769,7 @@ var ts;
if (catchClause) {
// Grammar checking
if (catchClause.variableDeclaration) {
- if (catchClause.variableDeclaration.name.kind !== 67 /* Identifier */) {
+ if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) {
grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier);
}
else if (catchClause.variableDeclaration.type) {
@@ -24134,7 +24844,7 @@ var ts;
// perform property check if property or indexer is declared in 'type'
// this allows to rule out cases when both property and indexer are inherited from the base class
var errorNode;
- if (prop.valueDeclaration.name.kind === 134 /* ComputedPropertyName */ || prop.parent === containingType.symbol) {
+ if (prop.valueDeclaration.name.kind === 136 /* ComputedPropertyName */ || prop.parent === containingType.symbol) {
errorNode = prop.valueDeclaration;
}
else if (indexDeclaration) {
@@ -24193,10 +24903,6 @@ var ts;
grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
}
checkClassLikeDeclaration(node);
- // Interfaces cannot be merged with non-ambient classes.
- if (getSymbolOfNode(node).flags & 64 /* Interface */ && !ts.isInAmbientContext(node)) {
- error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
- }
ts.forEach(node.members, checkSourceElement);
}
function checkClassLikeDeclaration(node) {
@@ -24211,6 +24917,7 @@ var ts;
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
var type = getDeclaredTypeOfSymbol(symbol);
+ var typeWithThis = getTypeWithThisArgument(type);
var staticType = getTypeOfSymbol(symbol);
var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node);
if (baseTypeNode) {
@@ -24229,7 +24936,7 @@ var ts;
}
}
}
- checkTypeAssignableTo(type, baseType, node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
+ checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) {
// When the static base type is a "class-like" constructor function (but not actually a class), we verify
@@ -24246,7 +24953,8 @@ var ts;
}
var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node);
if (implementedTypeNodes) {
- ts.forEach(implementedTypeNodes, function (typeRefNode) {
+ for (var _b = 0; _b < implementedTypeNodes.length; _b++) {
+ var typeRefNode = implementedTypeNodes[_b];
if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) {
error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
}
@@ -24256,14 +24964,14 @@ var ts;
if (t !== unknownType) {
var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t;
if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) {
- checkTypeAssignableTo(type, t, node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1);
+ checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1);
}
else {
error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface);
}
}
}
- });
+ }
}
if (produceDiagnostics) {
checkIndexConstraints(type);
@@ -24275,6 +24983,9 @@ var ts;
// so we'll need to get back original 'target' symbol to work with correct set of flags
return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s;
}
+ function getClassLikeDeclarationOfSymbol(symbol) {
+ return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; });
+ }
function checkKindsOfPropertyMemberOverrides(type, baseType) {
// TypeScript 1.0 spec (April 2014): 8.2.3
// A derived class inherits all members from its base class it doesn't override.
@@ -24306,12 +25017,17 @@ var ts;
// type declaration, derived and base resolve to the same symbol even in the case of generic classes.
if (derived === base) {
// derived class inherits base without override/redeclaration
- var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212 /* ClassDeclaration */);
+ var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol);
// It is an error to inherit an abstract member without implementing it or being declared abstract.
// If there is no declaration for the derived class (as in the case of class expressions),
// then the class cannot be declared abstract.
if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) {
- error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ if (derivedClassDecl.kind === 186 /* ClassExpression */) {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
+ }
+ else {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ }
}
}
else {
@@ -24354,7 +25070,7 @@ var ts;
}
}
function isAccessor(kind) {
- return kind === 143 /* GetAccessor */ || kind === 144 /* SetAccessor */;
+ return kind === 145 /* GetAccessor */ || kind === 146 /* SetAccessor */;
}
function areTypeParametersIdentical(list1, list2) {
if (!list1 && !list2) {
@@ -24394,7 +25110,7 @@ var ts;
var ok = true;
for (var _i = 0; _i < baseTypes.length; _i++) {
var base = baseTypes[_i];
- var properties = getPropertiesOfObjectType(base);
+ var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType));
for (var _a = 0; _a < properties.length; _a++) {
var prop = properties[_a];
if (!ts.hasProperty(seen, prop.name)) {
@@ -24424,7 +25140,7 @@ var ts;
checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
- var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */);
+ var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 215 /* InterfaceDeclaration */);
if (symbol.declarations.length > 1) {
if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) {
error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters);
@@ -24433,22 +25149,14 @@ var ts;
// Only check this symbol once
if (node === firstInterfaceDecl) {
var type = getDeclaredTypeOfSymbol(symbol);
+ var typeWithThis = getTypeWithThisArgument(type);
// run subsequent checks only if first set succeeded
if (checkInheritedPropertiesAreIdentical(type, node.name)) {
- ts.forEach(getBaseTypes(type), function (baseType) {
- checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1);
- });
- checkIndexConstraints(type);
- }
- }
- // Interfaces cannot merge with non-ambient classes.
- if (symbol && symbol.declarations) {
- for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
- var declaration = _a[_i];
- if (declaration.kind === 212 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) {
- error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
- break;
+ for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) {
+ var baseType = _a[_i];
+ checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1);
}
+ checkIndexConstraints(type);
}
}
}
@@ -24474,24 +25182,38 @@ var ts;
if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) {
var enumSymbol = getSymbolOfNode(node);
var enumType = getDeclaredTypeOfSymbol(enumSymbol);
- var autoValue = 0;
+ var autoValue = 0; // set to undefined when enum member is non-constant
var ambient = ts.isInAmbientContext(node);
var enumIsConst = ts.isConst(node);
- ts.forEach(node.members, function (member) {
- if (member.name.kind !== 134 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) {
+ for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
+ var member = _a[_i];
+ if (member.name.kind === 136 /* ComputedPropertyName */) {
+ error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums);
+ }
+ else if (isNumericLiteralName(member.name.text)) {
error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
}
+ var previousEnumMemberIsNonConstant = autoValue === undefined;
var initializer = member.initializer;
if (initializer) {
autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient);
}
else if (ambient && !enumIsConst) {
+ // In ambient enum declarations that specify no const modifier, enum member declarations
+ // that omit a value are considered computed members (as opposed to having auto-incremented values assigned).
autoValue = undefined;
}
+ else if (previousEnumMemberIsNonConstant) {
+ // If the member declaration specifies no value, the member is considered a constant enum member.
+ // If the member is the first member in the enum declaration, it is assigned the value zero.
+ // Otherwise, it is assigned the value of the immediately preceding member plus one,
+ // and an error occurs if the immediately preceding member is not a constant enum member
+ error(member.name, ts.Diagnostics.Enum_member_must_have_initializer);
+ }
if (autoValue !== undefined) {
getNodeLinks(member).enumMemberValue = autoValue++;
}
- });
+ }
nodeLinks.flags |= 8192 /* EnumValuesComputed */;
}
function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) {
@@ -24504,11 +25226,11 @@ var ts;
if (enumIsConst) {
error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression);
}
- else if (!ambient) {
+ else if (ambient) {
+ error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
+ }
+ else {
// Only here do we need to check that the initializer is assignable to the enum type.
- // If it is a constant value (not undefined), it is syntactically constrained to be a number.
- // Also, we do not need to check this for ambients because there is already
- // a syntax error if it is not a constant.
checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined);
}
}
@@ -24524,7 +25246,7 @@ var ts;
return value;
function evalConstant(e) {
switch (e.kind) {
- case 177 /* PrefixUnaryExpression */:
+ case 179 /* PrefixUnaryExpression */:
var value_1 = evalConstant(e.operand);
if (value_1 === undefined) {
return undefined;
@@ -24532,10 +25254,10 @@ var ts;
switch (e.operator) {
case 35 /* PlusToken */: return value_1;
case 36 /* MinusToken */: return -value_1;
- case 49 /* TildeToken */: return ~value_1;
+ case 50 /* TildeToken */: return ~value_1;
}
return undefined;
- case 179 /* BinaryExpression */:
+ case 181 /* BinaryExpression */:
var left = evalConstant(e.left);
if (left === undefined) {
return undefined;
@@ -24545,31 +25267,31 @@ var ts;
return undefined;
}
switch (e.operatorToken.kind) {
- case 46 /* BarToken */: return left | right;
- case 45 /* AmpersandToken */: return left & right;
- case 43 /* GreaterThanGreaterThanToken */: return left >> right;
- case 44 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right;
- case 42 /* LessThanLessThanToken */: return left << right;
- case 47 /* CaretToken */: return left ^ right;
+ case 47 /* BarToken */: return left | right;
+ case 46 /* AmpersandToken */: return left & right;
+ case 44 /* GreaterThanGreaterThanToken */: return left >> right;
+ case 45 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right;
+ case 43 /* LessThanLessThanToken */: return left << right;
+ case 48 /* CaretToken */: return left ^ right;
case 37 /* AsteriskToken */: return left * right;
- case 38 /* SlashToken */: return left / right;
+ case 39 /* SlashToken */: return left / right;
case 35 /* PlusToken */: return left + right;
case 36 /* MinusToken */: return left - right;
- case 39 /* PercentToken */: return left % right;
+ case 40 /* PercentToken */: return left % right;
}
return undefined;
case 8 /* NumericLiteral */:
return +e.text;
- case 170 /* ParenthesizedExpression */:
+ case 172 /* ParenthesizedExpression */:
return evalConstant(e.expression);
- case 67 /* Identifier */:
- case 165 /* ElementAccessExpression */:
- case 164 /* PropertyAccessExpression */:
+ case 69 /* Identifier */:
+ case 167 /* ElementAccessExpression */:
+ case 166 /* PropertyAccessExpression */:
var member = initializer.parent;
var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent));
var enumType_1;
var propertyName;
- if (e.kind === 67 /* Identifier */) {
+ if (e.kind === 69 /* Identifier */) {
// unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work.
// instead pick current enum type and later try to fetch member from the type
enumType_1 = currentType;
@@ -24577,7 +25299,7 @@ var ts;
}
else {
var expression;
- if (e.kind === 165 /* ElementAccessExpression */) {
+ if (e.kind === 167 /* ElementAccessExpression */) {
if (e.argumentExpression === undefined ||
e.argumentExpression.kind !== 9 /* StringLiteral */) {
return undefined;
@@ -24592,10 +25314,10 @@ var ts;
// expression part in ElementAccess\PropertyAccess should be either identifier or dottedName
var current = expression;
while (current) {
- if (current.kind === 67 /* Identifier */) {
+ if (current.kind === 69 /* Identifier */) {
break;
}
- else if (current.kind === 164 /* PropertyAccessExpression */) {
+ else if (current.kind === 166 /* PropertyAccessExpression */) {
current = current.expression;
}
else {
@@ -24621,7 +25343,7 @@ var ts;
return undefined;
}
// illegal case: forward reference
- if (!isDefinedBefore(propertyDecl, member)) {
+ if (!isBlockScopedNameDeclaredBeforeUse(propertyDecl, member)) {
reportError = false;
error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
@@ -24636,7 +25358,7 @@ var ts;
return;
}
// Grammar checking
- checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
+ checkGrammarDecorators(node) || checkGrammarModifiers(node);
checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
@@ -24666,7 +25388,7 @@ var ts;
var seenEnumMissingInitialInitializer = false;
ts.forEach(enumSymbol.declarations, function (declaration) {
// return true if we hit a violation of the rule, false otherwise
- if (declaration.kind !== 215 /* EnumDeclaration */) {
+ if (declaration.kind !== 217 /* EnumDeclaration */) {
return false;
}
var enumDeclaration = declaration;
@@ -24689,8 +25411,8 @@ var ts;
var declarations = symbol.declarations;
for (var _i = 0; _i < declarations.length; _i++) {
var declaration = declarations[_i];
- if ((declaration.kind === 212 /* ClassDeclaration */ ||
- (declaration.kind === 211 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
+ if ((declaration.kind === 214 /* ClassDeclaration */ ||
+ (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
!ts.isInAmbientContext(declaration)) {
return declaration;
}
@@ -24746,7 +25468,7 @@ var ts;
}
// if the module merges with a class declaration in the same lexical scope,
// we need to track this to ensure the correct emit.
- var mergedClass = ts.getDeclarationOfKind(symbol, 212 /* ClassDeclaration */);
+ var mergedClass = ts.getDeclarationOfKind(symbol, 214 /* ClassDeclaration */);
if (mergedClass &&
inSameLexicalScope(node, mergedClass)) {
getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */;
@@ -24755,9 +25477,9 @@ var ts;
// Checks for ambient external modules.
if (isAmbientExternalModule) {
if (!isGlobalSourceFile(node.parent)) {
- error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules);
+ error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces);
}
- if (isExternalModuleNameRelative(node.name.text)) {
+ if (ts.isExternalModuleNameRelative(node.name.text)) {
error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
}
}
@@ -24766,17 +25488,17 @@ var ts;
}
function getFirstIdentifier(node) {
while (true) {
- if (node.kind === 133 /* QualifiedName */) {
+ if (node.kind === 135 /* QualifiedName */) {
node = node.left;
}
- else if (node.kind === 164 /* PropertyAccessExpression */) {
+ else if (node.kind === 166 /* PropertyAccessExpression */) {
node = node.expression;
}
else {
break;
}
}
- ts.Debug.assert(node.kind === 67 /* Identifier */);
+ ts.Debug.assert(node.kind === 69 /* Identifier */);
return node;
}
function checkExternalImportOrExportDeclaration(node) {
@@ -24785,14 +25507,14 @@ var ts;
error(moduleName, ts.Diagnostics.String_literal_expected);
return false;
}
- var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */;
- if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) {
- error(moduleName, node.kind === 226 /* ExportDeclaration */ ?
+ var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */;
+ if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) {
+ error(moduleName, node.kind === 228 /* ExportDeclaration */ ?
ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
return false;
}
- if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) {
+ if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) {
// TypeScript 1.0 spec (April 2013): 12.1.6
// An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference
// other external modules only through top - level external module names.
@@ -24810,7 +25532,7 @@ var ts;
(symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) |
(symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0);
if (target.flags & excludedMeanings) {
- var message = node.kind === 228 /* ExportSpecifier */ ?
+ var message = node.kind === 230 /* ExportSpecifier */ ?
ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
error(node, message, symbolToString(symbol));
@@ -24837,7 +25559,7 @@ var ts;
checkImportBinding(importClause);
}
if (importClause.namedBindings) {
- if (importClause.namedBindings.kind === 222 /* NamespaceImport */) {
+ if (importClause.namedBindings.kind === 224 /* NamespaceImport */) {
checkImportBinding(importClause.namedBindings);
}
else {
@@ -24874,9 +25596,9 @@ var ts;
}
}
else {
- if (languageVersion >= 2 /* ES6 */ && !ts.isInAmbientContext(node)) {
+ if (modulekind === 5 /* ES6 */ && !ts.isInAmbientContext(node)) {
// Import equals declaration is deprecated in es6 or above
- grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead);
+ grammarErrorOnNode(node, ts.Diagnostics.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);
}
}
}
@@ -24894,8 +25616,8 @@ var ts;
// export { x, y }
// export { x, y } from "foo"
ts.forEach(node.exportClause.elements, checkExportSpecifier);
- var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */;
- if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) {
+ var inAmbientExternalModule = node.parent.kind === 219 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */;
+ if (node.parent.kind !== 248 /* SourceFile */ && !inAmbientExternalModule) {
error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
}
}
@@ -24909,7 +25631,7 @@ var ts;
}
}
function checkGrammarModuleElementContext(node, errorMessage) {
- if (node.parent.kind !== 246 /* SourceFile */ && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 216 /* ModuleDeclaration */) {
+ if (node.parent.kind !== 248 /* SourceFile */ && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 218 /* ModuleDeclaration */) {
return grammarErrorOnFirstToken(node, errorMessage);
}
}
@@ -24924,8 +25646,8 @@ var ts;
// If we hit an export assignment in an illegal context, just bail out to avoid cascading errors.
return;
}
- var container = node.parent.kind === 246 /* SourceFile */ ? node.parent : node.parent.parent;
- if (container.kind === 216 /* ModuleDeclaration */ && container.name.kind === 67 /* Identifier */) {
+ var container = node.parent.kind === 248 /* SourceFile */ ? node.parent : node.parent.parent;
+ if (container.kind === 218 /* ModuleDeclaration */ && container.name.kind === 69 /* Identifier */) {
error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
return;
}
@@ -24933,7 +25655,7 @@ var ts;
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) {
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers);
}
- if (node.expression.kind === 67 /* Identifier */) {
+ if (node.expression.kind === 69 /* Identifier */) {
markExportAsReferenced(node);
}
else {
@@ -24941,21 +25663,21 @@ var ts;
}
checkExternalModuleExports(container);
if (node.isExportEquals && !ts.isInAmbientContext(node)) {
- if (languageVersion >= 2 /* ES6 */) {
- // export assignment is deprecated in es6 or above
- grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead);
+ if (modulekind === 5 /* ES6 */) {
+ // export assignment is not supported in es6 modules
+ grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead);
}
- else if (compilerOptions.module === 4 /* System */) {
+ else if (modulekind === 4 /* System */) {
// system modules does not support export assignment
grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
}
}
}
function getModuleStatements(node) {
- if (node.kind === 246 /* SourceFile */) {
+ if (node.kind === 248 /* SourceFile */) {
return node.statements;
}
- if (node.kind === 216 /* ModuleDeclaration */ && node.body.kind === 217 /* ModuleBlock */) {
+ if (node.kind === 218 /* ModuleDeclaration */ && node.body.kind === 219 /* ModuleBlock */) {
return node.body.statements;
}
return emptyArray;
@@ -24994,118 +25716,118 @@ var ts;
// Only bother checking on a few construct kinds. We don't want to be excessivly
// hitting the cancellation token on every node we check.
switch (kind) {
- case 216 /* ModuleDeclaration */:
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 211 /* FunctionDeclaration */:
+ case 218 /* ModuleDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 213 /* FunctionDeclaration */:
cancellationToken.throwIfCancellationRequested();
}
}
switch (kind) {
- case 135 /* TypeParameter */:
+ case 137 /* TypeParameter */:
return checkTypeParameter(node);
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
return checkParameter(node);
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
return checkPropertyDeclaration(node);
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
return checkSignatureDeclaration(node);
- case 147 /* IndexSignature */:
+ case 149 /* IndexSignature */:
return checkSignatureDeclaration(node);
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
return checkMethodDeclaration(node);
- case 142 /* Constructor */:
+ case 144 /* Constructor */:
return checkConstructorDeclaration(node);
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
return checkAccessorDeclaration(node);
- case 149 /* TypeReference */:
+ case 151 /* TypeReference */:
return checkTypeReferenceNode(node);
- case 148 /* TypePredicate */:
+ case 150 /* TypePredicate */:
return checkTypePredicate(node);
- case 152 /* TypeQuery */:
+ case 154 /* TypeQuery */:
return checkTypeQuery(node);
- case 153 /* TypeLiteral */:
+ case 155 /* TypeLiteral */:
return checkTypeLiteral(node);
- case 154 /* ArrayType */:
+ case 156 /* ArrayType */:
return checkArrayType(node);
- case 155 /* TupleType */:
+ case 157 /* TupleType */:
return checkTupleType(node);
- case 156 /* UnionType */:
- case 157 /* IntersectionType */:
+ case 158 /* UnionType */:
+ case 159 /* IntersectionType */:
return checkUnionOrIntersectionType(node);
- case 158 /* ParenthesizedType */:
+ case 160 /* ParenthesizedType */:
return checkSourceElement(node.type);
- case 211 /* FunctionDeclaration */:
+ case 213 /* FunctionDeclaration */:
return checkFunctionDeclaration(node);
- case 190 /* Block */:
- case 217 /* ModuleBlock */:
+ case 192 /* Block */:
+ case 219 /* ModuleBlock */:
return checkBlock(node);
- case 191 /* VariableStatement */:
+ case 193 /* VariableStatement */:
return checkVariableStatement(node);
- case 193 /* ExpressionStatement */:
+ case 195 /* ExpressionStatement */:
return checkExpressionStatement(node);
- case 194 /* IfStatement */:
+ case 196 /* IfStatement */:
return checkIfStatement(node);
- case 195 /* DoStatement */:
+ case 197 /* DoStatement */:
return checkDoStatement(node);
- case 196 /* WhileStatement */:
+ case 198 /* WhileStatement */:
return checkWhileStatement(node);
- case 197 /* ForStatement */:
+ case 199 /* ForStatement */:
return checkForStatement(node);
- case 198 /* ForInStatement */:
+ case 200 /* ForInStatement */:
return checkForInStatement(node);
- case 199 /* ForOfStatement */:
+ case 201 /* ForOfStatement */:
return checkForOfStatement(node);
- case 200 /* ContinueStatement */:
- case 201 /* BreakStatement */:
+ case 202 /* ContinueStatement */:
+ case 203 /* BreakStatement */:
return checkBreakOrContinueStatement(node);
- case 202 /* ReturnStatement */:
+ case 204 /* ReturnStatement */:
return checkReturnStatement(node);
- case 203 /* WithStatement */:
+ case 205 /* WithStatement */:
return checkWithStatement(node);
- case 204 /* SwitchStatement */:
+ case 206 /* SwitchStatement */:
return checkSwitchStatement(node);
- case 205 /* LabeledStatement */:
+ case 207 /* LabeledStatement */:
return checkLabeledStatement(node);
- case 206 /* ThrowStatement */:
+ case 208 /* ThrowStatement */:
return checkThrowStatement(node);
- case 207 /* TryStatement */:
+ case 209 /* TryStatement */:
return checkTryStatement(node);
- case 209 /* VariableDeclaration */:
+ case 211 /* VariableDeclaration */:
return checkVariableDeclaration(node);
- case 161 /* BindingElement */:
+ case 163 /* BindingElement */:
return checkBindingElement(node);
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
return checkClassDeclaration(node);
- case 213 /* InterfaceDeclaration */:
+ case 215 /* InterfaceDeclaration */:
return checkInterfaceDeclaration(node);
- case 214 /* TypeAliasDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
return checkTypeAliasDeclaration(node);
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
return checkEnumDeclaration(node);
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
return checkModuleDeclaration(node);
- case 220 /* ImportDeclaration */:
+ case 222 /* ImportDeclaration */:
return checkImportDeclaration(node);
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
return checkImportEqualsDeclaration(node);
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
return checkExportDeclaration(node);
- case 225 /* ExportAssignment */:
+ case 227 /* ExportAssignment */:
return checkExportAssignment(node);
- case 192 /* EmptyStatement */:
+ case 194 /* EmptyStatement */:
checkGrammarStatementInAmbientContext(node);
return;
- case 208 /* DebuggerStatement */:
+ case 210 /* DebuggerStatement */:
checkGrammarStatementInAmbientContext(node);
return;
- case 229 /* MissingDeclaration */:
+ case 231 /* MissingDeclaration */:
return checkMissingDeclaration(node);
}
}
@@ -25120,97 +25842,98 @@ var ts;
// Delaying the type check of the body ensures foo has been assigned a type.
function checkFunctionAndClassExpressionBodies(node) {
switch (node.kind) {
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies);
checkFunctionExpressionOrObjectLiteralMethodBody(node);
break;
- case 184 /* ClassExpression */:
+ case 186 /* ClassExpression */:
ts.forEach(node.members, checkSourceElement);
+ ts.forEachChild(node, checkFunctionAndClassExpressionBodies);
break;
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies);
ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies);
if (ts.isObjectLiteralMethod(node)) {
checkFunctionExpressionOrObjectLiteralMethodBody(node);
}
break;
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 211 /* FunctionDeclaration */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 213 /* FunctionDeclaration */:
ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies);
break;
- case 203 /* WithStatement */:
+ case 205 /* WithStatement */:
checkFunctionAndClassExpressionBodies(node.expression);
break;
- case 137 /* Decorator */:
- case 136 /* Parameter */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 159 /* ObjectBindingPattern */:
- case 160 /* ArrayBindingPattern */:
- case 161 /* BindingElement */:
- case 162 /* ArrayLiteralExpression */:
- case 163 /* ObjectLiteralExpression */:
- case 243 /* PropertyAssignment */:
- case 164 /* PropertyAccessExpression */:
- case 165 /* ElementAccessExpression */:
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
- case 168 /* TaggedTemplateExpression */:
- case 181 /* TemplateExpression */:
- case 188 /* TemplateSpan */:
- case 169 /* TypeAssertionExpression */:
- case 187 /* AsExpression */:
- case 170 /* ParenthesizedExpression */:
- case 174 /* TypeOfExpression */:
- case 175 /* VoidExpression */:
- case 176 /* AwaitExpression */:
- case 173 /* DeleteExpression */:
- case 177 /* PrefixUnaryExpression */:
- case 178 /* PostfixUnaryExpression */:
- case 179 /* BinaryExpression */:
- case 180 /* ConditionalExpression */:
- case 183 /* SpreadElementExpression */:
- case 182 /* YieldExpression */:
- case 190 /* Block */:
- case 217 /* ModuleBlock */:
- case 191 /* VariableStatement */:
- case 193 /* ExpressionStatement */:
- case 194 /* IfStatement */:
- case 195 /* DoStatement */:
- case 196 /* WhileStatement */:
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 200 /* ContinueStatement */:
- case 201 /* BreakStatement */:
- case 202 /* ReturnStatement */:
- case 204 /* SwitchStatement */:
- case 218 /* CaseBlock */:
- case 239 /* CaseClause */:
- case 240 /* DefaultClause */:
- case 205 /* LabeledStatement */:
- case 206 /* ThrowStatement */:
- case 207 /* TryStatement */:
- case 242 /* CatchClause */:
- case 209 /* VariableDeclaration */:
- case 210 /* VariableDeclarationList */:
- case 212 /* ClassDeclaration */:
- case 241 /* HeritageClause */:
- case 186 /* ExpressionWithTypeArguments */:
- case 215 /* EnumDeclaration */:
- case 245 /* EnumMember */:
- case 225 /* ExportAssignment */:
- case 246 /* SourceFile */:
- case 238 /* JsxExpression */:
- case 231 /* JsxElement */:
- case 232 /* JsxSelfClosingElement */:
- case 236 /* JsxAttribute */:
- case 237 /* JsxSpreadAttribute */:
- case 233 /* JsxOpeningElement */:
+ case 139 /* Decorator */:
+ case 138 /* Parameter */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 161 /* ObjectBindingPattern */:
+ case 162 /* ArrayBindingPattern */:
+ case 163 /* BindingElement */:
+ case 164 /* ArrayLiteralExpression */:
+ case 165 /* ObjectLiteralExpression */:
+ case 245 /* PropertyAssignment */:
+ case 166 /* PropertyAccessExpression */:
+ case 167 /* ElementAccessExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
+ case 170 /* TaggedTemplateExpression */:
+ case 183 /* TemplateExpression */:
+ case 190 /* TemplateSpan */:
+ case 171 /* TypeAssertionExpression */:
+ case 189 /* AsExpression */:
+ case 172 /* ParenthesizedExpression */:
+ case 176 /* TypeOfExpression */:
+ case 177 /* VoidExpression */:
+ case 178 /* AwaitExpression */:
+ case 175 /* DeleteExpression */:
+ case 179 /* PrefixUnaryExpression */:
+ case 180 /* PostfixUnaryExpression */:
+ case 181 /* BinaryExpression */:
+ case 182 /* ConditionalExpression */:
+ case 185 /* SpreadElementExpression */:
+ case 184 /* YieldExpression */:
+ case 192 /* Block */:
+ case 219 /* ModuleBlock */:
+ case 193 /* VariableStatement */:
+ case 195 /* ExpressionStatement */:
+ case 196 /* IfStatement */:
+ case 197 /* DoStatement */:
+ case 198 /* WhileStatement */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 202 /* ContinueStatement */:
+ case 203 /* BreakStatement */:
+ case 204 /* ReturnStatement */:
+ case 206 /* SwitchStatement */:
+ case 220 /* CaseBlock */:
+ case 241 /* CaseClause */:
+ case 242 /* DefaultClause */:
+ case 207 /* LabeledStatement */:
+ case 208 /* ThrowStatement */:
+ case 209 /* TryStatement */:
+ case 244 /* CatchClause */:
+ case 211 /* VariableDeclaration */:
+ case 212 /* VariableDeclarationList */:
+ case 214 /* ClassDeclaration */:
+ case 243 /* HeritageClause */:
+ case 188 /* ExpressionWithTypeArguments */:
+ case 217 /* EnumDeclaration */:
+ case 247 /* EnumMember */:
+ case 227 /* ExportAssignment */:
+ case 248 /* SourceFile */:
+ case 240 /* JsxExpression */:
+ case 233 /* JsxElement */:
+ case 234 /* JsxSelfClosingElement */:
+ case 238 /* JsxAttribute */:
+ case 239 /* JsxSpreadAttribute */:
+ case 235 /* JsxOpeningElement */:
ts.forEachChild(node, checkFunctionAndClassExpressionBodies);
break;
}
@@ -25296,7 +26019,7 @@ var ts;
function isInsideWithStatementBody(node) {
if (node) {
while (node.parent) {
- if (node.parent.kind === 203 /* WithStatement */ && node.parent.statement === node) {
+ if (node.parent.kind === 205 /* WithStatement */ && node.parent.statement === node) {
return true;
}
node = node.parent;
@@ -25319,34 +26042,34 @@ var ts;
copySymbols(location.locals, meaning);
}
switch (location.kind) {
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
if (!ts.isExternalModule(location)) {
break;
}
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */);
break;
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */);
break;
- case 184 /* ClassExpression */:
+ case 186 /* ClassExpression */:
var className = location.name;
if (className) {
copySymbol(location.symbol, meaning);
}
// fall through; this fall-through is necessary because we would like to handle
// type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
// If we didn't come from static member of class or interface,
- // add the type parameters into the symbol table
+ // add the type parameters into the symbol table
// (type parameters of classDeclaration/classExpression and interface are in member property of the symbol.
// Note: that the memberFlags come from previous iteration.
if (!(memberFlags & 128 /* Static */)) {
copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */);
}
break;
- case 171 /* FunctionExpression */:
+ case 173 /* FunctionExpression */:
var funcName = location.name;
if (funcName) {
copySymbol(location.symbol, meaning);
@@ -25389,43 +26112,43 @@ var ts;
}
}
function isTypeDeclarationName(name) {
- return name.kind === 67 /* Identifier */ &&
+ return name.kind === 69 /* Identifier */ &&
isTypeDeclaration(name.parent) &&
name.parent.name === name;
}
function isTypeDeclaration(node) {
switch (node.kind) {
- case 135 /* TypeParameter */:
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 214 /* TypeAliasDeclaration */:
- case 215 /* EnumDeclaration */:
+ case 137 /* TypeParameter */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
+ case 217 /* EnumDeclaration */:
return true;
}
}
// True if the given identifier is part of a type reference
function isTypeReferenceIdentifier(entityName) {
var node = entityName;
- while (node.parent && node.parent.kind === 133 /* QualifiedName */) {
+ while (node.parent && node.parent.kind === 135 /* QualifiedName */) {
node = node.parent;
}
- return node.parent && node.parent.kind === 149 /* TypeReference */;
+ return node.parent && node.parent.kind === 151 /* TypeReference */;
}
function isHeritageClauseElementIdentifier(entityName) {
var node = entityName;
- while (node.parent && node.parent.kind === 164 /* PropertyAccessExpression */) {
+ while (node.parent && node.parent.kind === 166 /* PropertyAccessExpression */) {
node = node.parent;
}
- return node.parent && node.parent.kind === 186 /* ExpressionWithTypeArguments */;
+ return node.parent && node.parent.kind === 188 /* ExpressionWithTypeArguments */;
}
function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) {
- while (nodeOnRightSide.parent.kind === 133 /* QualifiedName */) {
+ while (nodeOnRightSide.parent.kind === 135 /* QualifiedName */) {
nodeOnRightSide = nodeOnRightSide.parent;
}
- if (nodeOnRightSide.parent.kind === 219 /* ImportEqualsDeclaration */) {
+ if (nodeOnRightSide.parent.kind === 221 /* ImportEqualsDeclaration */) {
return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent;
}
- if (nodeOnRightSide.parent.kind === 225 /* ExportAssignment */) {
+ if (nodeOnRightSide.parent.kind === 227 /* ExportAssignment */) {
return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent;
}
return undefined;
@@ -25437,11 +26160,11 @@ var ts;
if (ts.isDeclarationName(entityName)) {
return getSymbolOfNode(entityName.parent);
}
- if (entityName.parent.kind === 225 /* ExportAssignment */) {
+ if (entityName.parent.kind === 227 /* ExportAssignment */) {
return resolveEntityName(entityName,
/*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */);
}
- if (entityName.kind !== 164 /* PropertyAccessExpression */) {
+ if (entityName.kind !== 166 /* PropertyAccessExpression */) {
if (isInRightSideOfImportOrExportAssignment(entityName)) {
// Since we already checked for ExportAssignment, this really could only be an Import
return getSymbolOfPartOfRightHandSideOfImportEquals(entityName);
@@ -25451,13 +26174,24 @@ var ts;
entityName = entityName.parent;
}
if (isHeritageClauseElementIdentifier(entityName)) {
- var meaning = entityName.parent.kind === 186 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */;
+ var meaning = 0 /* None */;
+ // In an interface or class, we're definitely interested in a type.
+ if (entityName.parent.kind === 188 /* ExpressionWithTypeArguments */) {
+ meaning = 793056 /* Type */;
+ // In a class 'extends' clause we are also looking for a value.
+ if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) {
+ meaning |= 107455 /* Value */;
+ }
+ }
+ else {
+ meaning = 1536 /* Namespace */;
+ }
meaning |= 8388608 /* Alias */;
return resolveEntityName(entityName, meaning);
}
- else if ((entityName.parent.kind === 233 /* JsxOpeningElement */) ||
- (entityName.parent.kind === 232 /* JsxSelfClosingElement */) ||
- (entityName.parent.kind === 235 /* JsxClosingElement */)) {
+ else if ((entityName.parent.kind === 235 /* JsxOpeningElement */) ||
+ (entityName.parent.kind === 234 /* JsxSelfClosingElement */) ||
+ (entityName.parent.kind === 237 /* JsxClosingElement */)) {
return getJsxElementTagSymbol(entityName.parent);
}
else if (ts.isExpression(entityName)) {
@@ -25465,20 +26199,20 @@ var ts;
// Missing entity name.
return undefined;
}
- if (entityName.kind === 67 /* Identifier */) {
+ if (entityName.kind === 69 /* Identifier */) {
// Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead
// return the alias symbol.
var meaning = 107455 /* Value */ | 8388608 /* Alias */;
return resolveEntityName(entityName, meaning);
}
- else if (entityName.kind === 164 /* PropertyAccessExpression */) {
+ else if (entityName.kind === 166 /* PropertyAccessExpression */) {
var symbol = getNodeLinks(entityName).resolvedSymbol;
if (!symbol) {
checkPropertyAccessExpression(entityName);
}
return getNodeLinks(entityName).resolvedSymbol;
}
- else if (entityName.kind === 133 /* QualifiedName */) {
+ else if (entityName.kind === 135 /* QualifiedName */) {
var symbol = getNodeLinks(entityName).resolvedSymbol;
if (!symbol) {
checkQualifiedName(entityName);
@@ -25487,16 +26221,16 @@ var ts;
}
}
else if (isTypeReferenceIdentifier(entityName)) {
- var meaning = entityName.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */;
+ var meaning = entityName.parent.kind === 151 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */;
// Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead
// return the alias symbol.
meaning |= 8388608 /* Alias */;
return resolveEntityName(entityName, meaning);
}
- else if (entityName.parent.kind === 236 /* JsxAttribute */) {
+ else if (entityName.parent.kind === 238 /* JsxAttribute */) {
return getJsxAttributePropertySymbol(entityName.parent);
}
- if (entityName.parent.kind === 148 /* TypePredicate */) {
+ if (entityName.parent.kind === 150 /* TypePredicate */) {
return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */);
}
// Do we want to return undefined here?
@@ -25511,14 +26245,14 @@ var ts;
// This is a declaration, call getSymbolOfNode
return getSymbolOfNode(node.parent);
}
- if (node.kind === 67 /* Identifier */) {
+ if (node.kind === 69 /* Identifier */) {
if (isInRightSideOfImportOrExportAssignment(node)) {
- return node.parent.kind === 225 /* ExportAssignment */
+ return node.parent.kind === 227 /* ExportAssignment */
? getSymbolOfEntityNameOrPropertyAccessExpression(node)
: getSymbolOfPartOfRightHandSideOfImportEquals(node);
}
- else if (node.parent.kind === 161 /* BindingElement */ &&
- node.parent.parent.kind === 159 /* ObjectBindingPattern */ &&
+ else if (node.parent.kind === 163 /* BindingElement */ &&
+ node.parent.parent.kind === 161 /* ObjectBindingPattern */ &&
node === node.parent.propertyName) {
var typeOfPattern = getTypeOfNode(node.parent.parent);
var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text);
@@ -25528,18 +26262,18 @@ var ts;
}
}
switch (node.kind) {
- case 67 /* Identifier */:
- case 164 /* PropertyAccessExpression */:
- case 133 /* QualifiedName */:
+ case 69 /* Identifier */:
+ case 166 /* PropertyAccessExpression */:
+ case 135 /* QualifiedName */:
return getSymbolOfEntityNameOrPropertyAccessExpression(node);
- case 95 /* ThisKeyword */:
- case 93 /* SuperKeyword */:
- var type = checkExpression(node);
+ case 97 /* ThisKeyword */:
+ case 95 /* SuperKeyword */:
+ var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node);
return type.symbol;
- case 119 /* ConstructorKeyword */:
+ case 121 /* ConstructorKeyword */:
// constructor keyword for an overload, should take us to the definition if it exist
var constructorDeclaration = node.parent;
- if (constructorDeclaration && constructorDeclaration.kind === 142 /* Constructor */) {
+ if (constructorDeclaration && constructorDeclaration.kind === 144 /* Constructor */) {
return constructorDeclaration.parent.symbol;
}
return undefined;
@@ -25547,14 +26281,14 @@ var ts;
// External module name in an import declaration
if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) &&
ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
- ((node.parent.kind === 220 /* ImportDeclaration */ || node.parent.kind === 226 /* ExportDeclaration */) &&
+ ((node.parent.kind === 222 /* ImportDeclaration */ || node.parent.kind === 228 /* ExportDeclaration */) &&
node.parent.moduleSpecifier === node)) {
return resolveExternalModuleName(node, node);
}
// Fall through
case 8 /* NumericLiteral */:
// index access
- if (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node) {
+ if (node.parent.kind === 167 /* ElementAccessExpression */ && node.parent.argumentExpression === node) {
var objectType = checkExpression(node.parent.expression);
if (objectType === unknownType)
return undefined;
@@ -25571,7 +26305,7 @@ var ts;
// The function returns a value symbol of an identifier in the short-hand property assignment.
// This is necessary as an identifier in short-hand property assignment can contains two meaning:
// property name and property value.
- if (location && location.kind === 244 /* ShorthandPropertyAssignment */) {
+ if (location && location.kind === 246 /* ShorthandPropertyAssignment */) {
return resolveEntityName(location.name, 107455 /* Value */);
}
return undefined;
@@ -25688,11 +26422,11 @@ var ts;
}
var parentSymbol = getParentOfSymbol(symbol);
if (parentSymbol) {
- if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 246 /* SourceFile */) {
+ if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 248 /* SourceFile */) {
return parentSymbol.valueDeclaration;
}
for (var n = node.parent; n; n = n.parent) {
- if ((n.kind === 216 /* ModuleDeclaration */ || n.kind === 215 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) {
+ if ((n.kind === 218 /* ModuleDeclaration */ || n.kind === 217 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) {
return n;
}
}
@@ -25707,11 +26441,11 @@ var ts;
}
function isStatementWithLocals(node) {
switch (node.kind) {
- case 190 /* Block */:
- case 218 /* CaseBlock */:
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
+ case 192 /* Block */:
+ case 220 /* CaseBlock */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
return true;
}
return false;
@@ -25741,22 +26475,22 @@ var ts;
}
function isValueAliasDeclaration(node) {
switch (node.kind) {
- case 219 /* ImportEqualsDeclaration */:
- case 221 /* ImportClause */:
- case 222 /* NamespaceImport */:
- case 224 /* ImportSpecifier */:
- case 228 /* ExportSpecifier */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 223 /* ImportClause */:
+ case 224 /* NamespaceImport */:
+ case 226 /* ImportSpecifier */:
+ case 230 /* ExportSpecifier */:
return isAliasResolvedToValue(getSymbolOfNode(node));
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
var exportClause = node.exportClause;
return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration);
- case 225 /* ExportAssignment */:
- return node.expression && node.expression.kind === 67 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true;
+ case 227 /* ExportAssignment */:
+ return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true;
}
return false;
}
function isTopLevelValueImportEqualsWithEntityName(node) {
- if (node.parent.kind !== 246 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) {
+ if (node.parent.kind !== 248 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) {
// parent is not source file or it is not reference to internal module
return false;
}
@@ -25818,7 +26552,7 @@ var ts;
return getNodeLinks(node).enumMemberValue;
}
function getConstantValue(node) {
- if (node.kind === 245 /* EnumMember */) {
+ if (node.kind === 247 /* EnumMember */) {
return getEnumMemberValue(node);
}
var symbol = getNodeLinks(node).resolvedSymbol;
@@ -25910,23 +26644,6 @@ var ts;
var symbol = getReferencedValueSymbol(reference);
return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
}
- function getBlockScopedVariableId(n) {
- ts.Debug.assert(!ts.nodeIsSynthesized(n));
- var isVariableDeclarationOrBindingElement = n.parent.kind === 161 /* BindingElement */ || (n.parent.kind === 209 /* VariableDeclaration */ && n.parent.name === n);
- var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) ||
- getNodeLinks(n).resolvedSymbol ||
- resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);
- var isLetOrConst = symbol &&
- (symbol.flags & 2 /* BlockScopedVariable */) &&
- symbol.valueDeclaration.parent.kind !== 242 /* CatchClause */;
- if (isLetOrConst) {
- // side-effect of calling this method:
- // assign id to symbol if it was not yet set
- getSymbolLinks(symbol);
- return symbol.id;
- }
- return undefined;
- }
function instantiateSingleCallFunctionType(functionType, typeArguments) {
if (functionType === unknownType) {
return unknownType;
@@ -25958,7 +26675,6 @@ var ts;
isEntityNameVisible: isEntityNameVisible,
getConstantValue: getConstantValue,
collectLinkedAliases: collectLinkedAliases,
- getBlockScopedVariableId: getBlockScopedVariableId,
getReferencedValueDeclaration: getReferencedValueDeclaration,
getTypeReferenceSerializationKind: getTypeReferenceSerializationKind,
isOptionalParameter: isOptionalParameter
@@ -26050,10 +26766,7 @@ var ts;
if (!ts.nodeCanBeDecorated(node)) {
return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here);
}
- else if (languageVersion < 1 /* ES5 */) {
- return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher);
- }
- else if (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */) {
+ else if (node.kind === 145 /* GetAccessor */ || node.kind === 146 /* SetAccessor */) {
var accessors = ts.getAllAccessorDeclarations(node.parent.members, node);
if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
@@ -26063,38 +26776,38 @@ var ts;
}
function checkGrammarModifiers(node) {
switch (node.kind) {
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 142 /* Constructor */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 147 /* IndexSignature */:
- case 216 /* ModuleDeclaration */:
- case 220 /* ImportDeclaration */:
- case 219 /* ImportEqualsDeclaration */:
- case 226 /* ExportDeclaration */:
- case 225 /* ExportAssignment */:
- case 136 /* Parameter */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 144 /* Constructor */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 149 /* IndexSignature */:
+ case 218 /* ModuleDeclaration */:
+ case 222 /* ImportDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 228 /* ExportDeclaration */:
+ case 227 /* ExportAssignment */:
+ case 138 /* Parameter */:
break;
- case 211 /* FunctionDeclaration */:
- if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116 /* AsyncKeyword */) &&
- node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) {
+ case 213 /* FunctionDeclaration */:
+ if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) &&
+ node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) {
return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
}
break;
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 191 /* VariableStatement */:
- case 214 /* TypeAliasDeclaration */:
- if (node.modifiers && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) {
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 193 /* VariableStatement */:
+ case 216 /* TypeAliasDeclaration */:
+ if (node.modifiers && node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) {
return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
}
break;
- case 215 /* EnumDeclaration */:
- if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72 /* ConstKeyword */) &&
- node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) {
+ case 217 /* EnumDeclaration */:
+ if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) &&
+ node.parent.kind !== 219 /* ModuleBlock */ && node.parent.kind !== 248 /* SourceFile */) {
return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
}
break;
@@ -26109,14 +26822,14 @@ var ts;
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
var modifier = _a[_i];
switch (modifier.kind) {
- case 110 /* PublicKeyword */:
- case 109 /* ProtectedKeyword */:
- case 108 /* PrivateKeyword */:
+ case 112 /* PublicKeyword */:
+ case 111 /* ProtectedKeyword */:
+ case 110 /* PrivateKeyword */:
var text = void 0;
- if (modifier.kind === 110 /* PublicKeyword */) {
+ if (modifier.kind === 112 /* PublicKeyword */) {
text = "public";
}
- else if (modifier.kind === 109 /* ProtectedKeyword */) {
+ else if (modifier.kind === 111 /* ProtectedKeyword */) {
text = "protected";
lastProtected = modifier;
}
@@ -26133,11 +26846,11 @@ var ts;
else if (flags & 512 /* Async */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async");
}
- else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) {
+ else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text);
}
else if (flags & 256 /* Abstract */) {
- if (modifier.kind === 108 /* PrivateKeyword */) {
+ if (modifier.kind === 110 /* PrivateKeyword */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract");
}
else {
@@ -26146,17 +26859,17 @@ var ts;
}
flags |= ts.modifierToFlag(modifier.kind);
break;
- case 111 /* StaticKeyword */:
+ case 113 /* StaticKeyword */:
if (flags & 128 /* Static */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
}
else if (flags & 512 /* Async */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
}
- else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) {
+ else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static");
}
- else if (node.kind === 136 /* Parameter */) {
+ else if (node.kind === 138 /* Parameter */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
}
else if (flags & 256 /* Abstract */) {
@@ -26165,7 +26878,7 @@ var ts;
flags |= 128 /* Static */;
lastStatic = modifier;
break;
- case 80 /* ExportKeyword */:
+ case 82 /* ExportKeyword */:
if (flags & 1 /* Export */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export");
}
@@ -26178,42 +26891,42 @@ var ts;
else if (flags & 512 /* Async */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
}
- else if (node.parent.kind === 212 /* ClassDeclaration */) {
+ else if (node.parent.kind === 214 /* ClassDeclaration */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export");
}
- else if (node.kind === 136 /* Parameter */) {
+ else if (node.kind === 138 /* Parameter */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
}
flags |= 1 /* Export */;
break;
- case 120 /* DeclareKeyword */:
+ case 122 /* DeclareKeyword */:
if (flags & 2 /* Ambient */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare");
}
else if (flags & 512 /* Async */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
}
- else if (node.parent.kind === 212 /* ClassDeclaration */) {
+ else if (node.parent.kind === 214 /* ClassDeclaration */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
}
- else if (node.kind === 136 /* Parameter */) {
+ else if (node.kind === 138 /* Parameter */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
}
- else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217 /* ModuleBlock */) {
+ else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) {
return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
}
flags |= 2 /* Ambient */;
lastDeclare = modifier;
break;
- case 113 /* AbstractKeyword */:
+ case 115 /* AbstractKeyword */:
if (flags & 256 /* Abstract */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract");
}
- if (node.kind !== 212 /* ClassDeclaration */) {
- if (node.kind !== 141 /* MethodDeclaration */) {
+ if (node.kind !== 214 /* ClassDeclaration */) {
+ if (node.kind !== 143 /* MethodDeclaration */) {
return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration);
}
- if (!(node.parent.kind === 212 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) {
+ if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) {
return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
}
if (flags & 128 /* Static */) {
@@ -26225,14 +26938,14 @@ var ts;
}
flags |= 256 /* Abstract */;
break;
- case 116 /* AsyncKeyword */:
+ case 118 /* AsyncKeyword */:
if (flags & 512 /* Async */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
}
else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
}
- else if (node.kind === 136 /* Parameter */) {
+ else if (node.kind === 138 /* Parameter */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async");
}
flags |= 512 /* Async */;
@@ -26240,7 +26953,7 @@ var ts;
break;
}
}
- if (node.kind === 142 /* Constructor */) {
+ if (node.kind === 144 /* Constructor */) {
if (flags & 128 /* Static */) {
return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
}
@@ -26258,10 +26971,10 @@ var ts;
}
return;
}
- else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) {
+ else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) {
return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare");
}
- else if (node.kind === 136 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) {
+ else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) {
return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern);
}
if (flags & 512 /* Async */) {
@@ -26273,10 +26986,10 @@ var ts;
return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher);
}
switch (node.kind) {
- case 141 /* MethodDeclaration */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
+ case 143 /* MethodDeclaration */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
if (!node.asteriskToken) {
return false;
}
@@ -26342,7 +27055,7 @@ var ts;
checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file);
}
function checkGrammarArrowFunction(node, file) {
- if (node.kind === 172 /* ArrowFunction */) {
+ if (node.kind === 174 /* ArrowFunction */) {
var arrowFunction = node;
var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line;
var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line;
@@ -26377,7 +27090,7 @@ var ts;
if (!parameter.type) {
return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
}
- if (parameter.type.kind !== 128 /* StringKeyword */ && parameter.type.kind !== 126 /* NumberKeyword */) {
+ if (parameter.type.kind !== 130 /* StringKeyword */ && parameter.type.kind !== 128 /* NumberKeyword */) {
return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number);
}
if (!node.type) {
@@ -26410,7 +27123,7 @@ var ts;
var sourceFile = ts.getSourceFileOfNode(node);
for (var _i = 0; _i < args.length; _i++) {
var arg = args[_i];
- if (arg.kind === 185 /* OmittedExpression */) {
+ if (arg.kind === 187 /* OmittedExpression */) {
return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected);
}
}
@@ -26437,7 +27150,7 @@ var ts;
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) {
for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
var heritageClause = _a[_i];
- if (heritageClause.token === 81 /* ExtendsKeyword */) {
+ if (heritageClause.token === 83 /* ExtendsKeyword */) {
if (seenExtendsClause) {
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
}
@@ -26450,7 +27163,7 @@ var ts;
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */);
+ ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */);
if (seenImplementsClause) {
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
}
@@ -26466,14 +27179,14 @@ var ts;
if (node.heritageClauses) {
for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
var heritageClause = _a[_i];
- if (heritageClause.token === 81 /* ExtendsKeyword */) {
+ if (heritageClause.token === 83 /* ExtendsKeyword */) {
if (seenExtendsClause) {
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
}
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */);
+ ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */);
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
}
// Grammar checking heritageClause inside class declaration
@@ -26484,19 +27197,19 @@ var ts;
}
function checkGrammarComputedPropertyName(node) {
// If node is not a computedPropertyName, just skip the grammar checking
- if (node.kind !== 134 /* ComputedPropertyName */) {
+ if (node.kind !== 136 /* ComputedPropertyName */) {
return false;
}
var computedPropertyName = node;
- if (computedPropertyName.expression.kind === 179 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) {
+ if (computedPropertyName.expression.kind === 181 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) {
return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
}
}
function checkGrammarForGenerator(node) {
if (node.asteriskToken) {
- ts.Debug.assert(node.kind === 211 /* FunctionDeclaration */ ||
- node.kind === 171 /* FunctionExpression */ ||
- node.kind === 141 /* MethodDeclaration */);
+ ts.Debug.assert(node.kind === 213 /* FunctionDeclaration */ ||
+ node.kind === 173 /* FunctionExpression */ ||
+ node.kind === 143 /* MethodDeclaration */);
if (ts.isInAmbientContext(node)) {
return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
}
@@ -26513,7 +27226,7 @@ var ts;
return grammarErrorOnNode(questionToken, message);
}
}
- function checkGrammarObjectLiteralExpression(node) {
+ function checkGrammarObjectLiteralExpression(node, inDestructuring) {
var seen = {};
var Property = 1;
var GetAccessor = 2;
@@ -26522,12 +27235,17 @@ var ts;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var prop = _a[_i];
var name_16 = prop.name;
- if (prop.kind === 185 /* OmittedExpression */ ||
- name_16.kind === 134 /* ComputedPropertyName */) {
+ if (prop.kind === 187 /* OmittedExpression */ ||
+ name_16.kind === 136 /* ComputedPropertyName */) {
// If the name is not a ComputedPropertyName, the grammar checking will skip it
checkGrammarComputedPropertyName(name_16);
continue;
}
+ if (prop.kind === 246 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) {
+ // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern
+ // outside of destructuring it is a syntax error
+ return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment);
+ }
// 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
@@ -26537,7 +27255,7 @@ var ts;
// 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 = void 0;
- if (prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */) {
+ if (prop.kind === 245 /* PropertyAssignment */ || prop.kind === 246 /* ShorthandPropertyAssignment */) {
// Grammar checking for computedPropertName and shorthandPropertyAssignment
checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
if (name_16.kind === 8 /* NumericLiteral */) {
@@ -26545,13 +27263,13 @@ var ts;
}
currentKind = Property;
}
- else if (prop.kind === 141 /* MethodDeclaration */) {
+ else if (prop.kind === 143 /* MethodDeclaration */) {
currentKind = Property;
}
- else if (prop.kind === 143 /* GetAccessor */) {
+ else if (prop.kind === 145 /* GetAccessor */) {
currentKind = GetAccessor;
}
- else if (prop.kind === 144 /* SetAccessor */) {
+ else if (prop.kind === 146 /* SetAccessor */) {
currentKind = SetAccesor;
}
else {
@@ -26583,7 +27301,7 @@ var ts;
var seen = {};
for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) {
var attr = _a[_i];
- if (attr.kind === 237 /* JsxSpreadAttribute */) {
+ if (attr.kind === 239 /* JsxSpreadAttribute */) {
continue;
}
var jsxAttr = attr;
@@ -26595,7 +27313,7 @@ var ts;
return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name);
}
var initializer = jsxAttr.initializer;
- if (initializer && initializer.kind === 238 /* JsxExpression */ && !initializer.expression) {
+ if (initializer && initializer.kind === 240 /* JsxExpression */ && !initializer.expression) {
return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression);
}
}
@@ -26604,24 +27322,24 @@ var ts;
if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) {
return true;
}
- if (forInOrOfStatement.initializer.kind === 210 /* VariableDeclarationList */) {
+ if (forInOrOfStatement.initializer.kind === 212 /* VariableDeclarationList */) {
var variableList = forInOrOfStatement.initializer;
if (!checkGrammarVariableDeclarationList(variableList)) {
if (variableList.declarations.length > 1) {
- var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */
+ var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */
? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement
: ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic);
}
var firstDeclaration = variableList.declarations[0];
if (firstDeclaration.initializer) {
- var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */
+ var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */
? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer
: ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer;
return grammarErrorOnNode(firstDeclaration.name, diagnostic);
}
if (firstDeclaration.type) {
- var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */
+ var diagnostic = forInOrOfStatement.kind === 200 /* ForInStatement */
? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation
: ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation;
return grammarErrorOnNode(firstDeclaration, diagnostic);
@@ -26644,10 +27362,10 @@ var ts;
else if (accessor.typeParameters) {
return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters);
}
- else if (kind === 143 /* GetAccessor */ && accessor.parameters.length) {
+ else if (kind === 145 /* GetAccessor */ && accessor.parameters.length) {
return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters);
}
- else if (kind === 144 /* SetAccessor */) {
+ else if (kind === 146 /* SetAccessor */) {
if (accessor.type) {
return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
}
@@ -26672,7 +27390,7 @@ var ts;
}
}
function checkGrammarForNonSymbolComputedProperty(node, message) {
- if (node.kind === 134 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) {
+ if (node.kind === 136 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) {
return grammarErrorOnNode(node, message);
}
}
@@ -26682,7 +27400,7 @@ var ts;
checkGrammarForGenerator(node)) {
return true;
}
- if (node.parent.kind === 163 /* ObjectLiteralExpression */) {
+ if (node.parent.kind === 165 /* ObjectLiteralExpression */) {
if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) {
return true;
}
@@ -26706,22 +27424,22 @@ var ts;
return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol);
}
}
- else if (node.parent.kind === 213 /* InterfaceDeclaration */) {
+ else if (node.parent.kind === 215 /* InterfaceDeclaration */) {
return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol);
}
- else if (node.parent.kind === 153 /* TypeLiteral */) {
+ else if (node.parent.kind === 155 /* TypeLiteral */) {
return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol);
}
}
function isIterationStatement(node, lookInLabeledStatements) {
switch (node.kind) {
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 195 /* DoStatement */:
- case 196 /* WhileStatement */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 197 /* DoStatement */:
+ case 198 /* WhileStatement */:
return true;
- case 205 /* LabeledStatement */:
+ case 207 /* LabeledStatement */:
return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
}
return false;
@@ -26733,11 +27451,11 @@ var ts;
return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary);
}
switch (current.kind) {
- case 205 /* LabeledStatement */:
+ case 207 /* LabeledStatement */:
if (node.label && current.label.text === node.label.text) {
// found matching label - verify that label usage is correct
// continue can only target labels that are on iteration statements
- var isMisplacedContinueLabel = node.kind === 200 /* ContinueStatement */
+ var isMisplacedContinueLabel = node.kind === 202 /* ContinueStatement */
&& !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true);
if (isMisplacedContinueLabel) {
return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
@@ -26745,8 +27463,8 @@ var ts;
return false;
}
break;
- case 204 /* SwitchStatement */:
- if (node.kind === 201 /* BreakStatement */ && !node.label) {
+ case 206 /* SwitchStatement */:
+ if (node.kind === 203 /* BreakStatement */ && !node.label) {
// unlabeled break within switch statement - ok
return false;
}
@@ -26761,13 +27479,13 @@ var ts;
current = current.parent;
}
if (node.label) {
- var message = node.kind === 201 /* BreakStatement */
+ var message = node.kind === 203 /* BreakStatement */
? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement
: ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
return grammarErrorOnNode(node, message);
}
else {
- var message = node.kind === 201 /* BreakStatement */
+ var message = node.kind === 203 /* BreakStatement */
? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement
: ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
return grammarErrorOnNode(node, message);
@@ -26779,7 +27497,7 @@ var ts;
if (node !== ts.lastOrUndefined(elements)) {
return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
}
- if (node.name.kind === 160 /* ArrayBindingPattern */ || node.name.kind === 159 /* ObjectBindingPattern */) {
+ if (node.name.kind === 162 /* ArrayBindingPattern */ || node.name.kind === 161 /* ObjectBindingPattern */) {
return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
}
if (node.initializer) {
@@ -26789,7 +27507,7 @@ var ts;
}
}
function checkGrammarVariableDeclaration(node) {
- if (node.parent.parent.kind !== 198 /* ForInStatement */ && node.parent.parent.kind !== 199 /* ForOfStatement */) {
+ if (node.parent.parent.kind !== 200 /* ForInStatement */ && node.parent.parent.kind !== 201 /* ForOfStatement */) {
if (ts.isInAmbientContext(node)) {
if (node.initializer) {
// Error on equals token which immediate precedes the initializer
@@ -26816,7 +27534,7 @@ var ts;
return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name);
}
function checkGrammarNameInLetOrConstDeclarations(name) {
- if (name.kind === 67 /* Identifier */) {
+ if (name.kind === 69 /* Identifier */) {
if (name.text === "let") {
return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations);
}
@@ -26825,7 +27543,7 @@ var ts;
var elements = name.elements;
for (var _i = 0; _i < elements.length; _i++) {
var element = elements[_i];
- if (element.kind !== 185 /* OmittedExpression */) {
+ if (element.kind !== 187 /* OmittedExpression */) {
checkGrammarNameInLetOrConstDeclarations(element.name);
}
}
@@ -26842,15 +27560,15 @@ var ts;
}
function allowLetAndConstDeclarations(parent) {
switch (parent.kind) {
- case 194 /* IfStatement */:
- case 195 /* DoStatement */:
- case 196 /* WhileStatement */:
- case 203 /* WithStatement */:
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
+ case 196 /* IfStatement */:
+ case 197 /* DoStatement */:
+ case 198 /* WhileStatement */:
+ case 205 /* WithStatement */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
return false;
- case 205 /* LabeledStatement */:
+ case 207 /* LabeledStatement */:
return allowLetAndConstDeclarations(parent.parent);
}
return true;
@@ -26866,7 +27584,7 @@ var ts;
}
}
function isIntegerLiteral(expression) {
- if (expression.kind === 177 /* PrefixUnaryExpression */) {
+ if (expression.kind === 179 /* PrefixUnaryExpression */) {
var unaryExpression = expression;
if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) {
expression = unaryExpression.operand;
@@ -26882,37 +27600,6 @@ var ts;
}
return false;
}
- function checkGrammarEnumDeclaration(enumDecl) {
- var enumIsConst = (enumDecl.flags & 32768 /* Const */) !== 0;
- var hasError = false;
- // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions.
- // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members.
- if (!enumIsConst) {
- var inConstantEnumMemberSection = true;
- var inAmbientContext = ts.isInAmbientContext(enumDecl);
- for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) {
- var node = _a[_i];
- // Do not use hasDynamicName here, because that returns false for well known symbols.
- // We want to perform checkComputedPropertyName for all computed properties, including
- // well known symbols.
- if (node.name.kind === 134 /* ComputedPropertyName */) {
- hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums);
- }
- else if (inAmbientContext) {
- if (node.initializer && !isIntegerLiteral(node.initializer)) {
- hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError;
- }
- }
- else if (node.initializer) {
- inConstantEnumMemberSection = isIntegerLiteral(node.initializer);
- }
- else if (!inConstantEnumMemberSection) {
- hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError;
- }
- }
- }
- return hasError;
- }
function hasParseDiagnostics(sourceFile) {
return sourceFile.parseDiagnostics.length > 0;
}
@@ -26938,7 +27625,7 @@ var ts;
}
}
function isEvalOrArgumentsIdentifier(node) {
- return node.kind === 67 /* Identifier */ &&
+ return node.kind === 69 /* Identifier */ &&
(node.text === "eval" || node.text === "arguments");
}
function checkGrammarConstructorTypeParameters(node) {
@@ -26958,12 +27645,12 @@ var ts;
return true;
}
}
- else if (node.parent.kind === 213 /* InterfaceDeclaration */) {
+ else if (node.parent.kind === 215 /* InterfaceDeclaration */) {
if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) {
return true;
}
}
- else if (node.parent.kind === 153 /* TypeLiteral */) {
+ else if (node.parent.kind === 155 /* TypeLiteral */) {
if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) {
return true;
}
@@ -26983,11 +27670,11 @@ var ts;
// export_opt ExternalImportDeclaration
// export_opt AmbientDeclaration
//
- if (node.kind === 213 /* InterfaceDeclaration */ ||
- node.kind === 220 /* ImportDeclaration */ ||
- node.kind === 219 /* ImportEqualsDeclaration */ ||
- node.kind === 226 /* ExportDeclaration */ ||
- node.kind === 225 /* ExportAssignment */ ||
+ if (node.kind === 215 /* InterfaceDeclaration */ ||
+ node.kind === 222 /* ImportDeclaration */ ||
+ node.kind === 221 /* ImportEqualsDeclaration */ ||
+ node.kind === 228 /* ExportDeclaration */ ||
+ node.kind === 227 /* ExportAssignment */ ||
(node.flags & 2 /* Ambient */) ||
(node.flags & (1 /* Export */ | 1024 /* Default */))) {
return false;
@@ -26997,7 +27684,7 @@ var ts;
function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) {
for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
var decl = _a[_i];
- if (ts.isDeclaration(decl) || decl.kind === 191 /* VariableStatement */) {
+ if (ts.isDeclaration(decl) || decl.kind === 193 /* VariableStatement */) {
if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) {
return true;
}
@@ -27023,7 +27710,7 @@ var ts;
// to prevent noisyness. So use a bit on the block to indicate if
// this has already been reported, and don't report if it has.
//
- if (node.parent.kind === 190 /* Block */ || node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) {
+ if (node.parent.kind === 192 /* Block */ || node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) {
var links_1 = getNodeLinks(node.parent);
// Check if the containing block ever report this error
if (!links_1.hasReportedStatementInAmbientContext) {
@@ -27074,6 +27761,7 @@ var ts;
var enclosingDeclaration;
var currentSourceFile;
var reportedDeclarationError = false;
+ var errorNameNode;
var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments;
var emit = compilerOptions.stripInternal ? stripInternal : emitNode;
var moduleElementDeclarationEmitInfo = [];
@@ -27105,7 +27793,7 @@ var ts;
var oldWriter = writer;
ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) {
if (aliasEmitInfo.isVisible) {
- ts.Debug.assert(aliasEmitInfo.node.kind === 220 /* ImportDeclaration */);
+ ts.Debug.assert(aliasEmitInfo.node.kind === 222 /* ImportDeclaration */);
createAndSetNewTextWriterWithSymbolWriter();
ts.Debug.assert(aliasEmitInfo.indent === 0);
writeImportDeclaration(aliasEmitInfo.node);
@@ -27159,6 +27847,7 @@ var ts;
function createAndSetNewTextWriterWithSymbolWriter() {
var writer = ts.createTextWriter(newLine);
writer.trackSymbol = trackSymbol;
+ writer.reportInaccessibleThisError = reportInaccessibleThisError;
writer.writeKeyword = writer.write;
writer.writeOperator = writer.write;
writer.writePunctuation = writer.write;
@@ -27181,10 +27870,10 @@ var ts;
var oldWriter = writer;
ts.forEach(nodes, function (declaration) {
var nodeToCheck;
- if (declaration.kind === 209 /* VariableDeclaration */) {
+ if (declaration.kind === 211 /* VariableDeclaration */) {
nodeToCheck = declaration.parent.parent;
}
- else if (declaration.kind === 223 /* NamedImports */ || declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 221 /* ImportClause */) {
+ else if (declaration.kind === 225 /* NamedImports */ || declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 223 /* ImportClause */) {
ts.Debug.fail("We should be getting ImportDeclaration instead to write");
}
else {
@@ -27202,7 +27891,7 @@ var ts;
// Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing,
// we would write alias foo declaration when we visit it since it would now be marked as visible
if (moduleElementEmitInfo) {
- if (moduleElementEmitInfo.node.kind === 220 /* ImportDeclaration */) {
+ if (moduleElementEmitInfo.node.kind === 222 /* ImportDeclaration */) {
// we have to create asynchronous output only after we have collected complete information
// because it is possible to enable multiple bindings as asynchronously visible
moduleElementEmitInfo.isVisible = true;
@@ -27212,12 +27901,12 @@ var ts;
for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) {
increaseIndent();
}
- if (nodeToCheck.kind === 216 /* ModuleDeclaration */) {
+ if (nodeToCheck.kind === 218 /* ModuleDeclaration */) {
ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined);
asynchronousSubModuleDeclarationEmitInfo = [];
}
writeModuleElement(nodeToCheck);
- if (nodeToCheck.kind === 216 /* ModuleDeclaration */) {
+ if (nodeToCheck.kind === 218 /* ModuleDeclaration */) {
moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo;
asynchronousSubModuleDeclarationEmitInfo = undefined;
}
@@ -27251,6 +27940,11 @@ var ts;
function trackSymbol(symbol, enclosingDeclaration, meaning) {
handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning));
}
+ function reportInaccessibleThisError() {
+ if (errorNameNode) {
+ diagnostics.push(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode)));
+ }
+ }
function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) {
writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic;
write(": ");
@@ -27259,7 +27953,9 @@ var ts;
emitType(type);
}
else {
+ errorNameNode = declaration.name;
resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
+ errorNameNode = undefined;
}
}
function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) {
@@ -27270,7 +27966,9 @@ var ts;
emitType(signature.type);
}
else {
+ errorNameNode = signature.name;
resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
+ errorNameNode = undefined;
}
}
function emitLines(nodes) {
@@ -27309,49 +28007,50 @@ var ts;
}
function emitType(type) {
switch (type.kind) {
- case 115 /* AnyKeyword */:
- case 128 /* StringKeyword */:
- case 126 /* NumberKeyword */:
- case 118 /* BooleanKeyword */:
- case 129 /* SymbolKeyword */:
- case 101 /* VoidKeyword */:
+ case 117 /* AnyKeyword */:
+ case 130 /* StringKeyword */:
+ case 128 /* NumberKeyword */:
+ case 120 /* BooleanKeyword */:
+ case 131 /* SymbolKeyword */:
+ case 103 /* VoidKeyword */:
+ case 97 /* ThisKeyword */:
case 9 /* StringLiteral */:
return writeTextOfNode(currentSourceFile, type);
- case 186 /* ExpressionWithTypeArguments */:
+ case 188 /* ExpressionWithTypeArguments */:
return emitExpressionWithTypeArguments(type);
- case 149 /* TypeReference */:
+ case 151 /* TypeReference */:
return emitTypeReference(type);
- case 152 /* TypeQuery */:
+ case 154 /* TypeQuery */:
return emitTypeQuery(type);
- case 154 /* ArrayType */:
+ case 156 /* ArrayType */:
return emitArrayType(type);
- case 155 /* TupleType */:
+ case 157 /* TupleType */:
return emitTupleType(type);
- case 156 /* UnionType */:
+ case 158 /* UnionType */:
return emitUnionType(type);
- case 157 /* IntersectionType */:
+ case 159 /* IntersectionType */:
return emitIntersectionType(type);
- case 158 /* ParenthesizedType */:
+ case 160 /* ParenthesizedType */:
return emitParenType(type);
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
return emitSignatureDeclarationWithJsDocComments(type);
- case 153 /* TypeLiteral */:
+ case 155 /* TypeLiteral */:
return emitTypeLiteral(type);
- case 67 /* Identifier */:
+ case 69 /* Identifier */:
return emitEntityName(type);
- case 133 /* QualifiedName */:
+ case 135 /* QualifiedName */:
return emitEntityName(type);
- case 148 /* TypePredicate */:
+ case 150 /* TypePredicate */:
return emitTypePredicate(type);
}
function writeEntityName(entityName) {
- if (entityName.kind === 67 /* Identifier */) {
+ if (entityName.kind === 69 /* Identifier */) {
writeTextOfNode(currentSourceFile, entityName);
}
else {
- var left = entityName.kind === 133 /* QualifiedName */ ? entityName.left : entityName.expression;
- var right = entityName.kind === 133 /* QualifiedName */ ? entityName.right : entityName.name;
+ var left = entityName.kind === 135 /* QualifiedName */ ? entityName.left : entityName.expression;
+ var right = entityName.kind === 135 /* QualifiedName */ ? entityName.right : entityName.name;
writeEntityName(left);
write(".");
writeTextOfNode(currentSourceFile, right);
@@ -27360,13 +28059,13 @@ var ts;
function emitEntityName(entityName) {
var visibilityResult = resolver.isEntityNameVisible(entityName,
// Aliases can be written asynchronously so use correct enclosing declaration
- entityName.parent.kind === 219 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration);
+ entityName.parent.kind === 221 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration);
handleSymbolAccessibilityError(visibilityResult);
writeEntityName(entityName);
}
function emitExpressionWithTypeArguments(node) {
if (ts.isSupportedExpressionWithTypeArguments(node)) {
- ts.Debug.assert(node.expression.kind === 67 /* Identifier */ || node.expression.kind === 164 /* PropertyAccessExpression */);
+ ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 166 /* PropertyAccessExpression */);
emitEntityName(node.expression);
if (node.typeArguments) {
write("<");
@@ -27447,7 +28146,7 @@ var ts;
}
}
function emitExportAssignment(node) {
- if (node.expression.kind === 67 /* Identifier */) {
+ if (node.expression.kind === 69 /* Identifier */) {
write(node.isExportEquals ? "export = " : "export default ");
writeTextOfNode(currentSourceFile, node.expression);
}
@@ -27467,7 +28166,7 @@ var ts;
write(";");
writeLine();
// Make all the declarations visible for the export name
- if (node.expression.kind === 67 /* Identifier */) {
+ if (node.expression.kind === 69 /* Identifier */) {
var nodes = resolver.collectLinkedAliases(node.expression);
// write each of these declarations asynchronously
writeAsynchronousModuleElements(nodes);
@@ -27486,10 +28185,10 @@ var ts;
if (isModuleElementVisible) {
writeModuleElement(node);
}
- else if (node.kind === 219 /* ImportEqualsDeclaration */ ||
- (node.parent.kind === 246 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) {
+ else if (node.kind === 221 /* ImportEqualsDeclaration */ ||
+ (node.parent.kind === 248 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) {
var isVisible;
- if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246 /* SourceFile */) {
+ if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 248 /* SourceFile */) {
// Import declaration of another module that is visited async so lets put it in right spot
asynchronousSubModuleDeclarationEmitInfo.push({
node: node,
@@ -27499,7 +28198,7 @@ var ts;
});
}
else {
- if (node.kind === 220 /* ImportDeclaration */) {
+ if (node.kind === 222 /* ImportDeclaration */) {
var importDeclaration = node;
if (importDeclaration.importClause) {
isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) ||
@@ -27517,23 +28216,23 @@ var ts;
}
function writeModuleElement(node) {
switch (node.kind) {
- case 211 /* FunctionDeclaration */:
+ case 213 /* FunctionDeclaration */:
return writeFunctionDeclaration(node);
- case 191 /* VariableStatement */:
+ case 193 /* VariableStatement */:
return writeVariableStatement(node);
- case 213 /* InterfaceDeclaration */:
+ case 215 /* InterfaceDeclaration */:
return writeInterfaceDeclaration(node);
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
return writeClassDeclaration(node);
- case 214 /* TypeAliasDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
return writeTypeAliasDeclaration(node);
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
return writeEnumDeclaration(node);
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
return writeModuleDeclaration(node);
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
return writeImportEqualsDeclaration(node);
- case 220 /* ImportDeclaration */:
+ case 222 /* ImportDeclaration */:
return writeImportDeclaration(node);
default:
ts.Debug.fail("Unknown symbol kind");
@@ -27549,7 +28248,7 @@ var ts;
if (node.flags & 1024 /* Default */) {
write("default ");
}
- else if (node.kind !== 213 /* InterfaceDeclaration */) {
+ else if (node.kind !== 215 /* InterfaceDeclaration */) {
write("declare ");
}
}
@@ -27598,7 +28297,7 @@ var ts;
}
function isVisibleNamedBinding(namedBindings) {
if (namedBindings) {
- if (namedBindings.kind === 222 /* NamespaceImport */) {
+ if (namedBindings.kind === 224 /* NamespaceImport */) {
return resolver.isDeclarationVisible(namedBindings);
}
else {
@@ -27626,7 +28325,7 @@ var ts;
// If the default binding was emitted, write the separated
write(", ");
}
- if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) {
+ if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) {
write("* as ");
writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name);
}
@@ -27684,7 +28383,7 @@ var ts;
write("module ");
}
writeTextOfNode(currentSourceFile, node.name);
- while (node.body.kind !== 217 /* ModuleBlock */) {
+ while (node.body.kind !== 219 /* ModuleBlock */) {
node = node.body;
write(".");
writeTextOfNode(currentSourceFile, node.name);
@@ -27749,7 +28448,7 @@ var ts;
writeLine();
}
function isPrivateMethodTypeParameter(node) {
- return node.parent.kind === 141 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */);
+ return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */);
}
function emitTypeParameters(typeParameters) {
function emitTypeParameter(node) {
@@ -27760,15 +28459,15 @@ var ts;
// If there is constraint present and this is not a type parameter of the private method emit the constraint
if (node.constraint && !isPrivateMethodTypeParameter(node)) {
write(" extends ");
- if (node.parent.kind === 150 /* FunctionType */ ||
- node.parent.kind === 151 /* ConstructorType */ ||
- (node.parent.parent && node.parent.parent.kind === 153 /* TypeLiteral */)) {
- ts.Debug.assert(node.parent.kind === 141 /* MethodDeclaration */ ||
- node.parent.kind === 140 /* MethodSignature */ ||
- node.parent.kind === 150 /* FunctionType */ ||
- node.parent.kind === 151 /* ConstructorType */ ||
- node.parent.kind === 145 /* CallSignature */ ||
- node.parent.kind === 146 /* ConstructSignature */);
+ if (node.parent.kind === 152 /* FunctionType */ ||
+ node.parent.kind === 153 /* ConstructorType */ ||
+ (node.parent.parent && node.parent.parent.kind === 155 /* TypeLiteral */)) {
+ ts.Debug.assert(node.parent.kind === 143 /* MethodDeclaration */ ||
+ node.parent.kind === 142 /* MethodSignature */ ||
+ node.parent.kind === 152 /* FunctionType */ ||
+ node.parent.kind === 153 /* ConstructorType */ ||
+ node.parent.kind === 147 /* CallSignature */ ||
+ node.parent.kind === 148 /* ConstructSignature */);
emitType(node.constraint);
}
else {
@@ -27779,31 +28478,31 @@ var ts;
// Type parameter constraints are named by user so we should always be able to name it
var diagnosticMessage;
switch (node.parent.kind) {
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
break;
- case 213 /* InterfaceDeclaration */:
+ case 215 /* InterfaceDeclaration */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
break;
- case 146 /* ConstructSignature */:
+ case 148 /* ConstructSignature */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
break;
- case 145 /* CallSignature */:
+ case 147 /* CallSignature */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
break;
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
if (node.parent.flags & 128 /* Static */) {
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
}
- else if (node.parent.parent.kind === 212 /* ClassDeclaration */) {
+ else if (node.parent.parent.kind === 214 /* ClassDeclaration */) {
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
}
else {
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
}
break;
- case 211 /* FunctionDeclaration */:
+ case 213 /* FunctionDeclaration */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
break;
default:
@@ -27831,13 +28530,13 @@ var ts;
if (ts.isSupportedExpressionWithTypeArguments(node)) {
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError);
}
- else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) {
+ else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) {
write("null");
}
function getHeritageClauseVisibilityError(symbolAccesibilityResult) {
var diagnosticMessage;
// Heritage clause is written by user so it can always be named
- if (node.parent.parent.kind === 212 /* ClassDeclaration */) {
+ if (node.parent.parent.kind === 214 /* ClassDeclaration */) {
// Class or Interface implemented/extended is inaccessible
diagnosticMessage = isImplementsList ?
ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
@@ -27921,7 +28620,7 @@ var ts;
function emitVariableDeclaration(node) {
// If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted
// so there is no check needed to see if declaration is visible
- if (node.kind !== 209 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) {
+ if (node.kind !== 211 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) {
if (ts.isBindingPattern(node.name)) {
emitBindingPattern(node.name);
}
@@ -27931,10 +28630,10 @@ var ts;
// what we want, namely the name expression enclosed in brackets.
writeTextOfNode(currentSourceFile, node.name);
// If optional property emit ?
- if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && ts.hasQuestionToken(node)) {
+ if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && ts.hasQuestionToken(node)) {
write("?");
}
- if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && node.parent.kind === 153 /* TypeLiteral */) {
+ if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) {
emitTypeOfVariableDeclarationFromTypeLiteral(node);
}
else if (!(node.flags & 32 /* Private */)) {
@@ -27943,14 +28642,14 @@ var ts;
}
}
function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) {
- if (node.kind === 209 /* VariableDeclaration */) {
+ if (node.kind === 211 /* VariableDeclaration */) {
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ?
ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
}
- else if (node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) {
+ else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) {
// TODO(jfreeman): Deal with computed properties in error reporting.
if (node.flags & 128 /* Static */) {
return symbolAccesibilityResult.errorModuleName ?
@@ -27959,7 +28658,7 @@ var ts;
ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
}
- else if (node.parent.kind === 212 /* ClassDeclaration */) {
+ else if (node.parent.kind === 214 /* ClassDeclaration */) {
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ?
ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
@@ -27991,7 +28690,7 @@ var ts;
var elements = [];
for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) {
var element = _a[_i];
- if (element.kind !== 185 /* OmittedExpression */) {
+ if (element.kind !== 187 /* OmittedExpression */) {
elements.push(element);
}
}
@@ -28061,7 +28760,7 @@ var ts;
var type = getTypeAnnotationFromAccessor(node);
if (!type) {
// couldn't get type for the first accessor, try the another one
- var anotherAccessor = node.kind === 143 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor;
+ var anotherAccessor = node.kind === 145 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor;
type = getTypeAnnotationFromAccessor(anotherAccessor);
if (type) {
accessorWithTypeAnnotation = anotherAccessor;
@@ -28074,7 +28773,7 @@ var ts;
}
function getTypeAnnotationFromAccessor(accessor) {
if (accessor) {
- return accessor.kind === 143 /* GetAccessor */
+ return accessor.kind === 145 /* GetAccessor */
? accessor.type // Getter - return type
: accessor.parameters.length > 0
? accessor.parameters[0].type // Setter parameter type
@@ -28083,7 +28782,7 @@ var ts;
}
function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) {
var diagnosticMessage;
- if (accessorWithTypeAnnotation.kind === 144 /* SetAccessor */) {
+ if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) {
// Setters have to have type named and cannot infer it so, the type should always be named
if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
@@ -28133,17 +28832,17 @@ var ts;
// so no need to verify if the declaration is visible
if (!resolver.isImplementationOfOverload(node)) {
emitJsDocComments(node);
- if (node.kind === 211 /* FunctionDeclaration */) {
+ if (node.kind === 213 /* FunctionDeclaration */) {
emitModuleElementDeclarationFlags(node);
}
- else if (node.kind === 141 /* MethodDeclaration */) {
+ else if (node.kind === 143 /* MethodDeclaration */) {
emitClassMemberDeclarationFlags(node);
}
- if (node.kind === 211 /* FunctionDeclaration */) {
+ if (node.kind === 213 /* FunctionDeclaration */) {
write("function ");
writeTextOfNode(currentSourceFile, node.name);
}
- else if (node.kind === 142 /* Constructor */) {
+ else if (node.kind === 144 /* Constructor */) {
write("constructor");
}
else {
@@ -28161,11 +28860,11 @@ var ts;
}
function emitSignatureDeclaration(node) {
// Construct signature or constructor type write new Signature
- if (node.kind === 146 /* ConstructSignature */ || node.kind === 151 /* ConstructorType */) {
+ if (node.kind === 148 /* ConstructSignature */ || node.kind === 153 /* ConstructorType */) {
write("new ");
}
emitTypeParameters(node.typeParameters);
- if (node.kind === 147 /* IndexSignature */) {
+ if (node.kind === 149 /* IndexSignature */) {
write("[");
}
else {
@@ -28175,22 +28874,22 @@ var ts;
enclosingDeclaration = node;
// Parameters
emitCommaList(node.parameters, emitParameterDeclaration);
- if (node.kind === 147 /* IndexSignature */) {
+ if (node.kind === 149 /* IndexSignature */) {
write("]");
}
else {
write(")");
}
// If this is not a constructor and is not private, emit the return type
- var isFunctionTypeOrConstructorType = node.kind === 150 /* FunctionType */ || node.kind === 151 /* ConstructorType */;
- if (isFunctionTypeOrConstructorType || node.parent.kind === 153 /* TypeLiteral */) {
+ var isFunctionTypeOrConstructorType = node.kind === 152 /* FunctionType */ || node.kind === 153 /* ConstructorType */;
+ if (isFunctionTypeOrConstructorType || node.parent.kind === 155 /* TypeLiteral */) {
// Emit type literal signature return type only if specified
if (node.type) {
write(isFunctionTypeOrConstructorType ? " => " : ": ");
emitType(node.type);
}
}
- else if (node.kind !== 142 /* Constructor */ && !(node.flags & 32 /* Private */)) {
+ else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) {
writeReturnTypeAtSignature(node, getReturnTypeVisibilityError);
}
enclosingDeclaration = prevEnclosingDeclaration;
@@ -28201,26 +28900,26 @@ var ts;
function getReturnTypeVisibilityError(symbolAccesibilityResult) {
var diagnosticMessage;
switch (node.kind) {
- case 146 /* ConstructSignature */:
+ case 148 /* ConstructSignature */:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
- case 145 /* CallSignature */:
+ case 147 /* CallSignature */:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
- case 147 /* IndexSignature */:
+ case 149 /* IndexSignature */:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
if (node.flags & 128 /* Static */) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ?
@@ -28228,7 +28927,7 @@ var ts;
ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
}
- else if (node.parent.kind === 212 /* ClassDeclaration */) {
+ else if (node.parent.kind === 214 /* ClassDeclaration */) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ?
ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
@@ -28242,7 +28941,7 @@ var ts;
ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
}
break;
- case 211 /* FunctionDeclaration */:
+ case 213 /* FunctionDeclaration */:
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ?
ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
@@ -28277,9 +28976,9 @@ var ts;
write("?");
}
decreaseIndent();
- if (node.parent.kind === 150 /* FunctionType */ ||
- node.parent.kind === 151 /* ConstructorType */ ||
- node.parent.parent.kind === 153 /* TypeLiteral */) {
+ if (node.parent.kind === 152 /* FunctionType */ ||
+ node.parent.kind === 153 /* ConstructorType */ ||
+ node.parent.parent.kind === 155 /* TypeLiteral */) {
emitTypeOfVariableDeclarationFromTypeLiteral(node);
}
else if (!(node.parent.flags & 32 /* Private */)) {
@@ -28295,24 +28994,24 @@ var ts;
}
function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) {
switch (node.parent.kind) {
- case 142 /* Constructor */:
+ case 144 /* Constructor */:
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ?
ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
- case 146 /* ConstructSignature */:
+ case 148 /* ConstructSignature */:
// Interfaces cannot have parameter types that cannot be named
return symbolAccesibilityResult.errorModuleName ?
ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
- case 145 /* CallSignature */:
+ case 147 /* CallSignature */:
// Interfaces cannot have parameter types that cannot be named
return symbolAccesibilityResult.errorModuleName ?
ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
if (node.parent.flags & 128 /* Static */) {
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ?
@@ -28320,7 +29019,7 @@ var ts;
ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
}
- else if (node.parent.parent.kind === 212 /* ClassDeclaration */) {
+ else if (node.parent.parent.kind === 214 /* ClassDeclaration */) {
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ?
ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
@@ -28333,7 +29032,7 @@ var ts;
ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
}
- case 211 /* FunctionDeclaration */:
+ case 213 /* FunctionDeclaration */:
return symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ?
ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
@@ -28345,12 +29044,12 @@ var ts;
}
function emitBindingPattern(bindingPattern) {
// We have to explicitly emit square bracket and bracket because these tokens are not store inside the node.
- if (bindingPattern.kind === 159 /* ObjectBindingPattern */) {
+ if (bindingPattern.kind === 161 /* ObjectBindingPattern */) {
write("{");
emitCommaList(bindingPattern.elements, emitBindingElement);
write("}");
}
- else if (bindingPattern.kind === 160 /* ArrayBindingPattern */) {
+ else if (bindingPattern.kind === 162 /* ArrayBindingPattern */) {
write("[");
var elements = bindingPattern.elements;
emitCommaList(elements, emitBindingElement);
@@ -28369,7 +29068,7 @@ var ts;
typeName: bindingElement.name
} : undefined;
}
- if (bindingElement.kind === 185 /* OmittedExpression */) {
+ if (bindingElement.kind === 187 /* OmittedExpression */) {
// If bindingElement is an omittedExpression (i.e. containing elision),
// we will emit blank space (although this may differ from users' original code,
// it allows emitSeparatedList to write separator appropriately)
@@ -28378,7 +29077,7 @@ var ts;
// emit : function foo([ , x, , ]) {}
write(" ");
}
- else if (bindingElement.kind === 161 /* BindingElement */) {
+ else if (bindingElement.kind === 163 /* BindingElement */) {
if (bindingElement.propertyName) {
// bindingElement has propertyName property in the following case:
// { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y"
@@ -28401,7 +29100,7 @@ var ts;
emitBindingPattern(bindingElement.name);
}
else {
- ts.Debug.assert(bindingElement.name.kind === 67 /* Identifier */);
+ ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */);
// If the node is just an identifier, we will simply emit the text associated with the node's name
// Example:
// original: function foo({y = 10, x}) {}
@@ -28417,40 +29116,40 @@ var ts;
}
function emitNode(node) {
switch (node.kind) {
- case 211 /* FunctionDeclaration */:
- case 216 /* ModuleDeclaration */:
- case 219 /* ImportEqualsDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 212 /* ClassDeclaration */:
- case 214 /* TypeAliasDeclaration */:
- case 215 /* EnumDeclaration */:
+ case 213 /* FunctionDeclaration */:
+ case 218 /* ModuleDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
+ case 217 /* EnumDeclaration */:
return emitModuleElement(node, isModuleElementVisible(node));
- case 191 /* VariableStatement */:
+ case 193 /* VariableStatement */:
return emitModuleElement(node, isVariableStatementVisible(node));
- case 220 /* ImportDeclaration */:
+ case 222 /* ImportDeclaration */:
// Import declaration without import clause is visible, otherwise it is not visible
return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause);
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
return emitExportDeclaration(node);
- case 142 /* Constructor */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 144 /* Constructor */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
return writeFunctionDeclaration(node);
- case 146 /* ConstructSignature */:
- case 145 /* CallSignature */:
- case 147 /* IndexSignature */:
+ case 148 /* ConstructSignature */:
+ case 147 /* CallSignature */:
+ case 149 /* IndexSignature */:
return emitSignatureDeclarationWithJsDocComments(node);
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
return emitAccessorDeclaration(node);
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
return emitPropertyDeclaration(node);
- case 245 /* EnumMember */:
+ case 247 /* EnumMember */:
return emitEnumMemberDeclaration(node);
- case 225 /* ExportAssignment */:
+ case 227 /* ExportAssignment */:
return emitExportAssignment(node);
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
return emitSourceFile(node);
}
}
@@ -28501,6 +29200,261 @@ var ts;
return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile);
}
ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile;
+ var entities = {
+ "quot": 0x0022,
+ "amp": 0x0026,
+ "apos": 0x0027,
+ "lt": 0x003C,
+ "gt": 0x003E,
+ "nbsp": 0x00A0,
+ "iexcl": 0x00A1,
+ "cent": 0x00A2,
+ "pound": 0x00A3,
+ "curren": 0x00A4,
+ "yen": 0x00A5,
+ "brvbar": 0x00A6,
+ "sect": 0x00A7,
+ "uml": 0x00A8,
+ "copy": 0x00A9,
+ "ordf": 0x00AA,
+ "laquo": 0x00AB,
+ "not": 0x00AC,
+ "shy": 0x00AD,
+ "reg": 0x00AE,
+ "macr": 0x00AF,
+ "deg": 0x00B0,
+ "plusmn": 0x00B1,
+ "sup2": 0x00B2,
+ "sup3": 0x00B3,
+ "acute": 0x00B4,
+ "micro": 0x00B5,
+ "para": 0x00B6,
+ "middot": 0x00B7,
+ "cedil": 0x00B8,
+ "sup1": 0x00B9,
+ "ordm": 0x00BA,
+ "raquo": 0x00BB,
+ "frac14": 0x00BC,
+ "frac12": 0x00BD,
+ "frac34": 0x00BE,
+ "iquest": 0x00BF,
+ "Agrave": 0x00C0,
+ "Aacute": 0x00C1,
+ "Acirc": 0x00C2,
+ "Atilde": 0x00C3,
+ "Auml": 0x00C4,
+ "Aring": 0x00C5,
+ "AElig": 0x00C6,
+ "Ccedil": 0x00C7,
+ "Egrave": 0x00C8,
+ "Eacute": 0x00C9,
+ "Ecirc": 0x00CA,
+ "Euml": 0x00CB,
+ "Igrave": 0x00CC,
+ "Iacute": 0x00CD,
+ "Icirc": 0x00CE,
+ "Iuml": 0x00CF,
+ "ETH": 0x00D0,
+ "Ntilde": 0x00D1,
+ "Ograve": 0x00D2,
+ "Oacute": 0x00D3,
+ "Ocirc": 0x00D4,
+ "Otilde": 0x00D5,
+ "Ouml": 0x00D6,
+ "times": 0x00D7,
+ "Oslash": 0x00D8,
+ "Ugrave": 0x00D9,
+ "Uacute": 0x00DA,
+ "Ucirc": 0x00DB,
+ "Uuml": 0x00DC,
+ "Yacute": 0x00DD,
+ "THORN": 0x00DE,
+ "szlig": 0x00DF,
+ "agrave": 0x00E0,
+ "aacute": 0x00E1,
+ "acirc": 0x00E2,
+ "atilde": 0x00E3,
+ "auml": 0x00E4,
+ "aring": 0x00E5,
+ "aelig": 0x00E6,
+ "ccedil": 0x00E7,
+ "egrave": 0x00E8,
+ "eacute": 0x00E9,
+ "ecirc": 0x00EA,
+ "euml": 0x00EB,
+ "igrave": 0x00EC,
+ "iacute": 0x00ED,
+ "icirc": 0x00EE,
+ "iuml": 0x00EF,
+ "eth": 0x00F0,
+ "ntilde": 0x00F1,
+ "ograve": 0x00F2,
+ "oacute": 0x00F3,
+ "ocirc": 0x00F4,
+ "otilde": 0x00F5,
+ "ouml": 0x00F6,
+ "divide": 0x00F7,
+ "oslash": 0x00F8,
+ "ugrave": 0x00F9,
+ "uacute": 0x00FA,
+ "ucirc": 0x00FB,
+ "uuml": 0x00FC,
+ "yacute": 0x00FD,
+ "thorn": 0x00FE,
+ "yuml": 0x00FF,
+ "OElig": 0x0152,
+ "oelig": 0x0153,
+ "Scaron": 0x0160,
+ "scaron": 0x0161,
+ "Yuml": 0x0178,
+ "fnof": 0x0192,
+ "circ": 0x02C6,
+ "tilde": 0x02DC,
+ "Alpha": 0x0391,
+ "Beta": 0x0392,
+ "Gamma": 0x0393,
+ "Delta": 0x0394,
+ "Epsilon": 0x0395,
+ "Zeta": 0x0396,
+ "Eta": 0x0397,
+ "Theta": 0x0398,
+ "Iota": 0x0399,
+ "Kappa": 0x039A,
+ "Lambda": 0x039B,
+ "Mu": 0x039C,
+ "Nu": 0x039D,
+ "Xi": 0x039E,
+ "Omicron": 0x039F,
+ "Pi": 0x03A0,
+ "Rho": 0x03A1,
+ "Sigma": 0x03A3,
+ "Tau": 0x03A4,
+ "Upsilon": 0x03A5,
+ "Phi": 0x03A6,
+ "Chi": 0x03A7,
+ "Psi": 0x03A8,
+ "Omega": 0x03A9,
+ "alpha": 0x03B1,
+ "beta": 0x03B2,
+ "gamma": 0x03B3,
+ "delta": 0x03B4,
+ "epsilon": 0x03B5,
+ "zeta": 0x03B6,
+ "eta": 0x03B7,
+ "theta": 0x03B8,
+ "iota": 0x03B9,
+ "kappa": 0x03BA,
+ "lambda": 0x03BB,
+ "mu": 0x03BC,
+ "nu": 0x03BD,
+ "xi": 0x03BE,
+ "omicron": 0x03BF,
+ "pi": 0x03C0,
+ "rho": 0x03C1,
+ "sigmaf": 0x03C2,
+ "sigma": 0x03C3,
+ "tau": 0x03C4,
+ "upsilon": 0x03C5,
+ "phi": 0x03C6,
+ "chi": 0x03C7,
+ "psi": 0x03C8,
+ "omega": 0x03C9,
+ "thetasym": 0x03D1,
+ "upsih": 0x03D2,
+ "piv": 0x03D6,
+ "ensp": 0x2002,
+ "emsp": 0x2003,
+ "thinsp": 0x2009,
+ "zwnj": 0x200C,
+ "zwj": 0x200D,
+ "lrm": 0x200E,
+ "rlm": 0x200F,
+ "ndash": 0x2013,
+ "mdash": 0x2014,
+ "lsquo": 0x2018,
+ "rsquo": 0x2019,
+ "sbquo": 0x201A,
+ "ldquo": 0x201C,
+ "rdquo": 0x201D,
+ "bdquo": 0x201E,
+ "dagger": 0x2020,
+ "Dagger": 0x2021,
+ "bull": 0x2022,
+ "hellip": 0x2026,
+ "permil": 0x2030,
+ "prime": 0x2032,
+ "Prime": 0x2033,
+ "lsaquo": 0x2039,
+ "rsaquo": 0x203A,
+ "oline": 0x203E,
+ "frasl": 0x2044,
+ "euro": 0x20AC,
+ "image": 0x2111,
+ "weierp": 0x2118,
+ "real": 0x211C,
+ "trade": 0x2122,
+ "alefsym": 0x2135,
+ "larr": 0x2190,
+ "uarr": 0x2191,
+ "rarr": 0x2192,
+ "darr": 0x2193,
+ "harr": 0x2194,
+ "crarr": 0x21B5,
+ "lArr": 0x21D0,
+ "uArr": 0x21D1,
+ "rArr": 0x21D2,
+ "dArr": 0x21D3,
+ "hArr": 0x21D4,
+ "forall": 0x2200,
+ "part": 0x2202,
+ "exist": 0x2203,
+ "empty": 0x2205,
+ "nabla": 0x2207,
+ "isin": 0x2208,
+ "notin": 0x2209,
+ "ni": 0x220B,
+ "prod": 0x220F,
+ "sum": 0x2211,
+ "minus": 0x2212,
+ "lowast": 0x2217,
+ "radic": 0x221A,
+ "prop": 0x221D,
+ "infin": 0x221E,
+ "ang": 0x2220,
+ "and": 0x2227,
+ "or": 0x2228,
+ "cap": 0x2229,
+ "cup": 0x222A,
+ "int": 0x222B,
+ "there4": 0x2234,
+ "sim": 0x223C,
+ "cong": 0x2245,
+ "asymp": 0x2248,
+ "ne": 0x2260,
+ "equiv": 0x2261,
+ "le": 0x2264,
+ "ge": 0x2265,
+ "sub": 0x2282,
+ "sup": 0x2283,
+ "nsub": 0x2284,
+ "sube": 0x2286,
+ "supe": 0x2287,
+ "oplus": 0x2295,
+ "otimes": 0x2297,
+ "perp": 0x22A5,
+ "sdot": 0x22C5,
+ "lceil": 0x2308,
+ "rceil": 0x2309,
+ "lfloor": 0x230A,
+ "rfloor": 0x230B,
+ "lang": 0x2329,
+ "rang": 0x232A,
+ "loz": 0x25CA,
+ "spades": 0x2660,
+ "clubs": 0x2663,
+ "hearts": 0x2665,
+ "diams": 0x2666
+ };
// Flags enum to track count of temp variables and a few dedicated names
var TempFlags;
(function (TempFlags) {
@@ -28513,7 +29467,7 @@ var ts;
// emit output for the __extends helper function
var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};";
// emit output for the __decorate helper function
- var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};";
+ var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};";
// emit output for the __metadata helper function
var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};";
// emit output for the __param helper function
@@ -28521,6 +29475,7 @@ var ts;
var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {\n return new Promise(function (resolve, reject) {\n generator = generator.call(thisArg, _arguments);\n function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }\n function onfulfill(value) { try { step(\"next\", value); } catch (e) { reject(e); } }\n function onreject(value) { try { step(\"throw\", value); } catch (e) { reject(e); } }\n function step(verb, value) {\n var result = generator[verb](value);\n result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);\n }\n step(\"next\", void 0);\n });\n};";
var compilerOptions = host.getCompilerOptions();
var languageVersion = compilerOptions.target || 0 /* ES3 */;
+ var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */;
var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined;
var diagnostics = [];
var newLine = host.getNewLine();
@@ -28554,16 +29509,8 @@ var ts;
diagnostics: diagnostics,
sourceMaps: sourceMapDataList
};
- function isNodeDescendentOf(node, ancestor) {
- while (node) {
- if (node === ancestor)
- return true;
- node = node.parent;
- }
- return false;
- }
function isUniqueLocalName(name, container) {
- for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) {
+ for (var node = container; ts.isNodeDescendentOf(node, container); node = node.nextContainer) {
if (node.locals && ts.hasProperty(node.locals, name)) {
// We conservatively include alias symbols to cover cases where they're emitted as locals
if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) {
@@ -28623,6 +29570,16 @@ var ts;
var scopeEmitEnd = function () { };
/** Sourcemap data that will get encoded */
var sourceMapData;
+ /** If removeComments is true, no leading-comments needed to be emitted **/
+ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker;
+ var moduleEmitDelegates = (_a = {},
+ _a[5 /* ES6 */] = emitES6Module,
+ _a[2 /* AMD */] = emitAMDModule,
+ _a[4 /* System */] = emitSystemModule,
+ _a[3 /* UMD */] = emitUMDModule,
+ _a[1 /* CommonJS */] = emitCommonJSModule,
+ _a
+ );
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
initializeEmitterWithSourceMaps();
}
@@ -28710,19 +29667,19 @@ var ts;
}
function generateNameForNode(node) {
switch (node.kind) {
- case 67 /* Identifier */:
+ case 69 /* Identifier */:
return makeUniqueName(node.text);
- case 216 /* ModuleDeclaration */:
- case 215 /* EnumDeclaration */:
+ case 218 /* ModuleDeclaration */:
+ case 217 /* EnumDeclaration */:
return generateNameForModuleOrEnum(node);
- case 220 /* ImportDeclaration */:
- case 226 /* ExportDeclaration */:
+ case 222 /* ImportDeclaration */:
+ case 228 /* ExportDeclaration */:
return generateNameForImportOrExportDeclaration(node);
- case 211 /* FunctionDeclaration */:
- case 212 /* ClassDeclaration */:
- case 225 /* ExportAssignment */:
+ case 213 /* FunctionDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 227 /* ExportAssignment */:
return generateNameForExportDefault();
- case 184 /* ClassExpression */:
+ case 186 /* ClassExpression */:
return generateNameForClassExpression();
}
}
@@ -28894,7 +29851,7 @@ var ts;
// unless it is a computed property. Then it is shown with brackets,
// but the brackets are included in the name.
var name_21 = node.name;
- if (!name_21 || name_21.kind !== 134 /* ComputedPropertyName */) {
+ if (!name_21 || name_21.kind !== 136 /* ComputedPropertyName */) {
scopeName = "." + scopeName;
}
scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName;
@@ -28912,20 +29869,20 @@ var ts;
// The scope was already given a name use it
recordScopeNameStart(scopeName);
}
- else if (node.kind === 211 /* FunctionDeclaration */ ||
- node.kind === 171 /* FunctionExpression */ ||
- node.kind === 141 /* MethodDeclaration */ ||
- node.kind === 140 /* MethodSignature */ ||
- node.kind === 143 /* GetAccessor */ ||
- node.kind === 144 /* SetAccessor */ ||
- node.kind === 216 /* ModuleDeclaration */ ||
- node.kind === 212 /* ClassDeclaration */ ||
- node.kind === 215 /* EnumDeclaration */) {
+ else if (node.kind === 213 /* FunctionDeclaration */ ||
+ node.kind === 173 /* FunctionExpression */ ||
+ node.kind === 143 /* MethodDeclaration */ ||
+ node.kind === 142 /* MethodSignature */ ||
+ node.kind === 145 /* GetAccessor */ ||
+ node.kind === 146 /* SetAccessor */ ||
+ node.kind === 218 /* ModuleDeclaration */ ||
+ node.kind === 214 /* ClassDeclaration */ ||
+ node.kind === 217 /* EnumDeclaration */) {
// Declaration and has associated name use it
if (node.name) {
var name_22 = node.name;
// For computed property names, the text will include the brackets
- scopeName = name_22.kind === 134 /* ComputedPropertyName */
+ scopeName = name_22.kind === 136 /* ComputedPropertyName */
? ts.getTextOfNode(name_22)
: node.name.text;
}
@@ -29037,7 +29994,7 @@ var ts;
if (ts.nodeIsSynthesized(node)) {
return emitNodeWithoutSourceMap(node);
}
- if (node.kind !== 246 /* SourceFile */) {
+ if (node.kind !== 248 /* SourceFile */) {
recordEmitNodeStartSpan(node);
emitNodeWithoutSourceMap(node);
recordEmitNodeEndSpan(node);
@@ -29065,7 +30022,7 @@ var ts;
}
// Create a temporary variable with a unique unused name.
function createTempVariable(flags) {
- var result = ts.createSynthesizedNode(67 /* Identifier */);
+ var result = ts.createSynthesizedNode(69 /* Identifier */);
result.text = makeTempVariableName(flags);
return result;
}
@@ -29310,10 +30267,10 @@ var ts;
write("(");
emit(tempVariable);
// Now we emit the expressions
- if (node.template.kind === 181 /* TemplateExpression */) {
+ if (node.template.kind === 183 /* TemplateExpression */) {
ts.forEach(node.template.templateSpans, function (templateSpan) {
write(", ");
- var needsParens = templateSpan.expression.kind === 179 /* BinaryExpression */
+ var needsParens = templateSpan.expression.kind === 181 /* BinaryExpression */
&& templateSpan.expression.operatorToken.kind === 24 /* CommaToken */;
emitParenthesizedIf(templateSpan.expression, needsParens);
});
@@ -29348,7 +30305,7 @@ var ts;
// ("abc" + 1) << (2 + "")
// rather than
// "abc" + (1 << 2) + ""
- var needsParens = templateSpan.expression.kind !== 170 /* ParenthesizedExpression */
+ var needsParens = templateSpan.expression.kind !== 172 /* ParenthesizedExpression */
&& comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */;
if (i > 0 || headEmitted) {
// If this is the first span and the head was not emitted, then this templateSpan's
@@ -29390,11 +30347,11 @@ var ts;
}
function templateNeedsParens(template, parent) {
switch (parent.kind) {
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
return parent.expression === template;
- case 168 /* TaggedTemplateExpression */:
- case 170 /* ParenthesizedExpression */:
+ case 170 /* TaggedTemplateExpression */:
+ case 172 /* ParenthesizedExpression */:
return false;
default:
return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */;
@@ -29415,11 +30372,11 @@ var ts;
// TODO (drosen): Note that we need to account for the upcoming 'yield' and
// spread ('...') unary operators that are anticipated for ES6.
switch (expression.kind) {
- case 179 /* BinaryExpression */:
+ case 181 /* BinaryExpression */:
switch (expression.operatorToken.kind) {
case 37 /* AsteriskToken */:
- case 38 /* SlashToken */:
- case 39 /* PercentToken */:
+ case 39 /* SlashToken */:
+ case 40 /* PercentToken */:
return 1 /* GreaterThan */;
case 35 /* PlusToken */:
case 36 /* MinusToken */:
@@ -29427,8 +30384,8 @@ var ts;
default:
return -1 /* LessThan */;
}
- case 182 /* YieldExpression */:
- case 180 /* ConditionalExpression */:
+ case 184 /* YieldExpression */:
+ case 182 /* ConditionalExpression */:
return -1 /* LessThan */;
default:
return 1 /* GreaterThan */;
@@ -29443,7 +30400,7 @@ var ts;
/// Emit a tag name, which is either '"div"' for lower-cased names, or
/// 'Div' for upper-cased or dotted names
function emitTagName(name) {
- if (name.kind === 67 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) {
+ if (name.kind === 69 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) {
write("\"");
emit(name);
write("\"");
@@ -29477,8 +30434,8 @@ var ts;
}
}
function emitJsxElement(openingNode, children) {
- var syntheticReactRef = ts.createSynthesizedNode(67 /* Identifier */);
- syntheticReactRef.text = 'React';
+ var syntheticReactRef = ts.createSynthesizedNode(69 /* Identifier */);
+ syntheticReactRef.text = "React";
syntheticReactRef.parent = openingNode;
// Call React.createElement(tag, ...
emitLeadingComments(openingNode);
@@ -29495,12 +30452,12 @@ var ts;
// Either emit one big object literal (no spread attribs), or
// a call to React.__spread
var attrs = openingNode.attributes;
- if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) {
+ if (ts.forEach(attrs, function (attr) { return attr.kind === 239 /* JsxSpreadAttribute */; })) {
emitExpressionIdentifier(syntheticReactRef);
write(".__spread(");
var haveOpenedObjectLiteral = false;
for (var i_1 = 0; i_1 < attrs.length; i_1++) {
- if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) {
+ if (attrs[i_1].kind === 239 /* JsxSpreadAttribute */) {
// If this is the first argument, we need to emit a {} as the first argument
if (i_1 === 0) {
write("{}, ");
@@ -29515,7 +30472,7 @@ var ts;
emit(attrs[i_1].expression);
}
else {
- ts.Debug.assert(attrs[i_1].kind === 236 /* JsxAttribute */);
+ ts.Debug.assert(attrs[i_1].kind === 238 /* JsxAttribute */);
if (haveOpenedObjectLiteral) {
write(", ");
}
@@ -29549,11 +30506,11 @@ var ts;
if (children) {
for (var i = 0; i < children.length; i++) {
// Don't emit empty expressions
- if (children[i].kind === 238 /* JsxExpression */ && !(children[i].expression)) {
+ if (children[i].kind === 240 /* JsxExpression */ && !(children[i].expression)) {
continue;
}
// Don't emit empty strings
- if (children[i].kind === 234 /* JsxText */) {
+ if (children[i].kind === 236 /* JsxText */) {
var text = getTextToEmit(children[i]);
if (text !== undefined) {
write(", \"");
@@ -29571,11 +30528,11 @@ var ts;
write(")"); // closes "React.createElement("
emitTrailingComments(openingNode);
}
- if (node.kind === 231 /* JsxElement */) {
+ if (node.kind === 233 /* JsxElement */) {
emitJsxElement(node.openingElement, node.children);
}
else {
- ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */);
+ ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */);
emitJsxElement(node);
}
}
@@ -29597,11 +30554,11 @@ var ts;
if (i > 0) {
write(" ");
}
- if (attribs[i].kind === 237 /* JsxSpreadAttribute */) {
+ if (attribs[i].kind === 239 /* JsxSpreadAttribute */) {
emitJsxSpreadAttribute(attribs[i]);
}
else {
- ts.Debug.assert(attribs[i].kind === 236 /* JsxAttribute */);
+ ts.Debug.assert(attribs[i].kind === 238 /* JsxAttribute */);
emitJsxAttribute(attribs[i]);
}
}
@@ -29609,11 +30566,11 @@ var ts;
function emitJsxOpeningOrSelfClosingElement(node) {
write("<");
emit(node.tagName);
- if (node.attributes.length > 0 || (node.kind === 232 /* JsxSelfClosingElement */)) {
+ if (node.attributes.length > 0 || (node.kind === 234 /* JsxSelfClosingElement */)) {
write(" ");
}
emitAttributes(node.attributes);
- if (node.kind === 232 /* JsxSelfClosingElement */) {
+ if (node.kind === 234 /* JsxSelfClosingElement */) {
write("/>");
}
else {
@@ -29632,11 +30589,11 @@ var ts;
}
emitJsxClosingElement(node.closingElement);
}
- if (node.kind === 231 /* JsxElement */) {
+ if (node.kind === 233 /* JsxElement */) {
emitJsxElement(node);
}
else {
- ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */);
+ ts.Debug.assert(node.kind === 234 /* JsxSelfClosingElement */);
emitJsxOpeningOrSelfClosingElement(node);
}
}
@@ -29644,11 +30601,11 @@ var ts;
// In a sense, it does not actually emit identifiers as much as it declares a name for a specific property.
// For example, this is utilized when feeding in a result to Object.defineProperty.
function emitExpressionForPropertyName(node) {
- ts.Debug.assert(node.kind !== 161 /* BindingElement */);
+ ts.Debug.assert(node.kind !== 163 /* BindingElement */);
if (node.kind === 9 /* StringLiteral */) {
emitLiteral(node);
}
- else if (node.kind === 134 /* ComputedPropertyName */) {
+ else if (node.kind === 136 /* ComputedPropertyName */) {
// if this is a decorated computed property, we will need to capture the result
// of the property expression so that we can apply decorators later. This is to ensure
// we don't introduce unintended side effects:
@@ -29659,7 +30616,7 @@ var ts;
//
// The emit for the decorated computed property decorator is:
//
- // Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)));
+ // __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a));
//
if (ts.nodeIsDecorated(node.parent)) {
if (!computedPropertyNamesToGeneratedNames) {
@@ -29692,60 +30649,61 @@ var ts;
function isExpressionIdentifier(node) {
var parent = node.parent;
switch (parent.kind) {
- case 162 /* ArrayLiteralExpression */:
- case 179 /* BinaryExpression */:
- case 166 /* CallExpression */:
- case 239 /* CaseClause */:
- case 134 /* ComputedPropertyName */:
- case 180 /* ConditionalExpression */:
- case 137 /* Decorator */:
- case 173 /* DeleteExpression */:
- case 195 /* DoStatement */:
- case 165 /* ElementAccessExpression */:
- case 225 /* ExportAssignment */:
- case 193 /* ExpressionStatement */:
- case 186 /* ExpressionWithTypeArguments */:
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 194 /* IfStatement */:
- case 232 /* JsxSelfClosingElement */:
- case 233 /* JsxOpeningElement */:
- case 237 /* JsxSpreadAttribute */:
- case 238 /* JsxExpression */:
- case 167 /* NewExpression */:
- case 170 /* ParenthesizedExpression */:
- case 178 /* PostfixUnaryExpression */:
- case 177 /* PrefixUnaryExpression */:
- case 202 /* ReturnStatement */:
- case 244 /* ShorthandPropertyAssignment */:
- case 183 /* SpreadElementExpression */:
- case 204 /* SwitchStatement */:
- case 168 /* TaggedTemplateExpression */:
- case 188 /* TemplateSpan */:
- case 206 /* ThrowStatement */:
- case 169 /* TypeAssertionExpression */:
- case 174 /* TypeOfExpression */:
- case 175 /* VoidExpression */:
- case 196 /* WhileStatement */:
- case 203 /* WithStatement */:
- case 182 /* YieldExpression */:
+ case 164 /* ArrayLiteralExpression */:
+ case 189 /* AsExpression */:
+ case 181 /* BinaryExpression */:
+ case 168 /* CallExpression */:
+ case 241 /* CaseClause */:
+ case 136 /* ComputedPropertyName */:
+ case 182 /* ConditionalExpression */:
+ case 139 /* Decorator */:
+ case 175 /* DeleteExpression */:
+ case 197 /* DoStatement */:
+ case 167 /* ElementAccessExpression */:
+ case 227 /* ExportAssignment */:
+ case 195 /* ExpressionStatement */:
+ case 188 /* ExpressionWithTypeArguments */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 196 /* IfStatement */:
+ case 234 /* JsxSelfClosingElement */:
+ case 235 /* JsxOpeningElement */:
+ case 239 /* JsxSpreadAttribute */:
+ case 240 /* JsxExpression */:
+ case 169 /* NewExpression */:
+ case 172 /* ParenthesizedExpression */:
+ case 180 /* PostfixUnaryExpression */:
+ case 179 /* PrefixUnaryExpression */:
+ case 204 /* ReturnStatement */:
+ case 246 /* ShorthandPropertyAssignment */:
+ case 185 /* SpreadElementExpression */:
+ case 206 /* SwitchStatement */:
+ case 170 /* TaggedTemplateExpression */:
+ case 190 /* TemplateSpan */:
+ case 208 /* ThrowStatement */:
+ case 171 /* TypeAssertionExpression */:
+ case 176 /* TypeOfExpression */:
+ case 177 /* VoidExpression */:
+ case 198 /* WhileStatement */:
+ case 205 /* WithStatement */:
+ case 184 /* YieldExpression */:
return true;
- case 161 /* BindingElement */:
- case 245 /* EnumMember */:
- case 136 /* Parameter */:
- case 243 /* PropertyAssignment */:
- case 139 /* PropertyDeclaration */:
- case 209 /* VariableDeclaration */:
+ case 163 /* BindingElement */:
+ case 247 /* EnumMember */:
+ case 138 /* Parameter */:
+ case 245 /* PropertyAssignment */:
+ case 141 /* PropertyDeclaration */:
+ case 211 /* VariableDeclaration */:
return parent.initializer === node;
- case 164 /* PropertyAccessExpression */:
+ case 166 /* PropertyAccessExpression */:
return parent.expression === node;
- case 172 /* ArrowFunction */:
- case 171 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
+ case 173 /* FunctionExpression */:
return parent.body === node;
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
return parent.moduleReference === node;
- case 133 /* QualifiedName */:
+ case 135 /* QualifiedName */:
return parent.left === node;
}
return false;
@@ -29757,9 +30715,9 @@ var ts;
}
var container = resolver.getReferencedExportContainer(node);
if (container) {
- if (container.kind === 246 /* SourceFile */) {
+ if (container.kind === 248 /* SourceFile */) {
// Identifier references module export
- if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) {
+ if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) {
write("exports.");
}
}
@@ -29769,28 +30727,39 @@ var ts;
write(".");
}
}
- else if (languageVersion < 2 /* ES6 */) {
- var declaration = resolver.getReferencedImportDeclaration(node);
- if (declaration) {
- if (declaration.kind === 221 /* ImportClause */) {
- // Identifier references default import
- write(getGeneratedNameForNode(declaration.parent));
- write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default");
- return;
+ else {
+ if (modulekind !== 5 /* ES6 */) {
+ var declaration = resolver.getReferencedImportDeclaration(node);
+ if (declaration) {
+ if (declaration.kind === 223 /* ImportClause */) {
+ // Identifier references default import
+ write(getGeneratedNameForNode(declaration.parent));
+ write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default");
+ return;
+ }
+ else if (declaration.kind === 226 /* ImportSpecifier */) {
+ // Identifier references named import
+ write(getGeneratedNameForNode(declaration.parent.parent.parent));
+ var name_23 = declaration.propertyName || declaration.name;
+ var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name_23);
+ if (languageVersion === 0 /* ES3 */ && identifier === "default") {
+ write("[\"default\"]");
+ }
+ else {
+ write(".");
+ write(identifier);
+ }
+ return;
+ }
}
- else if (declaration.kind === 224 /* ImportSpecifier */) {
- // Identifier references named import
- write(getGeneratedNameForNode(declaration.parent.parent.parent));
- write(".");
- writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name);
+ }
+ if (languageVersion !== 2 /* ES6 */) {
+ var declaration = resolver.getReferencedNestedRedeclaration(node);
+ if (declaration) {
+ write(getGeneratedNameForNode(declaration.name));
return;
}
}
- declaration = resolver.getReferencedNestedRedeclaration(node);
- if (declaration) {
- write(getGeneratedNameForNode(declaration.name));
- return;
- }
}
if (ts.nodeIsSynthesized(node)) {
write(node.text);
@@ -29803,10 +30772,10 @@ var ts;
if (languageVersion < 2 /* ES6 */) {
var parent_6 = node.parent;
switch (parent_6.kind) {
- case 161 /* BindingElement */:
- case 212 /* ClassDeclaration */:
- case 215 /* EnumDeclaration */:
- case 209 /* VariableDeclaration */:
+ case 163 /* BindingElement */:
+ case 214 /* ClassDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 211 /* VariableDeclaration */:
return parent_6.name === node && resolver.isNestedRedeclaration(parent_6);
}
}
@@ -29884,7 +30853,7 @@ var ts;
emit(node.expression);
}
function emitYieldExpression(node) {
- write(ts.tokenToString(112 /* YieldKeyword */));
+ write(ts.tokenToString(114 /* YieldKeyword */));
if (node.asteriskToken) {
write("*");
}
@@ -29898,7 +30867,7 @@ var ts;
if (needsParenthesis) {
write("(");
}
- write(ts.tokenToString(112 /* YieldKeyword */));
+ write(ts.tokenToString(114 /* YieldKeyword */));
write(" ");
emit(node.expression);
if (needsParenthesis) {
@@ -29906,22 +30875,22 @@ var ts;
}
}
function needsParenthesisForAwaitExpressionAsYield(node) {
- if (node.parent.kind === 179 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) {
+ if (node.parent.kind === 181 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) {
return true;
}
- else if (node.parent.kind === 180 /* ConditionalExpression */ && node.parent.condition === node) {
+ else if (node.parent.kind === 182 /* ConditionalExpression */ && node.parent.condition === node) {
return true;
}
return false;
}
function needsParenthesisForPropertyAccessOrInvocation(node) {
switch (node.kind) {
- case 67 /* Identifier */:
- case 162 /* ArrayLiteralExpression */:
- case 164 /* PropertyAccessExpression */:
- case 165 /* ElementAccessExpression */:
- case 166 /* CallExpression */:
- case 170 /* ParenthesizedExpression */:
+ case 69 /* Identifier */:
+ case 164 /* ArrayLiteralExpression */:
+ case 166 /* PropertyAccessExpression */:
+ case 167 /* ElementAccessExpression */:
+ case 168 /* CallExpression */:
+ case 172 /* ParenthesizedExpression */:
// This list is not exhaustive and only includes those cases that are relevant
// to the check in emitArrayLiteral. More cases can be added as needed.
return false;
@@ -29941,17 +30910,17 @@ var ts;
write(", ");
}
var e = elements[pos];
- if (e.kind === 183 /* SpreadElementExpression */) {
+ if (e.kind === 185 /* SpreadElementExpression */) {
e = e.expression;
emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e));
pos++;
- if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162 /* ArrayLiteralExpression */) {
+ if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 164 /* ArrayLiteralExpression */) {
write(".slice()");
}
}
else {
var i = pos;
- while (i < length && elements[i].kind !== 183 /* SpreadElementExpression */) {
+ while (i < length && elements[i].kind !== 185 /* SpreadElementExpression */) {
i++;
}
write("[");
@@ -29974,7 +30943,7 @@ var ts;
}
}
function isSpreadElementExpression(node) {
- return node.kind === 183 /* SpreadElementExpression */;
+ return node.kind === 185 /* SpreadElementExpression */;
}
function emitArrayLiteral(node) {
var elements = node.elements;
@@ -30044,7 +31013,7 @@ var ts;
writeComma();
var property = properties[i];
emitStart(property);
- if (property.kind === 143 /* GetAccessor */ || property.kind === 144 /* SetAccessor */) {
+ if (property.kind === 145 /* GetAccessor */ || property.kind === 146 /* SetAccessor */) {
// TODO (drosen): Reconcile with 'emitMemberFunctions'.
var accessors = ts.getAllAccessorDeclarations(node.properties, property);
if (property !== accessors.firstAccessor) {
@@ -30096,13 +31065,13 @@ var ts;
emitMemberAccessForPropertyName(property.name);
emitEnd(property.name);
write(" = ");
- if (property.kind === 243 /* PropertyAssignment */) {
+ if (property.kind === 245 /* PropertyAssignment */) {
emit(property.initializer);
}
- else if (property.kind === 244 /* ShorthandPropertyAssignment */) {
+ else if (property.kind === 246 /* ShorthandPropertyAssignment */) {
emitExpressionIdentifier(property.name);
}
- else if (property.kind === 141 /* MethodDeclaration */) {
+ else if (property.kind === 143 /* MethodDeclaration */) {
emitFunctionDeclaration(property);
}
else {
@@ -30136,7 +31105,7 @@ var ts;
// Everything until that point can be emitted as part of the initial object literal.
var numInitialNonComputedProperties = numProperties;
for (var i = 0, n = properties.length; i < n; i++) {
- if (properties[i].name.kind === 134 /* ComputedPropertyName */) {
+ if (properties[i].name.kind === 136 /* ComputedPropertyName */) {
numInitialNonComputedProperties = i;
break;
}
@@ -30152,21 +31121,21 @@ var ts;
emitObjectLiteralBody(node, properties.length);
}
function createBinaryExpression(left, operator, right, startsOnNewLine) {
- var result = ts.createSynthesizedNode(179 /* BinaryExpression */, startsOnNewLine);
+ var result = ts.createSynthesizedNode(181 /* BinaryExpression */, startsOnNewLine);
result.operatorToken = ts.createSynthesizedNode(operator);
result.left = left;
result.right = right;
return result;
}
function createPropertyAccessExpression(expression, name) {
- var result = ts.createSynthesizedNode(164 /* PropertyAccessExpression */);
+ var result = ts.createSynthesizedNode(166 /* PropertyAccessExpression */);
result.expression = parenthesizeForAccess(expression);
result.dotToken = ts.createSynthesizedNode(21 /* DotToken */);
result.name = name;
return result;
}
function createElementAccessExpression(expression, argumentExpression) {
- var result = ts.createSynthesizedNode(165 /* ElementAccessExpression */);
+ var result = ts.createSynthesizedNode(167 /* ElementAccessExpression */);
result.expression = parenthesizeForAccess(expression);
result.argumentExpression = argumentExpression;
return result;
@@ -30174,7 +31143,7 @@ var ts;
function parenthesizeForAccess(expr) {
// When diagnosing whether the expression needs parentheses, the decision should be based
// on the innermost expression in a chain of nested type assertions.
- while (expr.kind === 169 /* TypeAssertionExpression */ || expr.kind === 187 /* AsExpression */) {
+ while (expr.kind === 171 /* TypeAssertionExpression */ || expr.kind === 189 /* AsExpression */) {
expr = expr.expression;
}
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
@@ -30186,11 +31155,11 @@ var ts;
// 1.x -> not the same as (1).x
//
if (ts.isLeftHandSideExpression(expr) &&
- expr.kind !== 167 /* NewExpression */ &&
+ expr.kind !== 169 /* NewExpression */ &&
expr.kind !== 8 /* NumericLiteral */) {
return expr;
}
- var node = ts.createSynthesizedNode(170 /* ParenthesizedExpression */);
+ var node = ts.createSynthesizedNode(172 /* ParenthesizedExpression */);
node.expression = expr;
return node;
}
@@ -30225,7 +31194,7 @@ var ts;
// Return true if identifier resolves to an exported member of a namespace
function isNamespaceExportReference(node) {
var container = resolver.getReferencedExportContainer(node);
- return container && container.kind !== 246 /* SourceFile */;
+ return container && container.kind !== 248 /* SourceFile */;
}
function emitShorthandPropertyAssignment(node) {
// The name property of a short-hand property assignment is considered an expression position, so here
@@ -30245,13 +31214,17 @@ var ts;
write(": ");
emit(node.name);
}
+ if (languageVersion >= 2 /* ES6 */ && node.objectAssignmentInitializer) {
+ write(" = ");
+ emit(node.objectAssignmentInitializer);
+ }
}
function tryEmitConstantValue(node) {
var constantValue = tryGetConstEnumValue(node);
if (constantValue !== undefined) {
write(constantValue.toString());
if (!compilerOptions.removeComments) {
- var propertyName = node.kind === 164 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression);
+ var propertyName = node.kind === 166 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression);
write(" /* " + propertyName + " */");
}
return true;
@@ -30262,7 +31235,7 @@ var ts;
if (compilerOptions.isolatedModules) {
return undefined;
}
- return node.kind === 164 /* PropertyAccessExpression */ || node.kind === 165 /* ElementAccessExpression */
+ return node.kind === 166 /* PropertyAccessExpression */ || node.kind === 167 /* ElementAccessExpression */
? resolver.getConstantValue(node)
: undefined;
}
@@ -30323,7 +31296,7 @@ var ts;
emit(node.right);
}
function emitQualifiedNameAsExpression(node, useFallback) {
- if (node.left.kind === 67 /* Identifier */) {
+ if (node.left.kind === 69 /* Identifier */) {
emitEntityNameAsExpression(node.left, useFallback);
}
else if (useFallback) {
@@ -30343,7 +31316,7 @@ var ts;
}
function emitEntityNameAsExpression(node, useFallback) {
switch (node.kind) {
- case 67 /* Identifier */:
+ case 69 /* Identifier */:
if (useFallback) {
write("typeof ");
emitExpressionIdentifier(node);
@@ -30351,7 +31324,7 @@ var ts;
}
emitExpressionIdentifier(node);
break;
- case 133 /* QualifiedName */:
+ case 135 /* QualifiedName */:
emitQualifiedNameAsExpression(node, useFallback);
break;
}
@@ -30366,16 +31339,16 @@ var ts;
write("]");
}
function hasSpreadElement(elements) {
- return ts.forEach(elements, function (e) { return e.kind === 183 /* SpreadElementExpression */; });
+ return ts.forEach(elements, function (e) { return e.kind === 185 /* SpreadElementExpression */; });
}
function skipParentheses(node) {
- while (node.kind === 170 /* ParenthesizedExpression */ || node.kind === 169 /* TypeAssertionExpression */ || node.kind === 187 /* AsExpression */) {
+ while (node.kind === 172 /* ParenthesizedExpression */ || node.kind === 171 /* TypeAssertionExpression */ || node.kind === 189 /* AsExpression */) {
node = node.expression;
}
return node;
}
function emitCallTarget(node) {
- if (node.kind === 67 /* Identifier */ || node.kind === 95 /* ThisKeyword */ || node.kind === 93 /* SuperKeyword */) {
+ if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || node.kind === 95 /* SuperKeyword */) {
emit(node);
return node;
}
@@ -30390,20 +31363,20 @@ var ts;
function emitCallWithSpread(node) {
var target;
var expr = skipParentheses(node.expression);
- if (expr.kind === 164 /* PropertyAccessExpression */) {
+ if (expr.kind === 166 /* PropertyAccessExpression */) {
// Target will be emitted as "this" argument
target = emitCallTarget(expr.expression);
write(".");
emit(expr.name);
}
- else if (expr.kind === 165 /* ElementAccessExpression */) {
+ else if (expr.kind === 167 /* ElementAccessExpression */) {
// Target will be emitted as "this" argument
target = emitCallTarget(expr.expression);
write("[");
emit(expr.argumentExpression);
write("]");
}
- else if (expr.kind === 93 /* SuperKeyword */) {
+ else if (expr.kind === 95 /* SuperKeyword */) {
target = expr;
write("_super");
}
@@ -30412,7 +31385,7 @@ var ts;
}
write(".apply(");
if (target) {
- if (target.kind === 93 /* SuperKeyword */) {
+ if (target.kind === 95 /* SuperKeyword */) {
// Calls of form super(...) and super.foo(...)
emitThis(target);
}
@@ -30435,13 +31408,13 @@ var ts;
return;
}
var superCall = false;
- if (node.expression.kind === 93 /* SuperKeyword */) {
+ if (node.expression.kind === 95 /* SuperKeyword */) {
emitSuper(node.expression);
superCall = true;
}
else {
emit(node.expression);
- superCall = node.expression.kind === 164 /* PropertyAccessExpression */ && node.expression.expression.kind === 93 /* SuperKeyword */;
+ superCall = node.expression.kind === 166 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */;
}
if (superCall && languageVersion < 2 /* ES6 */) {
write(".call(");
@@ -30510,12 +31483,12 @@ var ts;
// If the node is synthesized, it means the emitter put the parentheses there,
// not the user. If we didn't want them, the emitter would not have put them
// there.
- if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172 /* ArrowFunction */) {
- if (node.expression.kind === 169 /* TypeAssertionExpression */ || node.expression.kind === 187 /* AsExpression */) {
+ if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 174 /* ArrowFunction */) {
+ if (node.expression.kind === 171 /* TypeAssertionExpression */ || node.expression.kind === 189 /* AsExpression */) {
var operand = node.expression.expression;
// Make sure we consider all nested cast expressions, e.g.:
// (-A).x;
- while (operand.kind === 169 /* TypeAssertionExpression */ || operand.kind === 187 /* AsExpression */) {
+ while (operand.kind === 171 /* TypeAssertionExpression */ || operand.kind === 189 /* AsExpression */) {
operand = operand.expression;
}
// We have an expression of the form: (SubExpr)
@@ -30526,14 +31499,15 @@ var ts;
// (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString()
// new (A()) should be emitted as new (A()) and not new A()
// (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} ()
- if (operand.kind !== 177 /* PrefixUnaryExpression */ &&
- operand.kind !== 175 /* VoidExpression */ &&
- operand.kind !== 174 /* TypeOfExpression */ &&
- operand.kind !== 173 /* DeleteExpression */ &&
- operand.kind !== 178 /* PostfixUnaryExpression */ &&
- operand.kind !== 167 /* NewExpression */ &&
- !(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) &&
- !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */)) {
+ if (operand.kind !== 179 /* PrefixUnaryExpression */ &&
+ operand.kind !== 177 /* VoidExpression */ &&
+ operand.kind !== 176 /* TypeOfExpression */ &&
+ operand.kind !== 175 /* DeleteExpression */ &&
+ operand.kind !== 180 /* PostfixUnaryExpression */ &&
+ operand.kind !== 169 /* NewExpression */ &&
+ !(operand.kind === 168 /* CallExpression */ && node.parent.kind === 169 /* NewExpression */) &&
+ !(operand.kind === 173 /* FunctionExpression */ && node.parent.kind === 168 /* CallExpression */) &&
+ !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 166 /* PropertyAccessExpression */)) {
emit(operand);
return;
}
@@ -30544,25 +31518,25 @@ var ts;
write(")");
}
function emitDeleteExpression(node) {
- write(ts.tokenToString(76 /* DeleteKeyword */));
+ write(ts.tokenToString(78 /* DeleteKeyword */));
write(" ");
emit(node.expression);
}
function emitVoidExpression(node) {
- write(ts.tokenToString(101 /* VoidKeyword */));
+ write(ts.tokenToString(103 /* VoidKeyword */));
write(" ");
emit(node.expression);
}
function emitTypeOfExpression(node) {
- write(ts.tokenToString(99 /* TypeOfKeyword */));
+ write(ts.tokenToString(101 /* TypeOfKeyword */));
write(" ");
emit(node.expression);
}
function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) {
- if (!isCurrentFileSystemExternalModule() || node.kind !== 67 /* Identifier */ || ts.nodeIsSynthesized(node)) {
+ if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) {
return false;
}
- var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 /* VariableDeclaration */ || node.parent.kind === 161 /* BindingElement */);
+ var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 211 /* VariableDeclaration */ || node.parent.kind === 163 /* BindingElement */);
var targetDeclaration = isVariableDeclarationOrBindingElement
? node.parent
: resolver.getReferencedValueDeclaration(node);
@@ -30592,12 +31566,12 @@ var ts;
// the resulting expression a prefix increment operation. And in the second, it will make the resulting
// expression a prefix increment whose operand is a plus expression - (++(+x))
// The same is true of minus of course.
- if (node.operand.kind === 177 /* PrefixUnaryExpression */) {
+ if (node.operand.kind === 179 /* PrefixUnaryExpression */) {
var operand = node.operand;
- if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 40 /* PlusPlusToken */)) {
+ if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) {
write(" ");
}
- else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 41 /* MinusMinusToken */)) {
+ else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */)) {
write(" ");
}
}
@@ -30617,7 +31591,7 @@ var ts;
write("\", ");
write(ts.tokenToString(node.operator));
emit(node.operand);
- if (node.operator === 40 /* PlusPlusToken */) {
+ if (node.operator === 41 /* PlusPlusToken */) {
write(") - 1)");
}
else {
@@ -30648,10 +31622,10 @@ var ts;
}
var current = node;
while (current) {
- if (current.kind === 246 /* SourceFile */) {
+ if (current.kind === 248 /* SourceFile */) {
return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0);
}
- else if (ts.isFunctionLike(current) || current.kind === 217 /* ModuleBlock */) {
+ else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) {
return false;
}
else {
@@ -30659,14 +31633,69 @@ var ts;
}
}
}
+ /**
+ * Emit ES7 exponentiation operator downlevel using Math.pow
+ * @param node a binary expression node containing exponentiationOperator (**, **=)
+ */
+ function emitExponentiationOperator(node) {
+ var leftHandSideExpression = node.left;
+ if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) {
+ var synthesizedLHS;
+ var shouldEmitParentheses = false;
+ if (ts.isElementAccessExpression(leftHandSideExpression)) {
+ shouldEmitParentheses = true;
+ write("(");
+ synthesizedLHS = ts.createSynthesizedNode(167 /* ElementAccessExpression */, /*startsOnNewLine*/ false);
+ var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldEmitCommaBeforeAssignment*/ false);
+ synthesizedLHS.expression = identifier;
+ if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ &&
+ leftHandSideExpression.argumentExpression.kind !== 9 /* StringLiteral */) {
+ var tempArgumentExpression = createAndRecordTempVariable(268435456 /* _i */);
+ synthesizedLHS.argumentExpression = tempArgumentExpression;
+ emitAssignment(tempArgumentExpression, leftHandSideExpression.argumentExpression, /*shouldEmitCommaBeforeAssignment*/ true);
+ }
+ else {
+ synthesizedLHS.argumentExpression = leftHandSideExpression.argumentExpression;
+ }
+ write(", ");
+ }
+ else if (ts.isPropertyAccessExpression(leftHandSideExpression)) {
+ shouldEmitParentheses = true;
+ write("(");
+ synthesizedLHS = ts.createSynthesizedNode(166 /* PropertyAccessExpression */, /*startsOnNewLine*/ false);
+ var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefinedTempVariablesInPlaces*/ false, /*shouldemitCommaBeforeAssignment*/ false);
+ synthesizedLHS.expression = identifier;
+ synthesizedLHS.dotToken = leftHandSideExpression.dotToken;
+ synthesizedLHS.name = leftHandSideExpression.name;
+ write(", ");
+ }
+ emit(synthesizedLHS || leftHandSideExpression);
+ write(" = ");
+ write("Math.pow(");
+ emit(synthesizedLHS || leftHandSideExpression);
+ write(", ");
+ emit(node.right);
+ write(")");
+ if (shouldEmitParentheses) {
+ write(")");
+ }
+ }
+ else {
+ write("Math.pow(");
+ emit(leftHandSideExpression);
+ write(", ");
+ emit(node.right);
+ write(")");
+ }
+ }
function emitBinaryExpression(node) {
- if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 55 /* EqualsToken */ &&
- (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) {
- emitDestructuring(node, node.parent.kind === 193 /* ExpressionStatement */);
+ if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ &&
+ (node.left.kind === 165 /* ObjectLiteralExpression */ || node.left.kind === 164 /* ArrayLiteralExpression */)) {
+ emitDestructuring(node, node.parent.kind === 195 /* ExpressionStatement */);
}
else {
- var exportChanged = node.operatorToken.kind >= 55 /* FirstAssignment */ &&
- node.operatorToken.kind <= 66 /* LastAssignment */ &&
+ var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ &&
+ node.operatorToken.kind <= 68 /* LastAssignment */ &&
isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left);
if (exportChanged) {
// emit assignment 'x y' as 'exports("x", x y)'
@@ -30674,12 +31703,25 @@ var ts;
emitNodeWithoutSourceMap(node.left);
write("\", ");
}
- emit(node.left);
- var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined);
- write(ts.tokenToString(node.operatorToken.kind));
- var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " ");
- emit(node.right);
- decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator);
+ if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */ || node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) {
+ // Downleveled emit exponentiation operator using Math.pow
+ emitExponentiationOperator(node);
+ }
+ else {
+ emit(node.left);
+ // Add indentation before emit the operator if the operator is on different line
+ // For example:
+ // 3
+ // + 2;
+ // emitted as
+ // 3
+ // + 2;
+ var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined);
+ write(ts.tokenToString(node.operatorToken.kind));
+ var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " ");
+ emit(node.right);
+ decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator);
+ }
if (exportChanged) {
write(")");
}
@@ -30714,7 +31756,7 @@ var ts;
}
}
function isSingleLineEmptyBlock(node) {
- if (node && node.kind === 190 /* Block */) {
+ if (node && node.kind === 192 /* Block */) {
var block = node;
return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block);
}
@@ -30729,12 +31771,12 @@ var ts;
emitToken(15 /* OpenBraceToken */, node.pos);
increaseIndent();
scopeEmitStart(node.parent);
- if (node.kind === 217 /* ModuleBlock */) {
- ts.Debug.assert(node.parent.kind === 216 /* ModuleDeclaration */);
+ if (node.kind === 219 /* ModuleBlock */) {
+ ts.Debug.assert(node.parent.kind === 218 /* ModuleDeclaration */);
emitCaptureThisForNodeIfNecessary(node.parent);
}
emitLines(node.statements);
- if (node.kind === 217 /* ModuleBlock */) {
+ if (node.kind === 219 /* ModuleBlock */) {
emitTempDeclarations(/*newLine*/ true);
}
decreaseIndent();
@@ -30743,7 +31785,7 @@ var ts;
scopeEmitEnd();
}
function emitEmbeddedStatement(node) {
- if (node.kind === 190 /* Block */) {
+ if (node.kind === 192 /* Block */) {
write(" ");
emit(node);
}
@@ -30755,11 +31797,11 @@ var ts;
}
}
function emitExpressionStatement(node) {
- emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 172 /* ArrowFunction */);
+ emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 174 /* ArrowFunction */);
write(";");
}
function emitIfStatement(node) {
- var endPos = emitToken(86 /* IfKeyword */, node.pos);
+ var endPos = emitToken(88 /* IfKeyword */, node.pos);
write(" ");
endPos = emitToken(17 /* OpenParenToken */, endPos);
emit(node.expression);
@@ -30767,8 +31809,8 @@ var ts;
emitEmbeddedStatement(node.thenStatement);
if (node.elseStatement) {
writeLine();
- emitToken(78 /* ElseKeyword */, node.thenStatement.end);
- if (node.elseStatement.kind === 194 /* IfStatement */) {
+ emitToken(80 /* ElseKeyword */, node.thenStatement.end);
+ if (node.elseStatement.kind === 196 /* IfStatement */) {
write(" ");
emit(node.elseStatement);
}
@@ -30780,7 +31822,7 @@ var ts;
function emitDoStatement(node) {
write("do");
emitEmbeddedStatement(node.statement);
- if (node.statement.kind === 190 /* Block */) {
+ if (node.statement.kind === 192 /* Block */) {
write(" ");
}
else {
@@ -30806,13 +31848,13 @@ var ts;
// variables in variable declaration list were already hoisted
return false;
}
- var tokenKind = 100 /* VarKeyword */;
+ var tokenKind = 102 /* VarKeyword */;
if (decl && languageVersion >= 2 /* ES6 */) {
if (ts.isLet(decl)) {
- tokenKind = 106 /* LetKeyword */;
+ tokenKind = 108 /* LetKeyword */;
}
else if (ts.isConst(decl)) {
- tokenKind = 72 /* ConstKeyword */;
+ tokenKind = 74 /* ConstKeyword */;
}
}
if (startPos !== undefined) {
@@ -30821,13 +31863,13 @@ var ts;
}
else {
switch (tokenKind) {
- case 100 /* VarKeyword */:
+ case 102 /* VarKeyword */:
write("var ");
break;
- case 106 /* LetKeyword */:
+ case 108 /* LetKeyword */:
write("let ");
break;
- case 72 /* ConstKeyword */:
+ case 74 /* ConstKeyword */:
write("const ");
break;
}
@@ -30852,10 +31894,10 @@ var ts;
return started;
}
function emitForStatement(node) {
- var endPos = emitToken(84 /* ForKeyword */, node.pos);
+ var endPos = emitToken(86 /* ForKeyword */, node.pos);
write(" ");
endPos = emitToken(17 /* OpenParenToken */, endPos);
- if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) {
+ if (node.initializer && node.initializer.kind === 212 /* VariableDeclarationList */) {
var variableDeclarationList = node.initializer;
var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos);
if (startIsEmitted) {
@@ -30876,13 +31918,13 @@ var ts;
emitEmbeddedStatement(node.statement);
}
function emitForInOrForOfStatement(node) {
- if (languageVersion < 2 /* ES6 */ && node.kind === 199 /* ForOfStatement */) {
+ if (languageVersion < 2 /* ES6 */ && node.kind === 201 /* ForOfStatement */) {
return emitDownLevelForOfStatement(node);
}
- var endPos = emitToken(84 /* ForKeyword */, node.pos);
+ var endPos = emitToken(86 /* ForKeyword */, node.pos);
write(" ");
endPos = emitToken(17 /* OpenParenToken */, endPos);
- if (node.initializer.kind === 210 /* VariableDeclarationList */) {
+ if (node.initializer.kind === 212 /* VariableDeclarationList */) {
var variableDeclarationList = node.initializer;
if (variableDeclarationList.declarations.length >= 1) {
tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos);
@@ -30892,7 +31934,7 @@ var ts;
else {
emit(node.initializer);
}
- if (node.kind === 198 /* ForInStatement */) {
+ if (node.kind === 200 /* ForInStatement */) {
write(" in ");
}
else {
@@ -30923,7 +31965,7 @@ var ts;
// all destructuring.
// Note also that because an extra statement is needed to assign to the LHS,
// for-of bodies are always emitted as blocks.
- var endPos = emitToken(84 /* ForKeyword */, node.pos);
+ var endPos = emitToken(86 /* ForKeyword */, node.pos);
write(" ");
endPos = emitToken(17 /* OpenParenToken */, endPos);
// Do not emit the LHS let declaration yet, because it might contain destructuring.
@@ -30934,7 +31976,7 @@ var ts;
// for (let v of arr) { }
//
// we don't want to emit a temporary variable for the RHS, just use it directly.
- var rhsIsIdentifier = node.expression.kind === 67 /* Identifier */;
+ var rhsIsIdentifier = node.expression.kind === 69 /* Identifier */;
var counter = createTempVariable(268435456 /* _i */);
var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */);
// This is the let keyword for the counter and rhsReference. The let keyword for
@@ -30977,7 +32019,7 @@ var ts;
// let v = _a[_i];
var rhsIterationValue = createElementAccessExpression(rhsReference, counter);
emitStart(node.initializer);
- if (node.initializer.kind === 210 /* VariableDeclarationList */) {
+ if (node.initializer.kind === 212 /* VariableDeclarationList */) {
write("var ");
var variableDeclarationList = node.initializer;
if (variableDeclarationList.declarations.length > 0) {
@@ -31006,8 +32048,8 @@ var ts;
else {
// Initializer is an expression. Emit the expression in the body, so that it's
// evaluated on every iteration.
- var assignmentExpression = createBinaryExpression(node.initializer, 55 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false);
- if (node.initializer.kind === 162 /* ArrayLiteralExpression */ || node.initializer.kind === 163 /* ObjectLiteralExpression */) {
+ var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false);
+ if (node.initializer.kind === 164 /* ArrayLiteralExpression */ || node.initializer.kind === 165 /* ObjectLiteralExpression */) {
// This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause
// the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash.
emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined);
@@ -31018,7 +32060,7 @@ var ts;
}
emitEnd(node.initializer);
write(";");
- if (node.statement.kind === 190 /* Block */) {
+ if (node.statement.kind === 192 /* Block */) {
emitLines(node.statement.statements);
}
else {
@@ -31030,12 +32072,12 @@ var ts;
write("}");
}
function emitBreakOrContinueStatement(node) {
- emitToken(node.kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */, node.pos);
+ emitToken(node.kind === 203 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos);
emitOptional(" ", node.label);
write(";");
}
function emitReturnStatement(node) {
- emitToken(92 /* ReturnKeyword */, node.pos);
+ emitToken(94 /* ReturnKeyword */, node.pos);
emitOptional(" ", node.expression);
write(";");
}
@@ -31046,7 +32088,7 @@ var ts;
emitEmbeddedStatement(node.statement);
}
function emitSwitchStatement(node) {
- var endPos = emitToken(94 /* SwitchKeyword */, node.pos);
+ var endPos = emitToken(96 /* SwitchKeyword */, node.pos);
write(" ");
emitToken(17 /* OpenParenToken */, endPos);
emit(node.expression);
@@ -31075,7 +32117,7 @@ var ts;
ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos));
}
function emitCaseOrDefaultClause(node) {
- if (node.kind === 239 /* CaseClause */) {
+ if (node.kind === 241 /* CaseClause */) {
write("case ");
emit(node.expression);
write(":");
@@ -31110,7 +32152,7 @@ var ts;
}
function emitCatchClause(node) {
writeLine();
- var endPos = emitToken(70 /* CatchKeyword */, node.pos);
+ var endPos = emitToken(72 /* CatchKeyword */, node.pos);
write(" ");
emitToken(17 /* OpenParenToken */, endPos);
emit(node.variableDeclaration);
@@ -31119,7 +32161,7 @@ var ts;
emitBlock(node.block);
}
function emitDebuggerStatement(node) {
- emitToken(74 /* DebuggerKeyword */, node.pos);
+ emitToken(76 /* DebuggerKeyword */, node.pos);
write(";");
}
function emitLabelledStatement(node) {
@@ -31130,7 +32172,7 @@ var ts;
function getContainingModule(node) {
do {
node = node.parent;
- } while (node && node.kind !== 216 /* ModuleDeclaration */);
+ } while (node && node.kind !== 218 /* ModuleDeclaration */);
return node;
}
function emitContainingModuleName(node) {
@@ -31145,7 +32187,7 @@ var ts;
write(getGeneratedNameForNode(container));
write(".");
}
- else if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) {
+ else if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) {
write("exports.");
}
}
@@ -31155,15 +32197,15 @@ var ts;
function createVoidZero() {
var zero = ts.createSynthesizedNode(8 /* NumericLiteral */);
zero.text = "0";
- var result = ts.createSynthesizedNode(175 /* VoidExpression */);
+ var result = ts.createSynthesizedNode(177 /* VoidExpression */);
result.expression = zero;
return result;
}
function emitEs6ExportDefaultCompat(node) {
- if (node.parent.kind === 246 /* SourceFile */) {
- ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 225 /* ExportAssignment */);
+ if (node.parent.kind === 248 /* SourceFile */) {
+ ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */);
// only allow export default at a source file level
- if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) {
+ if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) {
if (!currentSourceFile.symbol.exports["___esModule"]) {
if (languageVersion === 1 /* ES5 */) {
// default value of configurable, enumerable, writable are `false`.
@@ -31183,7 +32225,7 @@ var ts;
writeLine();
emitStart(node);
// emit call to exporter only for top level nodes
- if (compilerOptions.module === 4 /* System */ && node.parent === currentSourceFile) {
+ if (modulekind === 4 /* System */ && node.parent === currentSourceFile) {
// emit export default as
// export("default", )
write(exportFunctionForFile + "(\"");
@@ -31218,7 +32260,7 @@ var ts;
}
}
function emitExportMemberAssignments(name) {
- if (compilerOptions.module === 4 /* System */) {
+ if (modulekind === 4 /* System */) {
return;
}
if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) {
@@ -31237,7 +32279,7 @@ var ts;
}
}
function emitExportSpecifierInSystemModule(specifier) {
- ts.Debug.assert(compilerOptions.module === 4 /* System */);
+ ts.Debug.assert(modulekind === 4 /* System */);
if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) {
return;
}
@@ -31251,6 +32293,49 @@ var ts;
emitEnd(specifier.name);
write(";");
}
+ /**
+ * Emit an assignment to a given identifier, 'name', with a given expression, 'value'.
+ * @param name an identifier as a left-hand-side operand of the assignment
+ * @param value an expression as a right-hand-side operand of the assignment
+ * @param shouldEmitCommaBeforeAssignment a boolean indicating whether to prefix an assignment with comma
+ */
+ function emitAssignment(name, value, shouldEmitCommaBeforeAssignment) {
+ if (shouldEmitCommaBeforeAssignment) {
+ write(", ");
+ }
+ var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name);
+ if (exportChanged) {
+ write(exportFunctionForFile + "(\"");
+ emitNodeWithCommentsAndWithoutSourcemap(name);
+ write("\", ");
+ }
+ var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 211 /* VariableDeclaration */ || name.parent.kind === 163 /* BindingElement */);
+ if (isVariableDeclarationOrBindingElement) {
+ emitModuleMemberName(name.parent);
+ }
+ else {
+ emit(name);
+ }
+ write(" = ");
+ emit(value);
+ if (exportChanged) {
+ write(")");
+ }
+ }
+ /**
+ * Create temporary variable, emit an assignment of the variable the given expression
+ * @param expression an expression to assign to the newly created temporary variable
+ * @param canDefineTempVariablesInPlace a boolean indicating whether you can define the temporary variable at an assignment location
+ * @param shouldEmitCommaBeforeAssignment a boolean indicating whether an assignment should prefix with comma
+ */
+ function emitTempVariableAssignment(expression, canDefineTempVariablesInPlace, shouldEmitCommaBeforeAssignment) {
+ var identifier = createTempVariable(0 /* Auto */);
+ if (!canDefineTempVariablesInPlace) {
+ recordTempDeclaration(identifier);
+ }
+ emitAssignment(identifier, expression, shouldEmitCommaBeforeAssignment);
+ return identifier;
+ }
function emitDestructuring(root, isAssignmentExpressionStatement, value) {
var emitCount = 0;
// An exported declaration is actually emitted as an assignment (to a property on the module object), so
@@ -31258,44 +32343,21 @@ var ts;
// Also temporary variables should be explicitly allocated for source level declarations when module target is system
// because actual variable declarations are hoisted
var canDefineTempVariablesInPlace = false;
- if (root.kind === 209 /* VariableDeclaration */) {
+ if (root.kind === 211 /* VariableDeclaration */) {
var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */;
var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root);
canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind;
}
- else if (root.kind === 136 /* Parameter */) {
+ else if (root.kind === 138 /* Parameter */) {
canDefineTempVariablesInPlace = true;
}
- if (root.kind === 179 /* BinaryExpression */) {
+ if (root.kind === 181 /* BinaryExpression */) {
emitAssignmentExpression(root);
}
else {
ts.Debug.assert(!isAssignmentExpressionStatement);
emitBindingElement(root, value);
}
- function emitAssignment(name, value) {
- if (emitCount++) {
- write(", ");
- }
- var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 /* VariableDeclaration */ || name.parent.kind === 161 /* BindingElement */);
- var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name);
- if (exportChanged) {
- write(exportFunctionForFile + "(\"");
- emitNodeWithCommentsAndWithoutSourcemap(name);
- write("\", ");
- }
- if (isVariableDeclarationOrBindingElement) {
- emitModuleMemberName(name.parent);
- }
- else {
- emit(name);
- }
- write(" = ");
- emit(value);
- if (exportChanged) {
- write(")");
- }
- }
/**
* Ensures that there exists a declared identifier whose value holds the given expression.
* This function is useful to ensure that the expression's value can be read from in subsequent expressions.
@@ -31306,14 +32368,11 @@ var ts;
* false if it is necessary to always emit an identifier.
*/
function ensureIdentifier(expr, reuseIdentifierExpressions) {
- if (expr.kind === 67 /* Identifier */ && reuseIdentifierExpressions) {
+ if (expr.kind === 69 /* Identifier */ && reuseIdentifierExpressions) {
return expr;
}
- var identifier = createTempVariable(0 /* Auto */);
- if (!canDefineTempVariablesInPlace) {
- recordTempDeclaration(identifier);
- }
- emitAssignment(identifier, expr);
+ var identifier = emitTempVariableAssignment(expr, canDefineTempVariablesInPlace, emitCount > 0);
+ emitCount++;
return identifier;
}
function createDefaultValueCheck(value, defaultValue) {
@@ -31321,18 +32380,18 @@ var ts;
// we need to generate a temporary variable
value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
// Return the expression 'value === void 0 ? defaultValue : value'
- var equals = ts.createSynthesizedNode(179 /* BinaryExpression */);
+ var equals = ts.createSynthesizedNode(181 /* BinaryExpression */);
equals.left = value;
equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */);
equals.right = createVoidZero();
return createConditionalExpression(equals, defaultValue, value);
}
function createConditionalExpression(condition, whenTrue, whenFalse) {
- var cond = ts.createSynthesizedNode(180 /* ConditionalExpression */);
+ var cond = ts.createSynthesizedNode(182 /* ConditionalExpression */);
cond.condition = condition;
- cond.questionToken = ts.createSynthesizedNode(52 /* QuestionToken */);
+ cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */);
cond.whenTrue = whenTrue;
- cond.colonToken = ts.createSynthesizedNode(53 /* ColonToken */);
+ cond.colonToken = ts.createSynthesizedNode(54 /* ColonToken */);
cond.whenFalse = whenFalse;
return cond;
}
@@ -31346,14 +32405,14 @@ var ts;
// otherwise occur when the identifier is emitted.
var syntheticName = ts.createSynthesizedNode(propName.kind);
syntheticName.text = propName.text;
- if (syntheticName.kind !== 67 /* Identifier */) {
+ if (syntheticName.kind !== 69 /* Identifier */) {
return createElementAccessExpression(object, syntheticName);
}
return createPropertyAccessExpression(object, syntheticName);
}
function createSliceCall(value, sliceIndex) {
- var call = ts.createSynthesizedNode(166 /* CallExpression */);
- var sliceIdentifier = ts.createSynthesizedNode(67 /* Identifier */);
+ var call = ts.createSynthesizedNode(168 /* CallExpression */);
+ var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */);
sliceIdentifier.text = "slice";
call.expression = createPropertyAccessExpression(value, sliceIdentifier);
call.arguments = ts.createSynthesizedNodeArray();
@@ -31369,9 +32428,10 @@ var ts;
}
for (var _a = 0; _a < properties.length; _a++) {
var p = properties[_a];
- if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) {
+ if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) {
var propName = p.name;
- emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName));
+ var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName;
+ emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName));
}
}
}
@@ -31384,8 +32444,8 @@ var ts;
}
for (var i = 0; i < elements.length; i++) {
var e = elements[i];
- if (e.kind !== 185 /* OmittedExpression */) {
- if (e.kind !== 183 /* SpreadElementExpression */) {
+ if (e.kind !== 187 /* OmittedExpression */) {
+ if (e.kind !== 185 /* SpreadElementExpression */) {
emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)));
}
else if (i === elements.length - 1) {
@@ -31395,18 +32455,25 @@ var ts;
}
}
function emitDestructuringAssignment(target, value) {
- if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) {
+ if (target.kind === 246 /* ShorthandPropertyAssignment */) {
+ if (target.objectAssignmentInitializer) {
+ value = createDefaultValueCheck(value, target.objectAssignmentInitializer);
+ }
+ target = target.name;
+ }
+ else if (target.kind === 181 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) {
value = createDefaultValueCheck(value, target.right);
target = target.left;
}
- if (target.kind === 163 /* ObjectLiteralExpression */) {
+ if (target.kind === 165 /* ObjectLiteralExpression */) {
emitObjectLiteralAssignment(target, value);
}
- else if (target.kind === 162 /* ArrayLiteralExpression */) {
+ else if (target.kind === 164 /* ArrayLiteralExpression */) {
emitArrayLiteralAssignment(target, value);
}
else {
- emitAssignment(target, value);
+ emitAssignment(target, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0);
+ emitCount++;
}
}
function emitAssignmentExpression(root) {
@@ -31419,14 +32486,14 @@ var ts;
emitDestructuringAssignment(target, value);
}
else {
- if (root.parent.kind !== 170 /* ParenthesizedExpression */) {
+ if (root.parent.kind !== 172 /* ParenthesizedExpression */) {
write("(");
}
value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true);
emitDestructuringAssignment(target, value);
write(", ");
emit(value);
- if (root.parent.kind !== 170 /* ParenthesizedExpression */) {
+ if (root.parent.kind !== 172 /* ParenthesizedExpression */) {
write(")");
}
}
@@ -31453,12 +32520,12 @@ var ts;
}
for (var i = 0; i < numElements; i++) {
var element = elements[i];
- if (pattern.kind === 159 /* ObjectBindingPattern */) {
+ if (pattern.kind === 161 /* ObjectBindingPattern */) {
// Rewrite element to a declaration with an initializer that fetches property
var propName = element.propertyName || element.name;
emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName));
}
- else if (element.kind !== 185 /* OmittedExpression */) {
+ else if (element.kind !== 187 /* OmittedExpression */) {
if (!element.dotDotDotToken) {
// Rewrite element to a declaration that accesses array element at index i
emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i)));
@@ -31470,7 +32537,8 @@ var ts;
}
}
else {
- emitAssignment(target.name, value);
+ emitAssignment(target.name, value, /*shouldEmitCommaBeforeAssignment*/ emitCount > 0);
+ emitCount++;
}
}
}
@@ -31497,8 +32565,8 @@ var ts;
(getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */);
// NOTE: default initialization should not be added to let bindings in for-in\for-of statements
if (isUninitializedLet &&
- node.parent.parent.kind !== 198 /* ForInStatement */ &&
- node.parent.parent.kind !== 199 /* ForOfStatement */) {
+ node.parent.parent.kind !== 200 /* ForInStatement */ &&
+ node.parent.parent.kind !== 201 /* ForOfStatement */) {
initializer = createVoidZero();
}
}
@@ -31516,11 +32584,11 @@ var ts;
}
}
function emitExportVariableAssignments(node) {
- if (node.kind === 185 /* OmittedExpression */) {
+ if (node.kind === 187 /* OmittedExpression */) {
return;
}
var name = node.name;
- if (name.kind === 67 /* Identifier */) {
+ if (name.kind === 69 /* Identifier */) {
emitExportMemberAssignments(name);
}
else if (ts.isBindingPattern(name)) {
@@ -31528,15 +32596,15 @@ var ts;
}
}
function getCombinedFlagsForIdentifier(node) {
- if (!node.parent || (node.parent.kind !== 209 /* VariableDeclaration */ && node.parent.kind !== 161 /* BindingElement */)) {
+ if (!node.parent || (node.parent.kind !== 211 /* VariableDeclaration */ && node.parent.kind !== 163 /* BindingElement */)) {
return 0;
}
return ts.getCombinedNodeFlags(node.parent);
}
function isES6ExportedDeclaration(node) {
return !!(node.flags & 1 /* Export */) &&
- languageVersion >= 2 /* ES6 */ &&
- node.parent.kind === 246 /* SourceFile */;
+ modulekind === 5 /* ES6 */ &&
+ node.parent.kind === 248 /* SourceFile */;
}
function emitVariableStatement(node) {
var startIsEmitted = false;
@@ -31560,7 +32628,7 @@ var ts;
write(";");
}
}
- if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) {
+ if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) {
ts.forEach(node.declarationList.declarations, emitExportVariableAssignments);
}
}
@@ -31587,12 +32655,12 @@ var ts;
function emitParameter(node) {
if (languageVersion < 2 /* ES6 */) {
if (ts.isBindingPattern(node.name)) {
- var name_23 = createTempVariable(0 /* Auto */);
+ var name_24 = createTempVariable(0 /* Auto */);
if (!tempParameters) {
tempParameters = [];
}
- tempParameters.push(name_23);
- emit(name_23);
+ tempParameters.push(name_24);
+ emit(name_24);
}
else {
emit(node.name);
@@ -31697,12 +32765,12 @@ var ts;
}
}
function emitAccessor(node) {
- write(node.kind === 143 /* GetAccessor */ ? "get " : "set ");
+ write(node.kind === 145 /* GetAccessor */ ? "get " : "set ");
emit(node.name);
emitSignatureAndBody(node);
}
function shouldEmitAsArrowFunction(node) {
- return node.kind === 172 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */;
+ return node.kind === 174 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */;
}
function emitDeclarationName(node) {
if (node.name) {
@@ -31713,24 +32781,24 @@ var ts;
}
}
function shouldEmitFunctionName(node) {
- if (node.kind === 171 /* FunctionExpression */) {
+ if (node.kind === 173 /* FunctionExpression */) {
// Emit name if one is present
return !!node.name;
}
- if (node.kind === 211 /* FunctionDeclaration */) {
+ if (node.kind === 213 /* FunctionDeclaration */) {
// Emit name if one is present, or emit generated name in down-level case (for export default case)
return !!node.name || languageVersion < 2 /* ES6 */;
}
}
function emitFunctionDeclaration(node) {
if (ts.nodeIsMissing(node.body)) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
// TODO (yuisu) : we should not have special cases to condition emitting comments
// but have one place to fix check for these conditions.
- if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */ &&
- node.parent && node.parent.kind !== 243 /* PropertyAssignment */ &&
- node.parent.kind !== 166 /* CallExpression */) {
+ if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */ &&
+ node.parent && node.parent.kind !== 245 /* PropertyAssignment */ &&
+ node.parent.kind !== 168 /* CallExpression */) {
// 1. Methods will emit the comments as part of emitting method declaration
// 2. If the function is a property of object literal, emitting leading-comments
// is done by emitNodeWithoutSourceMap which then call this function.
@@ -31764,11 +32832,11 @@ var ts;
emitDeclarationName(node);
}
emitSignatureAndBody(node);
- if (languageVersion < 2 /* ES6 */ && node.kind === 211 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) {
+ if (modulekind !== 5 /* ES6 */ && node.kind === 213 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) {
emitExportMemberAssignments(node.name);
}
emitEnd(node);
- if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) {
+ if (node.kind !== 143 /* MethodDeclaration */ && node.kind !== 142 /* MethodSignature */) {
emitTrailingComments(node);
}
}
@@ -31801,7 +32869,7 @@ var ts;
}
function emitAsyncFunctionBodyForES6(node) {
var promiseConstructor = ts.getEntityNameFromTypeNode(node.type);
- var isArrowFunction = node.kind === 172 /* ArrowFunction */;
+ var isArrowFunction = node.kind === 174 /* ArrowFunction */;
var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0;
var args;
// An async function is emit as an outer function that calls an inner
@@ -31922,7 +32990,7 @@ var ts;
write(" { }");
}
else {
- if (node.body.kind === 190 /* Block */) {
+ if (node.body.kind === 192 /* Block */) {
emitBlockFunctionBody(node, node.body);
}
else {
@@ -31977,10 +33045,10 @@ var ts;
write(" ");
// Unwrap all type assertions.
var current = body;
- while (current.kind === 169 /* TypeAssertionExpression */) {
+ while (current.kind === 171 /* TypeAssertionExpression */) {
current = current.expression;
}
- emitParenthesizedIf(body, current.kind === 163 /* ObjectLiteralExpression */);
+ emitParenthesizedIf(body, current.kind === 165 /* ObjectLiteralExpression */);
}
function emitDownLevelExpressionFunctionBody(node, body) {
write(" {");
@@ -32056,11 +33124,11 @@ var ts;
function findInitialSuperCall(ctor) {
if (ctor.body) {
var statement = ctor.body.statements[0];
- if (statement && statement.kind === 193 /* ExpressionStatement */) {
+ if (statement && statement.kind === 195 /* ExpressionStatement */) {
var expr = statement.expression;
- if (expr && expr.kind === 166 /* CallExpression */) {
+ if (expr && expr.kind === 168 /* CallExpression */) {
var func = expr.expression;
- if (func && func.kind === 93 /* SuperKeyword */) {
+ if (func && func.kind === 95 /* SuperKeyword */) {
return statement;
}
}
@@ -32092,7 +33160,7 @@ var ts;
emitNodeWithCommentsAndWithoutSourcemap(memberName);
write("]");
}
- else if (memberName.kind === 134 /* ComputedPropertyName */) {
+ else if (memberName.kind === 136 /* ComputedPropertyName */) {
emitComputedPropertyName(memberName);
}
else {
@@ -32104,7 +33172,7 @@ var ts;
var properties = [];
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
- if (member.kind === 139 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) {
+ if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) {
properties.push(member);
}
}
@@ -32144,13 +33212,13 @@ var ts;
}
function emitMemberFunctionsForES5AndLower(node) {
ts.forEach(node.members, function (member) {
- if (member.kind === 189 /* SemicolonClassElement */) {
+ if (member.kind === 191 /* SemicolonClassElement */) {
writeLine();
write(";");
}
- else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) {
+ else if (member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) {
if (!member.body) {
- return emitOnlyPinnedOrTripleSlashComments(member);
+ return emitCommentsOnNotEmittedNode(member);
}
writeLine();
emitLeadingComments(member);
@@ -32165,7 +33233,7 @@ var ts;
write(";");
emitTrailingComments(member);
}
- else if (member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) {
+ else if (member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) {
var accessors = ts.getAllAccessorDeclarations(node.members, member);
if (member === accessors.firstAccessor) {
writeLine();
@@ -32215,22 +33283,22 @@ var ts;
function emitMemberFunctionsForES6AndHigher(node) {
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
- if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ if ((member.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */) && !member.body) {
+ emitCommentsOnNotEmittedNode(member);
}
- else if (member.kind === 141 /* MethodDeclaration */ ||
- member.kind === 143 /* GetAccessor */ ||
- member.kind === 144 /* SetAccessor */) {
+ else if (member.kind === 143 /* MethodDeclaration */ ||
+ member.kind === 145 /* GetAccessor */ ||
+ member.kind === 146 /* SetAccessor */) {
writeLine();
emitLeadingComments(member);
emitStart(member);
if (member.flags & 128 /* Static */) {
write("static ");
}
- if (member.kind === 143 /* GetAccessor */) {
+ if (member.kind === 145 /* GetAccessor */) {
write("get ");
}
- else if (member.kind === 144 /* SetAccessor */) {
+ else if (member.kind === 146 /* SetAccessor */) {
write("set ");
}
if (member.asteriskToken) {
@@ -32241,7 +33309,7 @@ var ts;
emitEnd(member);
emitTrailingComments(member);
}
- else if (member.kind === 189 /* SemicolonClassElement */) {
+ else if (member.kind === 191 /* SemicolonClassElement */) {
writeLine();
write(";");
}
@@ -32266,11 +33334,11 @@ var ts;
var hasInstancePropertyWithInitializer = false;
// Emit the constructor overload pinned comments
ts.forEach(node.members, function (member) {
- if (member.kind === 142 /* Constructor */ && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ if (member.kind === 144 /* Constructor */ && !member.body) {
+ emitCommentsOnNotEmittedNode(member);
}
// Check if there is any non-static property assignment
- if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) {
+ if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) {
hasInstancePropertyWithInitializer = true;
}
});
@@ -32380,10 +33448,13 @@ var ts;
else {
emitClassLikeDeclarationForES6AndHigher(node);
}
+ if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile && node.name) {
+ emitExportMemberAssignments(node.name);
+ }
}
function emitClassLikeDeclarationForES6AndHigher(node) {
var thisNodeIsDecorated = ts.nodeIsDecorated(node);
- if (node.kind === 212 /* ClassDeclaration */) {
+ if (node.kind === 214 /* ClassDeclaration */) {
if (thisNodeIsDecorated) {
// To preserve the correct runtime semantics when decorators are applied to the class,
// the emit needs to follow one of the following rules:
@@ -32397,7 +33468,6 @@ var ts;
//
// let C = class {
// };
- // Object.defineProperty(C, "name", { value: "C", configurable: true });
// C = __decorate([dec], C);
//
// * For an exported class declaration:
@@ -32409,7 +33479,6 @@ var ts;
//
// export let C = class {
// };
- // Object.defineProperty(C, "name", { value: "C", configurable: true });
// C = __decorate([dec], C);
//
// * For a default export of a class declaration with a name:
@@ -32421,7 +33490,6 @@ var ts;
//
// let C = class {
// }
- // Object.defineProperty(C, "name", { value: "C", configurable: true });
// C = __decorate([dec], C);
// export default C;
//
@@ -32463,7 +33531,7 @@ var ts;
// This keeps the expression as an expression, while ensuring that the static parts
// of it have been initialized by the time it is used.
var staticProperties = getInitializedProperties(node, /*static:*/ true);
- var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184 /* ClassExpression */;
+ var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 186 /* ClassExpression */;
var tempVariable;
if (isClassExpressionWithStaticProperties) {
tempVariable = createAndRecordTempVariable(0 /* Auto */);
@@ -32473,8 +33541,10 @@ var ts;
write(" = ");
}
write("class");
- // check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated.
- if ((node.name || !(node.flags & 1024 /* Default */)) && !thisNodeIsDecorated) {
+ // emit name if
+ // - node has a name
+ // - this is default export with static initializers
+ if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) {
write(" ");
emitDeclarationName(node);
}
@@ -32547,7 +33617,7 @@ var ts;
}
}
function emitClassLikeDeclarationBelowES6(node) {
- if (node.kind === 212 /* ClassDeclaration */) {
+ if (node.kind === 214 /* ClassDeclaration */) {
// source file level classes in system modules are hoisted so 'var's for them are already defined
if (!shouldHoistDeclarationInSystemJsModule(node)) {
write("var ");
@@ -32606,16 +33676,13 @@ var ts;
emit(baseTypeNode.expression);
}
write(")");
- if (node.kind === 212 /* ClassDeclaration */) {
+ if (node.kind === 214 /* ClassDeclaration */) {
write(";");
}
emitEnd(node);
- if (node.kind === 212 /* ClassDeclaration */) {
+ if (node.kind === 214 /* ClassDeclaration */) {
emitExportMemberAssignment(node);
}
- if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) {
- emitExportMemberAssignments(node.name);
- }
}
function emitClassMemberPrefix(node, member) {
emitDeclarationName(node);
@@ -32702,7 +33769,7 @@ var ts;
else {
decorators = member.decorators;
// we only decorate the parameters here if this is a method
- if (member.kind === 141 /* MethodDeclaration */) {
+ if (member.kind === 143 /* MethodDeclaration */) {
functionLikeMember = member;
}
}
@@ -32716,21 +33783,19 @@ var ts;
//
// The emit for a method is:
//
- // Object.defineProperty(C.prototype, "method",
- // __decorate([
- // dec,
- // __param(0, dec2),
- // __metadata("design:type", Function),
- // __metadata("design:paramtypes", [Object]),
- // __metadata("design:returntype", void 0)
- // ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
+ // __decorate([
+ // dec,
+ // __param(0, dec2),
+ // __metadata("design:type", Function),
+ // __metadata("design:paramtypes", [Object]),
+ // __metadata("design:returntype", void 0)
+ // ], C.prototype, "method", undefined);
//
// The emit for an accessor is:
//
- // Object.defineProperty(C.prototype, "accessor",
- // __decorate([
- // dec
- // ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
+ // __decorate([
+ // dec
+ // ], C.prototype, "accessor", undefined);
//
// The emit for a property is:
//
@@ -32740,17 +33805,6 @@ var ts;
//
writeLine();
emitStart(member);
- if (member.kind !== 139 /* PropertyDeclaration */) {
- write("Object.defineProperty(");
- emitStart(member.name);
- emitClassMemberPrefix(node, member);
- write(", ");
- emitExpressionForPropertyName(member.name);
- emitEnd(member.name);
- write(",");
- increaseIndent();
- writeLine();
- }
write("__decorate([");
increaseIndent();
writeLine();
@@ -32770,15 +33824,17 @@ var ts;
write(", ");
emitExpressionForPropertyName(member.name);
emitEnd(member.name);
- if (member.kind !== 139 /* PropertyDeclaration */) {
- write(", Object.getOwnPropertyDescriptor(");
- emitStart(member.name);
- emitClassMemberPrefix(node, member);
- write(", ");
- emitExpressionForPropertyName(member.name);
- emitEnd(member.name);
- write("))");
- decreaseIndent();
+ if (languageVersion > 0 /* ES3 */) {
+ if (member.kind !== 141 /* PropertyDeclaration */) {
+ // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
+ // We have this extra argument here so that we can inject an explicit property descriptor at a later date.
+ write(", null");
+ }
+ else {
+ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
+ // should not invoke `Object.getOwnPropertyDescriptor`.
+ write(", void 0");
+ }
}
write(");");
emitEnd(member);
@@ -32812,10 +33868,10 @@ var ts;
// The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata
// compiler option is set.
switch (node.kind) {
- case 141 /* MethodDeclaration */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 139 /* PropertyDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 141 /* PropertyDeclaration */:
return true;
}
return false;
@@ -32825,7 +33881,7 @@ var ts;
// The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata
// compiler option is set.
switch (node.kind) {
- case 141 /* MethodDeclaration */:
+ case 143 /* MethodDeclaration */:
return true;
}
return false;
@@ -32835,9 +33891,9 @@ var ts;
// The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata
// compiler option is set.
switch (node.kind) {
- case 212 /* ClassDeclaration */:
- case 141 /* MethodDeclaration */:
- case 144 /* SetAccessor */:
+ case 214 /* ClassDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 146 /* SetAccessor */:
return true;
}
return false;
@@ -32855,19 +33911,19 @@ var ts;
//
// For rules on serializing type annotations, see `serializeTypeNode`.
switch (node.kind) {
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
write("Function");
return;
- case 139 /* PropertyDeclaration */:
+ case 141 /* PropertyDeclaration */:
emitSerializedTypeNode(node.type);
return;
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
emitSerializedTypeNode(node.type);
return;
- case 143 /* GetAccessor */:
+ case 145 /* GetAccessor */:
emitSerializedTypeNode(node.type);
return;
- case 144 /* SetAccessor */:
+ case 146 /* SetAccessor */:
emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node));
return;
}
@@ -32880,42 +33936,42 @@ var ts;
function emitSerializedTypeNode(node) {
if (node) {
switch (node.kind) {
- case 101 /* VoidKeyword */:
+ case 103 /* VoidKeyword */:
write("void 0");
return;
- case 158 /* ParenthesizedType */:
+ case 160 /* ParenthesizedType */:
emitSerializedTypeNode(node.type);
return;
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
write("Function");
return;
- case 154 /* ArrayType */:
- case 155 /* TupleType */:
+ case 156 /* ArrayType */:
+ case 157 /* TupleType */:
write("Array");
return;
- case 148 /* TypePredicate */:
- case 118 /* BooleanKeyword */:
+ case 150 /* TypePredicate */:
+ case 120 /* BooleanKeyword */:
write("Boolean");
return;
- case 128 /* StringKeyword */:
+ case 130 /* StringKeyword */:
case 9 /* StringLiteral */:
write("String");
return;
- case 126 /* NumberKeyword */:
+ case 128 /* NumberKeyword */:
write("Number");
return;
- case 129 /* SymbolKeyword */:
+ case 131 /* SymbolKeyword */:
write("Symbol");
return;
- case 149 /* TypeReference */:
+ case 151 /* TypeReference */:
emitSerializedTypeReferenceNode(node);
return;
- case 152 /* TypeQuery */:
- case 153 /* TypeLiteral */:
- case 156 /* UnionType */:
- case 157 /* IntersectionType */:
- case 115 /* AnyKeyword */:
+ case 154 /* TypeQuery */:
+ case 155 /* TypeLiteral */:
+ case 158 /* UnionType */:
+ case 159 /* IntersectionType */:
+ case 117 /* AnyKeyword */:
break;
default:
ts.Debug.fail("Cannot serialize unexpected type node.");
@@ -32989,7 +34045,7 @@ var ts;
// For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`.
if (node) {
var valueDeclaration;
- if (node.kind === 212 /* ClassDeclaration */) {
+ if (node.kind === 214 /* ClassDeclaration */) {
valueDeclaration = ts.getFirstConstructorWithBody(node);
}
else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) {
@@ -33005,10 +34061,10 @@ var ts;
}
if (parameters[i].dotDotDotToken) {
var parameterType = parameters[i].type;
- if (parameterType.kind === 154 /* ArrayType */) {
+ if (parameterType.kind === 156 /* ArrayType */) {
parameterType = parameterType.elementType;
}
- else if (parameterType.kind === 149 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) {
+ else if (parameterType.kind === 151 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) {
parameterType = parameterType.typeArguments[0];
}
else {
@@ -33071,7 +34127,7 @@ var ts;
return argumentsWritten;
}
function emitInterfaceDeclaration(node) {
- emitOnlyPinnedOrTripleSlashComments(node);
+ emitCommentsOnNotEmittedNode(node);
}
function shouldEmitEnumDeclaration(node) {
var isConstEnum = ts.isConst(node);
@@ -33126,8 +34182,8 @@ var ts;
emitEnd(node);
write(";");
}
- if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) {
- if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) {
+ if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) {
+ if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) {
// write the call to exporter for enum
writeLine();
write(exportFunctionForFile + "(\"");
@@ -33168,7 +34224,7 @@ var ts;
}
}
function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
- if (moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) {
+ if (moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) {
var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
return recursiveInnerModule || moduleDeclaration.body;
}
@@ -33183,7 +34239,7 @@ var ts;
// Emit only if this module is non-ambient.
var shouldEmit = shouldEmitModuleDeclaration(node);
if (!shouldEmit) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node);
var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
@@ -33204,7 +34260,7 @@ var ts;
write(getGeneratedNameForNode(node));
emitEnd(node.name);
write(") ");
- if (node.body.kind === 217 /* ModuleBlock */) {
+ if (node.body.kind === 219 /* ModuleBlock */) {
var saveTempFlags = tempFlags;
var saveTempVariables = tempVariables;
tempFlags = 0;
@@ -33237,8 +34293,8 @@ var ts;
emitModuleMemberName(node);
write(" = {}));");
emitEnd(node);
- if (!isES6ExportedDeclaration(node) && node.name.kind === 67 /* Identifier */ && node.parent === currentSourceFile) {
- if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) {
+ if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) {
+ if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) {
writeLine();
write(exportFunctionForFile + "(\"");
emitDeclarationName(node);
@@ -33278,16 +34334,16 @@ var ts;
}
}
function getNamespaceDeclarationNode(node) {
- if (node.kind === 219 /* ImportEqualsDeclaration */) {
+ if (node.kind === 221 /* ImportEqualsDeclaration */) {
return node;
}
var importClause = node.importClause;
- if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222 /* NamespaceImport */) {
+ if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 224 /* NamespaceImport */) {
return importClause.namedBindings;
}
}
function isDefaultImport(node) {
- return node.kind === 220 /* ImportDeclaration */ && node.importClause && !!node.importClause.name;
+ return node.kind === 222 /* ImportDeclaration */ && node.importClause && !!node.importClause.name;
}
function emitExportImportAssignments(node) {
if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) {
@@ -33296,7 +34352,7 @@ var ts;
ts.forEachChild(node, emitExportImportAssignments);
}
function emitImportDeclaration(node) {
- if (languageVersion < 2 /* ES6 */) {
+ if (modulekind !== 5 /* ES6 */) {
return emitExternalImportDeclaration(node);
}
// ES6 import
@@ -33315,7 +34371,7 @@ var ts;
if (shouldEmitNamedBindings) {
emitLeadingComments(node.importClause.namedBindings);
emitStart(node.importClause.namedBindings);
- if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) {
+ if (node.importClause.namedBindings.kind === 224 /* NamespaceImport */) {
write("* as ");
emit(node.importClause.namedBindings.name);
}
@@ -33341,9 +34397,9 @@ var ts;
}
function emitExternalImportDeclaration(node) {
if (ts.contains(externalImports, node)) {
- var isExportedImport = node.kind === 219 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0;
+ var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0;
var namespaceDeclaration = getNamespaceDeclarationNode(node);
- if (compilerOptions.module !== 2 /* AMD */) {
+ if (modulekind !== 2 /* AMD */) {
emitLeadingComments(node);
emitStart(node);
if (namespaceDeclaration && !isDefaultImport(node)) {
@@ -33360,7 +34416,7 @@ var ts;
// import { x, y } from "foo"
// import d, * as x from "foo"
// import d, { x, y } from "foo"
- var isNakedImport = 220 /* ImportDeclaration */ && !node.importClause;
+ var isNakedImport = 222 /* ImportDeclaration */ && !node.importClause;
if (!isNakedImport) {
write("var ");
write(getGeneratedNameForNode(node));
@@ -33445,14 +34501,14 @@ var ts;
}
}
function emitExportDeclaration(node) {
- ts.Debug.assert(compilerOptions.module !== 4 /* System */);
- if (languageVersion < 2 /* ES6 */) {
+ ts.Debug.assert(modulekind !== 4 /* System */);
+ if (modulekind !== 5 /* ES6 */) {
if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) {
emitStart(node);
var generatedName = getGeneratedNameForNode(node);
if (node.exportClause) {
// export { x, y, ... } from "foo"
- if (compilerOptions.module !== 2 /* AMD */) {
+ if (modulekind !== 2 /* AMD */) {
write("var ");
write(generatedName);
write(" = ");
@@ -33480,7 +34536,7 @@ var ts;
// export * from "foo"
writeLine();
write("__export(");
- if (compilerOptions.module !== 2 /* AMD */) {
+ if (modulekind !== 2 /* AMD */) {
emitRequire(ts.getExternalModuleName(node));
}
else {
@@ -33512,7 +34568,7 @@ var ts;
}
}
function emitExportOrImportSpecifierList(specifiers, shouldEmit) {
- ts.Debug.assert(languageVersion >= 2 /* ES6 */);
+ ts.Debug.assert(modulekind === 5 /* ES6 */);
var needsComma = false;
for (var _a = 0; _a < specifiers.length; _a++) {
var specifier = specifiers[_a];
@@ -33531,14 +34587,14 @@ var ts;
}
function emitExportAssignment(node) {
if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) {
- if (languageVersion >= 2 /* ES6 */) {
+ if (modulekind === 5 /* ES6 */) {
writeLine();
emitStart(node);
write("export default ");
var expression = node.expression;
emit(expression);
- if (expression.kind !== 211 /* FunctionDeclaration */ &&
- expression.kind !== 212 /* ClassDeclaration */) {
+ if (expression.kind !== 213 /* FunctionDeclaration */ &&
+ expression.kind !== 214 /* ClassDeclaration */) {
write(";");
}
emitEnd(node);
@@ -33546,7 +34602,7 @@ var ts;
else {
writeLine();
emitStart(node);
- if (compilerOptions.module === 4 /* System */) {
+ if (modulekind === 4 /* System */) {
write(exportFunctionForFile + "(\"default\",");
emit(node.expression);
write(")");
@@ -33575,7 +34631,7 @@ var ts;
for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) {
var node = _b[_a];
switch (node.kind) {
- case 220 /* ImportDeclaration */:
+ case 222 /* ImportDeclaration */:
if (!node.importClause ||
resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) {
// import "mod"
@@ -33585,13 +34641,13 @@ var ts;
externalImports.push(node);
}
break;
- case 219 /* ImportEqualsDeclaration */:
- if (node.moduleReference.kind === 230 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) {
+ case 221 /* ImportEqualsDeclaration */:
+ if (node.moduleReference.kind === 232 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) {
// import x = require("mod") where x is referenced
externalImports.push(node);
}
break;
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
if (node.moduleSpecifier) {
if (!node.exportClause) {
// export * from "mod"
@@ -33607,12 +34663,12 @@ var ts;
// export { x, y }
for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) {
var specifier = _d[_c];
- var name_24 = (specifier.propertyName || specifier.name).text;
- (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier);
+ var name_25 = (specifier.propertyName || specifier.name).text;
+ (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier);
}
}
break;
- case 225 /* ExportAssignment */:
+ case 227 /* ExportAssignment */:
if (node.isExportEquals && !exportEquals) {
// export = x
exportEquals = node;
@@ -33638,10 +34694,10 @@ var ts;
if (namespaceDeclaration && !isDefaultImport(node)) {
return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name);
}
- if (node.kind === 220 /* ImportDeclaration */ && node.importClause) {
+ if (node.kind === 222 /* ImportDeclaration */ && node.importClause) {
return getGeneratedNameForNode(node);
}
- if (node.kind === 226 /* ExportDeclaration */ && node.moduleSpecifier) {
+ if (node.kind === 228 /* ExportDeclaration */ && node.moduleSpecifier) {
return getGeneratedNameForNode(node);
}
}
@@ -33661,8 +34717,8 @@ var ts;
for (var _a = 0; _a < externalImports.length; _a++) {
var importNode = externalImports[_a];
// do not create variable declaration for exports and imports that lack import clause
- var skipNode = importNode.kind === 226 /* ExportDeclaration */ ||
- (importNode.kind === 220 /* ImportDeclaration */ && !importNode.importClause);
+ var skipNode = importNode.kind === 228 /* ExportDeclaration */ ||
+ (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause);
if (skipNode) {
continue;
}
@@ -33695,7 +34751,7 @@ var ts;
var hasExportDeclarationWithExportClause = false;
for (var _a = 0; _a < externalImports.length; _a++) {
var externalImport = externalImports[_a];
- if (externalImport.kind === 226 /* ExportDeclaration */ && externalImport.exportClause) {
+ if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) {
hasExportDeclarationWithExportClause = true;
break;
}
@@ -33727,7 +34783,7 @@ var ts;
}
for (var _d = 0; _d < externalImports.length; _d++) {
var externalImport = externalImports[_d];
- if (externalImport.kind !== 226 /* ExportDeclaration */) {
+ if (externalImport.kind !== 228 /* ExportDeclaration */) {
continue;
}
var exportDecl = externalImport;
@@ -33775,7 +34831,7 @@ var ts;
function writeExportedName(node) {
// do not record default exports
// they are local to module and never overwritten (explicitly skipped) by star export
- if (node.kind !== 67 /* Identifier */ && node.flags & 1024 /* Default */) {
+ if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) {
return;
}
if (started) {
@@ -33786,7 +34842,7 @@ var ts;
}
writeLine();
write("'");
- if (node.kind === 67 /* Identifier */) {
+ if (node.kind === 69 /* Identifier */) {
emitNodeWithCommentsAndWithoutSourcemap(node);
}
else {
@@ -33815,12 +34871,12 @@ var ts;
var seen = {};
for (var i = 0; i < hoistedVars.length; ++i) {
var local = hoistedVars[i];
- var name_25 = local.kind === 67 /* Identifier */
+ var name_26 = local.kind === 69 /* Identifier */
? local
: local.name;
- if (name_25) {
+ if (name_26) {
// do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables
- var text = ts.unescapeIdentifier(name_25.text);
+ var text = ts.unescapeIdentifier(name_26.text);
if (ts.hasProperty(seen, text)) {
continue;
}
@@ -33831,13 +34887,13 @@ var ts;
if (i !== 0) {
write(", ");
}
- if (local.kind === 212 /* ClassDeclaration */ || local.kind === 216 /* ModuleDeclaration */ || local.kind === 215 /* EnumDeclaration */) {
+ if (local.kind === 214 /* ClassDeclaration */ || local.kind === 218 /* ModuleDeclaration */ || local.kind === 217 /* EnumDeclaration */) {
emitDeclarationName(local);
}
else {
emit(local);
}
- var flags = ts.getCombinedNodeFlags(local.kind === 67 /* Identifier */ ? local.parent : local);
+ var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local);
if (flags & 1 /* Export */) {
if (!exportedDeclarations) {
exportedDeclarations = [];
@@ -33865,21 +34921,21 @@ var ts;
if (node.flags & 2 /* Ambient */) {
return;
}
- if (node.kind === 211 /* FunctionDeclaration */) {
+ if (node.kind === 213 /* FunctionDeclaration */) {
if (!hoistedFunctionDeclarations) {
hoistedFunctionDeclarations = [];
}
hoistedFunctionDeclarations.push(node);
return;
}
- if (node.kind === 212 /* ClassDeclaration */) {
+ if (node.kind === 214 /* ClassDeclaration */) {
if (!hoistedVars) {
hoistedVars = [];
}
hoistedVars.push(node);
return;
}
- if (node.kind === 215 /* EnumDeclaration */) {
+ if (node.kind === 217 /* EnumDeclaration */) {
if (shouldEmitEnumDeclaration(node)) {
if (!hoistedVars) {
hoistedVars = [];
@@ -33888,7 +34944,7 @@ var ts;
}
return;
}
- if (node.kind === 216 /* ModuleDeclaration */) {
+ if (node.kind === 218 /* ModuleDeclaration */) {
if (shouldEmitModuleDeclaration(node)) {
if (!hoistedVars) {
hoistedVars = [];
@@ -33897,17 +34953,17 @@ var ts;
}
return;
}
- if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) {
+ if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) {
if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) {
- var name_26 = node.name;
- if (name_26.kind === 67 /* Identifier */) {
+ var name_27 = node.name;
+ if (name_27.kind === 69 /* Identifier */) {
if (!hoistedVars) {
hoistedVars = [];
}
- hoistedVars.push(name_26);
+ hoistedVars.push(name_27);
}
else {
- ts.forEachChild(name_26, visit);
+ ts.forEachChild(name_27, visit);
}
}
return;
@@ -33938,10 +34994,10 @@ var ts;
// if block scoped variables are nested in some another block then
// no other functions can use them except ones that are defined at least in the same block
return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 ||
- ts.getEnclosingBlockScopeContainer(node).kind === 246 /* SourceFile */;
+ ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */;
}
function isCurrentFileSystemExternalModule() {
- return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile);
+ return modulekind === 4 /* System */ && ts.isExternalModule(currentSourceFile);
}
function emitSystemModuleBody(node, dependencyGroups, startIndex) {
// shape of the body in system modules:
@@ -34013,21 +35069,21 @@ var ts;
var entry = group[_a];
var importVariableName = getLocalNameForExternalImport(entry) || "";
switch (entry.kind) {
- case 220 /* ImportDeclaration */:
+ case 222 /* ImportDeclaration */:
if (!entry.importClause) {
// 'import "..."' case
// module is imported only for side-effects, no emit required
break;
}
// fall-through
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
ts.Debug.assert(importVariableName !== "");
writeLine();
// save import into the local
write(importVariableName + " = " + parameterName + ";");
writeLine();
break;
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
ts.Debug.assert(importVariableName !== "");
if (entry.exportClause) {
// export {a, b as c} from 'foo'
@@ -34084,10 +35140,10 @@ var ts;
// - import declarations are not emitted since they are already handled in setters
// - export declarations with module specifiers are not emitted since they were already written in setters
// - export declarations without module specifiers are emitted preserving the order
- case 211 /* FunctionDeclaration */:
- case 220 /* ImportDeclaration */:
+ case 213 /* FunctionDeclaration */:
+ case 222 /* ImportDeclaration */:
continue;
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
if (!statement.moduleSpecifier) {
for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) {
var element = _b[_a];
@@ -34096,7 +35152,7 @@ var ts;
}
}
continue;
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
if (!ts.isInternalModuleImportEqualsDeclaration(statement)) {
// - import equals declarations that import external modules are not emitted
continue;
@@ -34111,7 +35167,7 @@ var ts;
writeLine();
write("}"); // execute
}
- function emitSystemModule(node, startIndex) {
+ function emitSystemModule(node) {
collectExternalModuleInfo(node);
// System modules has the following shape
// System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */})
@@ -34152,6 +35208,7 @@ var ts;
write("], function(" + exportFunctionForFile + ") {");
writeLine();
increaseIndent();
+ var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true);
emitEmitHelpers(node);
emitCaptureThisForNodeIfNecessary(node);
emitSystemModuleBody(node, dependencyGroups, startIndex);
@@ -34159,18 +35216,7 @@ var ts;
writeLine();
write("});");
}
- function emitAMDDependencies(node, includeNonAmdDependencies) {
- // An AMD define function has the following shape:
- // define(id?, dependencies?, factory);
- //
- // This has the shape of
- // define(name, ["module1", "module2"], function (module1Alias) {
- // The location of the alias in the parameter list in the factory function needs to
- // match the position of the module name in the dependency list.
- //
- // To ensure this is true in cases of modules with no aliases, e.g.:
- // `import "module"` or ``
- // we need to add modules without alias names to the end of the dependencies list
+ function getAMDDependencyNames(node, includeNonAmdDependencies) {
// names of modules with corresponding parameter in the factory function
var aliasedModuleNames = [];
// names of modules with no corresponding parameters in factory function
@@ -34203,6 +35249,27 @@ var ts;
unaliasedModuleNames.push(externalModuleName);
}
}
+ return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames };
+ }
+ function emitAMDDependencies(node, includeNonAmdDependencies) {
+ // An AMD define function has the following shape:
+ // define(id?, dependencies?, factory);
+ //
+ // This has the shape of
+ // define(name, ["module1", "module2"], function (module1Alias) {
+ // The location of the alias in the parameter list in the factory function needs to
+ // match the position of the module name in the dependency list.
+ //
+ // To ensure this is true in cases of modules with no aliases, e.g.:
+ // `import "module"` or ``
+ // we need to add modules without alias names to the end of the dependencies list
+ var dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies);
+ emitAMDDependencyList(dependencyNames);
+ write(", ");
+ emitAMDFactoryHeader(dependencyNames);
+ }
+ function emitAMDDependencyList(_a) {
+ var aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames;
write("[\"require\", \"exports\"");
if (aliasedModuleNames.length) {
write(", ");
@@ -34212,13 +35279,18 @@ var ts;
write(", ");
write(unaliasedModuleNames.join(", "));
}
- write("], function (require, exports");
+ write("]");
+ }
+ function emitAMDFactoryHeader(_a) {
+ var importAliasNames = _a.importAliasNames;
+ write("function (require, exports");
if (importAliasNames.length) {
write(", ");
write(importAliasNames.join(", "));
}
+ write(") {");
}
- function emitAMDModule(node, startIndex) {
+ function emitAMDModule(node) {
emitEmitHelpers(node);
collectExternalModuleInfo(node);
writeLine();
@@ -34227,8 +35299,8 @@ var ts;
write("\"" + node.moduleName + "\", ");
}
emitAMDDependencies(node, /*includeNonAmdDependencies*/ true);
- write(") {");
increaseIndent();
+ var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true);
emitExportStarHelper();
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
@@ -34238,7 +35310,8 @@ var ts;
writeLine();
write("});");
}
- function emitCommonJSModule(node, startIndex) {
+ function emitCommonJSModule(node) {
+ var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
emitEmitHelpers(node);
collectExternalModuleInfo(node);
emitExportStarHelper();
@@ -34247,14 +35320,18 @@ var ts;
emitTempDeclarations(/*newLine*/ true);
emitExportEquals(/*emitAsReturn*/ false);
}
- function emitUMDModule(node, startIndex) {
+ function emitUMDModule(node) {
emitEmitHelpers(node);
collectExternalModuleInfo(node);
+ var dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false);
// Module is detected first to support Browserify users that load into a browser with an AMD loader
- writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})(");
- emitAMDDependencies(node, false);
- write(") {");
+ writeLines("(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(");
+ emitAMDDependencyList(dependencyNames);
+ write(", factory);");
+ writeLines(" }\n})(");
+ emitAMDFactoryHeader(dependencyNames);
increaseIndent();
+ var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true);
emitExportStarHelper();
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
@@ -34264,11 +35341,12 @@ var ts;
writeLine();
write("});");
}
- function emitES6Module(node, startIndex) {
+ function emitES6Module(node) {
externalImports = undefined;
exportSpecifiers = undefined;
exportEquals = undefined;
hasExportStars = false;
+ var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
emitEmitHelpers(node);
emitCaptureThisForNodeIfNecessary(node);
emitLinesStartingAt(node.statements, startIndex);
@@ -34311,7 +35389,7 @@ var ts;
if (ts.isLineBreak(c)) {
if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) {
var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1);
- result = (result ? result + "\" + ' ' + \"" : "") + part;
+ result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part);
}
firstNonWhitespace = -1;
}
@@ -34324,7 +35402,7 @@ var ts;
}
if (firstNonWhitespace !== -1) {
var part = text.substr(firstNonWhitespace);
- result = (result ? result + "\" + ' ' + \"" : "") + part;
+ result = (result ? result + "\" + ' ' + \"" : "") + ts.escapeString(part);
}
if (result) {
// Replace entities like
@@ -34438,26 +35516,13 @@ var ts;
writeLine();
emitShebang();
emitDetachedComments(node);
- // emit prologue directives prior to __extends
- var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
- if (languageVersion >= 2 /* ES6 */) {
- emitES6Module(node, startIndex);
- }
- else if (compilerOptions.module === 2 /* AMD */) {
- emitAMDModule(node, startIndex);
- }
- else if (compilerOptions.module === 4 /* System */) {
- emitSystemModule(node, startIndex);
- }
- else if (compilerOptions.module === 3 /* UMD */) {
- emitUMDModule(node, startIndex);
- }
- else {
- emitCommonJSModule(node, startIndex);
- }
+ var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */];
+ emitModule(node);
}
else {
+ // emit prologue directives prior to __extends
+ var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
externalImports = undefined;
exportSpecifiers = undefined;
exportEquals = undefined;
@@ -34475,7 +35540,7 @@ var ts;
function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) {
if (node) {
if (node.flags & 2 /* Ambient */) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (isSpecializedCommentHandling(node)) {
// This is the node that will handle its own comments and sourcemap
@@ -34500,38 +35565,38 @@ var ts;
switch (node.kind) {
// All of these entities are emitted in a specialized fashion. As such, we allow
// the specialized methods for each to handle the comments on the nodes.
- case 213 /* InterfaceDeclaration */:
- case 211 /* FunctionDeclaration */:
- case 220 /* ImportDeclaration */:
- case 219 /* ImportEqualsDeclaration */:
- case 214 /* TypeAliasDeclaration */:
- case 225 /* ExportAssignment */:
+ case 215 /* InterfaceDeclaration */:
+ case 213 /* FunctionDeclaration */:
+ case 222 /* ImportDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
+ case 227 /* ExportAssignment */:
return true;
}
}
function shouldEmitLeadingAndTrailingComments(node) {
switch (node.kind) {
- case 191 /* VariableStatement */:
+ case 193 /* VariableStatement */:
return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node);
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
// Only emit the leading/trailing comments for a module if we're actually
// emitting the module as well.
return shouldEmitModuleDeclaration(node);
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
// Only emit the leading/trailing comments for an enum if we're actually
// emitting the module as well.
return shouldEmitEnumDeclaration(node);
}
- // If the node is emitted in specialized fashion, dont emit comments as this node will handle
+ // If the node is emitted in specialized fashion, dont emit comments as this node will handle
// emitting comments when emitting itself
ts.Debug.assert(!isSpecializedCommentHandling(node));
// If this is the expression body of an arrow function that we're down-leveling,
// then we don't want to emit comments when we emit the body. It will have already
// been taken care of when we emitted the 'return' statement for the function
// expression body.
- if (node.kind !== 190 /* Block */ &&
+ if (node.kind !== 192 /* Block */ &&
node.parent &&
- node.parent.kind === 172 /* ArrowFunction */ &&
+ node.parent.kind === 174 /* ArrowFunction */ &&
node.parent.body === node &&
compilerOptions.target <= 1 /* ES5 */) {
return false;
@@ -34542,25 +35607,25 @@ var ts;
function emitJavaScriptWorker(node) {
// Check if the node can be emitted regardless of the ScriptTarget
switch (node.kind) {
- case 67 /* Identifier */:
+ case 69 /* Identifier */:
return emitIdentifier(node);
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
return emitParameter(node);
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
return emitMethod(node);
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
return emitAccessor(node);
- case 95 /* ThisKeyword */:
+ case 97 /* ThisKeyword */:
return emitThis(node);
- case 93 /* SuperKeyword */:
+ case 95 /* SuperKeyword */:
return emitSuper(node);
- case 91 /* NullKeyword */:
+ case 93 /* NullKeyword */:
return write("null");
- case 97 /* TrueKeyword */:
+ case 99 /* TrueKeyword */:
return write("true");
- case 82 /* FalseKeyword */:
+ case 84 /* FalseKeyword */:
return write("false");
case 8 /* NumericLiteral */:
case 9 /* StringLiteral */:
@@ -34570,142 +35635,142 @@ var ts;
case 13 /* TemplateMiddle */:
case 14 /* TemplateTail */:
return emitLiteral(node);
- case 181 /* TemplateExpression */:
+ case 183 /* TemplateExpression */:
return emitTemplateExpression(node);
- case 188 /* TemplateSpan */:
+ case 190 /* TemplateSpan */:
return emitTemplateSpan(node);
- case 231 /* JsxElement */:
- case 232 /* JsxSelfClosingElement */:
+ case 233 /* JsxElement */:
+ case 234 /* JsxSelfClosingElement */:
return emitJsxElement(node);
- case 234 /* JsxText */:
+ case 236 /* JsxText */:
return emitJsxText(node);
- case 238 /* JsxExpression */:
+ case 240 /* JsxExpression */:
return emitJsxExpression(node);
- case 133 /* QualifiedName */:
+ case 135 /* QualifiedName */:
return emitQualifiedName(node);
- case 159 /* ObjectBindingPattern */:
+ case 161 /* ObjectBindingPattern */:
return emitObjectBindingPattern(node);
- case 160 /* ArrayBindingPattern */:
+ case 162 /* ArrayBindingPattern */:
return emitArrayBindingPattern(node);
- case 161 /* BindingElement */:
+ case 163 /* BindingElement */:
return emitBindingElement(node);
- case 162 /* ArrayLiteralExpression */:
+ case 164 /* ArrayLiteralExpression */:
return emitArrayLiteral(node);
- case 163 /* ObjectLiteralExpression */:
+ case 165 /* ObjectLiteralExpression */:
return emitObjectLiteral(node);
- case 243 /* PropertyAssignment */:
+ case 245 /* PropertyAssignment */:
return emitPropertyAssignment(node);
- case 244 /* ShorthandPropertyAssignment */:
+ case 246 /* ShorthandPropertyAssignment */:
return emitShorthandPropertyAssignment(node);
- case 134 /* ComputedPropertyName */:
+ case 136 /* ComputedPropertyName */:
return emitComputedPropertyName(node);
- case 164 /* PropertyAccessExpression */:
+ case 166 /* PropertyAccessExpression */:
return emitPropertyAccess(node);
- case 165 /* ElementAccessExpression */:
+ case 167 /* ElementAccessExpression */:
return emitIndexedAccess(node);
- case 166 /* CallExpression */:
+ case 168 /* CallExpression */:
return emitCallExpression(node);
- case 167 /* NewExpression */:
+ case 169 /* NewExpression */:
return emitNewExpression(node);
- case 168 /* TaggedTemplateExpression */:
+ case 170 /* TaggedTemplateExpression */:
return emitTaggedTemplateExpression(node);
- case 169 /* TypeAssertionExpression */:
+ case 171 /* TypeAssertionExpression */:
return emit(node.expression);
- case 187 /* AsExpression */:
+ case 189 /* AsExpression */:
return emit(node.expression);
- case 170 /* ParenthesizedExpression */:
+ case 172 /* ParenthesizedExpression */:
return emitParenExpression(node);
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
return emitFunctionDeclaration(node);
- case 173 /* DeleteExpression */:
+ case 175 /* DeleteExpression */:
return emitDeleteExpression(node);
- case 174 /* TypeOfExpression */:
+ case 176 /* TypeOfExpression */:
return emitTypeOfExpression(node);
- case 175 /* VoidExpression */:
+ case 177 /* VoidExpression */:
return emitVoidExpression(node);
- case 176 /* AwaitExpression */:
+ case 178 /* AwaitExpression */:
return emitAwaitExpression(node);
- case 177 /* PrefixUnaryExpression */:
+ case 179 /* PrefixUnaryExpression */:
return emitPrefixUnaryExpression(node);
- case 178 /* PostfixUnaryExpression */:
+ case 180 /* PostfixUnaryExpression */:
return emitPostfixUnaryExpression(node);
- case 179 /* BinaryExpression */:
+ case 181 /* BinaryExpression */:
return emitBinaryExpression(node);
- case 180 /* ConditionalExpression */:
+ case 182 /* ConditionalExpression */:
return emitConditionalExpression(node);
- case 183 /* SpreadElementExpression */:
+ case 185 /* SpreadElementExpression */:
return emitSpreadElementExpression(node);
- case 182 /* YieldExpression */:
+ case 184 /* YieldExpression */:
return emitYieldExpression(node);
- case 185 /* OmittedExpression */:
+ case 187 /* OmittedExpression */:
return;
- case 190 /* Block */:
- case 217 /* ModuleBlock */:
+ case 192 /* Block */:
+ case 219 /* ModuleBlock */:
return emitBlock(node);
- case 191 /* VariableStatement */:
+ case 193 /* VariableStatement */:
return emitVariableStatement(node);
- case 192 /* EmptyStatement */:
+ case 194 /* EmptyStatement */:
return write(";");
- case 193 /* ExpressionStatement */:
+ case 195 /* ExpressionStatement */:
return emitExpressionStatement(node);
- case 194 /* IfStatement */:
+ case 196 /* IfStatement */:
return emitIfStatement(node);
- case 195 /* DoStatement */:
+ case 197 /* DoStatement */:
return emitDoStatement(node);
- case 196 /* WhileStatement */:
+ case 198 /* WhileStatement */:
return emitWhileStatement(node);
- case 197 /* ForStatement */:
+ case 199 /* ForStatement */:
return emitForStatement(node);
- case 199 /* ForOfStatement */:
- case 198 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 200 /* ForInStatement */:
return emitForInOrForOfStatement(node);
- case 200 /* ContinueStatement */:
- case 201 /* BreakStatement */:
+ case 202 /* ContinueStatement */:
+ case 203 /* BreakStatement */:
return emitBreakOrContinueStatement(node);
- case 202 /* ReturnStatement */:
+ case 204 /* ReturnStatement */:
return emitReturnStatement(node);
- case 203 /* WithStatement */:
+ case 205 /* WithStatement */:
return emitWithStatement(node);
- case 204 /* SwitchStatement */:
+ case 206 /* SwitchStatement */:
return emitSwitchStatement(node);
- case 239 /* CaseClause */:
- case 240 /* DefaultClause */:
+ case 241 /* CaseClause */:
+ case 242 /* DefaultClause */:
return emitCaseOrDefaultClause(node);
- case 205 /* LabeledStatement */:
+ case 207 /* LabeledStatement */:
return emitLabelledStatement(node);
- case 206 /* ThrowStatement */:
+ case 208 /* ThrowStatement */:
return emitThrowStatement(node);
- case 207 /* TryStatement */:
+ case 209 /* TryStatement */:
return emitTryStatement(node);
- case 242 /* CatchClause */:
+ case 244 /* CatchClause */:
return emitCatchClause(node);
- case 208 /* DebuggerStatement */:
+ case 210 /* DebuggerStatement */:
return emitDebuggerStatement(node);
- case 209 /* VariableDeclaration */:
+ case 211 /* VariableDeclaration */:
return emitVariableDeclaration(node);
- case 184 /* ClassExpression */:
+ case 186 /* ClassExpression */:
return emitClassExpression(node);
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
return emitClassDeclaration(node);
- case 213 /* InterfaceDeclaration */:
+ case 215 /* InterfaceDeclaration */:
return emitInterfaceDeclaration(node);
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
return emitEnumDeclaration(node);
- case 245 /* EnumMember */:
+ case 247 /* EnumMember */:
return emitEnumMember(node);
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
return emitModuleDeclaration(node);
- case 220 /* ImportDeclaration */:
+ case 222 /* ImportDeclaration */:
return emitImportDeclaration(node);
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
return emitImportEqualsDeclaration(node);
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
return emitExportDeclaration(node);
- case 225 /* ExportAssignment */:
+ case 227 /* ExportAssignment */:
return emitExportAssignment(node);
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
return emitSourceFileNode(node);
}
}
@@ -34723,26 +35788,32 @@ var ts;
}
return leadingComments;
}
+ function isPinnedComments(comment) {
+ return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
+ }
/**
- * Removes all but the pinned or triple slash comments.
- * @param ranges The array to be filtered
- * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed.
- */
- function filterComments(ranges, onlyPinnedOrTripleSlashComments) {
- // If we're removing comments, then we want to strip out all but the pinned or
- // triple slash comments.
- if (ranges && onlyPinnedOrTripleSlashComments) {
- ranges = ts.filter(ranges, isPinnedOrTripleSlashComment);
- if (ranges.length === 0) {
- return undefined;
- }
+ * Determine if the given comment is a triple-slash
+ *
+ * @return true if the comment is a triple-slash comment else false
+ **/
+ function isTripleSlashComment(comment) {
+ // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
+ // so that we don't end up computing comment string and doing match for all // comments
+ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ &&
+ comment.pos + 2 < comment.end &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) {
+ var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
+ return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
+ textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ?
+ true : false;
}
- return ranges;
+ return false;
}
function getLeadingCommentsToEmit(node) {
// Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
if (node.parent) {
- if (node.parent.kind === 246 /* SourceFile */ || node.pos !== node.parent.pos) {
+ if (node.parent.kind === 248 /* SourceFile */ || node.pos !== node.parent.pos) {
if (hasDetachedComments(node.pos)) {
// get comments without detached comments
return getLeadingCommentsWithoutDetachedComments();
@@ -34757,28 +35828,51 @@ var ts;
function getTrailingCommentsToEmit(node) {
// Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments
if (node.parent) {
- if (node.parent.kind === 246 /* SourceFile */ || node.end !== node.parent.end) {
+ if (node.parent.kind === 248 /* SourceFile */ || node.end !== node.parent.end) {
return ts.getTrailingCommentRanges(currentSourceFile.text, node.end);
}
}
}
- function emitOnlyPinnedOrTripleSlashComments(node) {
- emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true);
+ /**
+ * Emit comments associated with node that will not be emitted into JS file
+ */
+ function emitCommentsOnNotEmittedNode(node) {
+ emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false);
}
function emitLeadingComments(node) {
- return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true);
}
- function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) {
- // If the caller only wants pinned or triple slash comments, then always filter
- // down to that set. Otherwise, filter based on the current compiler options.
- var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments);
+ function emitLeadingCommentsWorker(node, isEmittedNode) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var leadingComments;
+ if (isEmittedNode) {
+ leadingComments = getLeadingCommentsToEmit(node);
+ }
+ else {
+ // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node,
+ // unless it is a triple slash comment at the top of the file.
+ // For Example:
+ // ///
+ // declare var x;
+ // ///
+ // interface F {}
+ // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted
+ if (node.pos === 0) {
+ leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
+ }
+ }
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
- ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
+ ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment);
}
function emitTrailingComments(node) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
// Emit the trailing comments only if the parent's end doesn't match
- var trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ var trailingComments = getTrailingCommentsToEmit(node);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment);
}
@@ -34788,11 +35882,17 @@ var ts;
* ^ => pos; the function will emit "comment1" in the emitJS
*/
function emitTrailingCommentsOfPosition(pos) {
- var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
- function emitLeadingCommentsOfPosition(pos) {
+ function emitLeadingCommentsOfPositionWorker(pos) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
var leadingComments;
if (hasDetachedComments(pos)) {
// get comments without detached comments
@@ -34802,13 +35902,26 @@ var ts;
// get the leading comments from the node
leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos);
}
- leadingComments = filterComments(leadingComments, compilerOptions.removeComments);
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
function emitDetachedComments(node) {
- var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ var leadingComments;
+ if (compilerOptions.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(currentSourceFile.text, node.pos), isPinnedComments);
+ }
+ }
+ else {
+ // removeComments is false, just get detached as normal and bypass the process to filter comment
+ leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ }
if (leadingComments) {
var detachedComments = [];
var lastComment;
@@ -34853,17 +35966,7 @@ var ts;
write(shebang);
}
}
- function isPinnedOrTripleSlashComment(comment) {
- if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) {
- return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
- }
- else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ &&
- comment.pos + 2 < comment.end &&
- currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */ &&
- currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) {
- return true;
- }
- }
+ var _a;
}
function emitFile(jsFilePath, sourceFile) {
emitJavaScript(jsFilePath, sourceFile);
@@ -34873,261 +35976,6 @@ var ts;
}
}
ts.emitFiles = emitFiles;
- var entities = {
- "quot": 0x0022,
- "amp": 0x0026,
- "apos": 0x0027,
- "lt": 0x003C,
- "gt": 0x003E,
- "nbsp": 0x00A0,
- "iexcl": 0x00A1,
- "cent": 0x00A2,
- "pound": 0x00A3,
- "curren": 0x00A4,
- "yen": 0x00A5,
- "brvbar": 0x00A6,
- "sect": 0x00A7,
- "uml": 0x00A8,
- "copy": 0x00A9,
- "ordf": 0x00AA,
- "laquo": 0x00AB,
- "not": 0x00AC,
- "shy": 0x00AD,
- "reg": 0x00AE,
- "macr": 0x00AF,
- "deg": 0x00B0,
- "plusmn": 0x00B1,
- "sup2": 0x00B2,
- "sup3": 0x00B3,
- "acute": 0x00B4,
- "micro": 0x00B5,
- "para": 0x00B6,
- "middot": 0x00B7,
- "cedil": 0x00B8,
- "sup1": 0x00B9,
- "ordm": 0x00BA,
- "raquo": 0x00BB,
- "frac14": 0x00BC,
- "frac12": 0x00BD,
- "frac34": 0x00BE,
- "iquest": 0x00BF,
- "Agrave": 0x00C0,
- "Aacute": 0x00C1,
- "Acirc": 0x00C2,
- "Atilde": 0x00C3,
- "Auml": 0x00C4,
- "Aring": 0x00C5,
- "AElig": 0x00C6,
- "Ccedil": 0x00C7,
- "Egrave": 0x00C8,
- "Eacute": 0x00C9,
- "Ecirc": 0x00CA,
- "Euml": 0x00CB,
- "Igrave": 0x00CC,
- "Iacute": 0x00CD,
- "Icirc": 0x00CE,
- "Iuml": 0x00CF,
- "ETH": 0x00D0,
- "Ntilde": 0x00D1,
- "Ograve": 0x00D2,
- "Oacute": 0x00D3,
- "Ocirc": 0x00D4,
- "Otilde": 0x00D5,
- "Ouml": 0x00D6,
- "times": 0x00D7,
- "Oslash": 0x00D8,
- "Ugrave": 0x00D9,
- "Uacute": 0x00DA,
- "Ucirc": 0x00DB,
- "Uuml": 0x00DC,
- "Yacute": 0x00DD,
- "THORN": 0x00DE,
- "szlig": 0x00DF,
- "agrave": 0x00E0,
- "aacute": 0x00E1,
- "acirc": 0x00E2,
- "atilde": 0x00E3,
- "auml": 0x00E4,
- "aring": 0x00E5,
- "aelig": 0x00E6,
- "ccedil": 0x00E7,
- "egrave": 0x00E8,
- "eacute": 0x00E9,
- "ecirc": 0x00EA,
- "euml": 0x00EB,
- "igrave": 0x00EC,
- "iacute": 0x00ED,
- "icirc": 0x00EE,
- "iuml": 0x00EF,
- "eth": 0x00F0,
- "ntilde": 0x00F1,
- "ograve": 0x00F2,
- "oacute": 0x00F3,
- "ocirc": 0x00F4,
- "otilde": 0x00F5,
- "ouml": 0x00F6,
- "divide": 0x00F7,
- "oslash": 0x00F8,
- "ugrave": 0x00F9,
- "uacute": 0x00FA,
- "ucirc": 0x00FB,
- "uuml": 0x00FC,
- "yacute": 0x00FD,
- "thorn": 0x00FE,
- "yuml": 0x00FF,
- "OElig": 0x0152,
- "oelig": 0x0153,
- "Scaron": 0x0160,
- "scaron": 0x0161,
- "Yuml": 0x0178,
- "fnof": 0x0192,
- "circ": 0x02C6,
- "tilde": 0x02DC,
- "Alpha": 0x0391,
- "Beta": 0x0392,
- "Gamma": 0x0393,
- "Delta": 0x0394,
- "Epsilon": 0x0395,
- "Zeta": 0x0396,
- "Eta": 0x0397,
- "Theta": 0x0398,
- "Iota": 0x0399,
- "Kappa": 0x039A,
- "Lambda": 0x039B,
- "Mu": 0x039C,
- "Nu": 0x039D,
- "Xi": 0x039E,
- "Omicron": 0x039F,
- "Pi": 0x03A0,
- "Rho": 0x03A1,
- "Sigma": 0x03A3,
- "Tau": 0x03A4,
- "Upsilon": 0x03A5,
- "Phi": 0x03A6,
- "Chi": 0x03A7,
- "Psi": 0x03A8,
- "Omega": 0x03A9,
- "alpha": 0x03B1,
- "beta": 0x03B2,
- "gamma": 0x03B3,
- "delta": 0x03B4,
- "epsilon": 0x03B5,
- "zeta": 0x03B6,
- "eta": 0x03B7,
- "theta": 0x03B8,
- "iota": 0x03B9,
- "kappa": 0x03BA,
- "lambda": 0x03BB,
- "mu": 0x03BC,
- "nu": 0x03BD,
- "xi": 0x03BE,
- "omicron": 0x03BF,
- "pi": 0x03C0,
- "rho": 0x03C1,
- "sigmaf": 0x03C2,
- "sigma": 0x03C3,
- "tau": 0x03C4,
- "upsilon": 0x03C5,
- "phi": 0x03C6,
- "chi": 0x03C7,
- "psi": 0x03C8,
- "omega": 0x03C9,
- "thetasym": 0x03D1,
- "upsih": 0x03D2,
- "piv": 0x03D6,
- "ensp": 0x2002,
- "emsp": 0x2003,
- "thinsp": 0x2009,
- "zwnj": 0x200C,
- "zwj": 0x200D,
- "lrm": 0x200E,
- "rlm": 0x200F,
- "ndash": 0x2013,
- "mdash": 0x2014,
- "lsquo": 0x2018,
- "rsquo": 0x2019,
- "sbquo": 0x201A,
- "ldquo": 0x201C,
- "rdquo": 0x201D,
- "bdquo": 0x201E,
- "dagger": 0x2020,
- "Dagger": 0x2021,
- "bull": 0x2022,
- "hellip": 0x2026,
- "permil": 0x2030,
- "prime": 0x2032,
- "Prime": 0x2033,
- "lsaquo": 0x2039,
- "rsaquo": 0x203A,
- "oline": 0x203E,
- "frasl": 0x2044,
- "euro": 0x20AC,
- "image": 0x2111,
- "weierp": 0x2118,
- "real": 0x211C,
- "trade": 0x2122,
- "alefsym": 0x2135,
- "larr": 0x2190,
- "uarr": 0x2191,
- "rarr": 0x2192,
- "darr": 0x2193,
- "harr": 0x2194,
- "crarr": 0x21B5,
- "lArr": 0x21D0,
- "uArr": 0x21D1,
- "rArr": 0x21D2,
- "dArr": 0x21D3,
- "hArr": 0x21D4,
- "forall": 0x2200,
- "part": 0x2202,
- "exist": 0x2203,
- "empty": 0x2205,
- "nabla": 0x2207,
- "isin": 0x2208,
- "notin": 0x2209,
- "ni": 0x220B,
- "prod": 0x220F,
- "sum": 0x2211,
- "minus": 0x2212,
- "lowast": 0x2217,
- "radic": 0x221A,
- "prop": 0x221D,
- "infin": 0x221E,
- "ang": 0x2220,
- "and": 0x2227,
- "or": 0x2228,
- "cap": 0x2229,
- "cup": 0x222A,
- "int": 0x222B,
- "there4": 0x2234,
- "sim": 0x223C,
- "cong": 0x2245,
- "asymp": 0x2248,
- "ne": 0x2260,
- "equiv": 0x2261,
- "le": 0x2264,
- "ge": 0x2265,
- "sub": 0x2282,
- "sup": 0x2283,
- "nsub": 0x2284,
- "sube": 0x2286,
- "supe": 0x2287,
- "oplus": 0x2295,
- "otimes": 0x2297,
- "perp": 0x22A5,
- "sdot": 0x22C5,
- "lceil": 0x2308,
- "rceil": 0x2309,
- "lfloor": 0x230A,
- "rfloor": 0x230B,
- "lang": 0x2329,
- "rang": 0x232A,
- "loz": 0x25CA,
- "spades": 0x2660,
- "clubs": 0x2663,
- "hearts": 0x2665,
- "diams": 0x2666
- };
})(ts || (ts = {}));
///
///
@@ -35140,7 +35988,7 @@ var ts;
/* @internal */ ts.ioWriteTime = 0;
/** The version of the TypeScript compiler release */
var emptyArray = [];
- ts.version = "1.6.2";
+ ts.version = "1.7.3";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@@ -35178,11 +36026,11 @@ var ts;
if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
var failedLookupLocations = [];
var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
- var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
+ var resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
if (resolvedFileName) {
return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations };
}
- resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
+ resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host);
return resolvedFileName
? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }
: { resolvedModule: undefined, failedLookupLocations: failedLookupLocations };
@@ -35192,13 +36040,8 @@ var ts;
}
}
ts.nodeModuleNameResolver = nodeModuleNameResolver;
- function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) {
- if (loadOnlyDts) {
- return tryLoad(".d.ts");
- }
- else {
- return ts.forEach(ts.supportedExtensions, tryLoad);
- }
+ function loadNodeModuleFromFile(candidate, failedLookupLocation, host) {
+ return ts.forEach(ts.moduleFileExtensions, tryLoad);
function tryLoad(ext) {
var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
if (host.fileExists(fileName)) {
@@ -35210,7 +36053,7 @@ var ts;
}
}
}
- function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) {
+ function loadNodeModuleFromDirectory(candidate, failedLookupLocation, host) {
var packageJsonPath = ts.combinePaths(candidate, "package.json");
if (host.fileExists(packageJsonPath)) {
var jsonContent;
@@ -35223,7 +36066,7 @@ var ts;
jsonContent = { typings: undefined };
}
if (jsonContent.typings) {
- var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host);
+ var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host);
if (result) {
return result;
}
@@ -35233,7 +36076,7 @@ var ts;
// record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results
failedLookupLocation.push(packageJsonPath);
}
- return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host);
+ return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), failedLookupLocation, host);
}
function loadModuleFromNodeModules(moduleName, directory, host) {
var failedLookupLocations = [];
@@ -35243,11 +36086,11 @@ var ts;
if (baseName !== "node_modules") {
var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName));
- var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
+ var result = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
if (result) {
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations };
}
- result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
+ result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host);
if (result) {
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations };
}
@@ -35266,7 +36109,7 @@ var ts;
}
function classicNameResolver(moduleName, containingFile, compilerOptions, host) {
// module names that contain '!' are used to reference resources and are not resolved to actual files on disk
- if (moduleName.indexOf('!') != -1) {
+ if (moduleName.indexOf("!") != -1) {
return { resolvedModule: undefined, failedLookupLocations: [] };
}
var searchPath = ts.getDirectoryPath(containingFile);
@@ -35613,7 +36456,9 @@ var ts;
return emitResult;
}
function getSourceFile(fileName) {
- return filesByName.get(fileName);
+ // first try to use file name as is to find file
+ // then try to convert relative file name to absolute and use it to retrieve source file
+ return filesByName.get(fileName) || filesByName.get(ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()));
}
function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) {
if (sourceFile) {
@@ -35712,10 +36557,14 @@ var ts;
var imports;
for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
var node = _a[_i];
+ collect(node, /* allowRelativeModuleNames */ true);
+ }
+ file.imports = imports || emptyArray;
+ function collect(node, allowRelativeModuleNames) {
switch (node.kind) {
- case 220 /* ImportDeclaration */:
- case 219 /* ImportEqualsDeclaration */:
- case 226 /* ExportDeclaration */:
+ case 222 /* ImportDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 228 /* ExportDeclaration */:
var moduleNameExpr = ts.getExternalModuleName(node);
if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) {
break;
@@ -35723,9 +36572,11 @@ var ts;
if (!moduleNameExpr.text) {
break;
}
- (imports || (imports = [])).push(moduleNameExpr);
+ if (allowRelativeModuleNames || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) {
+ (imports || (imports = [])).push(moduleNameExpr);
+ }
break;
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) {
// TypeScript 1.0 spec (April 2014): 12.1.6
// An AmbientExternalModuleDeclaration declares an external module.
@@ -35733,22 +36584,15 @@ var ts;
// The StringLiteral must specify a top - level external module name.
// Relative external module names are not permitted
ts.forEachChild(node.body, function (node) {
- if (ts.isExternalModuleImportEqualsDeclaration(node) &&
- ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9 /* StringLiteral */) {
- var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node);
- // TypeScript 1.0 spec (April 2014): 12.1.6
- // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
- // only through top - level external module names. Relative external module names are not permitted.
- if (moduleName) {
- (imports || (imports = [])).push(moduleName);
- }
- }
+ // TypeScript 1.0 spec (April 2014): 12.1.6
+ // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
+ // only through top - level external module names. Relative external module names are not permitted.
+ collect(node, /* allowRelativeModuleNames */ false);
});
}
break;
}
}
- file.imports = imports || emptyArray;
}
function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) {
var diagnosticArgument;
@@ -35792,52 +36636,52 @@ var ts;
}
// Get source file from normalized fileName
function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) {
- var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName));
- if (filesByName.contains(canonicalName)) {
+ if (filesByName.contains(fileName)) {
// We've already looked for this file, use cached result
- return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false);
+ return getSourceFileFromCache(fileName, /*useAbsolutePath*/ false);
}
- else {
- var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
- var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
- if (filesByName.contains(canonicalAbsolutePath)) {
- return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true);
+ var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
+ if (filesByName.contains(normalizedAbsolutePath)) {
+ var file_1 = getSourceFileFromCache(normalizedAbsolutePath, /*useAbsolutePath*/ true);
+ // we don't have resolution for this relative file name but the match was found by absolute file name
+ // store resolution for relative name as well
+ filesByName.set(fileName, file_1);
+ return file_1;
+ }
+ // We haven't looked for this file, do so now and cache result
+ var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) {
+ if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
- // We haven't looked for this file, do so now and cache result
- var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) {
- if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
- fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
- }
- else {
- fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
- }
- });
- filesByName.set(canonicalName, file);
- if (file) {
- skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
- // Set the source file for normalized absolute path
- filesByName.set(canonicalAbsolutePath, file);
- var basePath = ts.getDirectoryPath(fileName);
- if (!options.noResolve) {
- processReferencedFiles(file, basePath);
- }
- // always process imported modules to record module name resolutions
- processImportedModules(file, basePath);
- if (isDefaultLib) {
- file.isDefaultLib = true;
- files.unshift(file);
- }
- else {
- files.push(file);
- }
+ else {
+ fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
+ }
+ });
+ filesByName.set(fileName, file);
+ if (file) {
+ skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
+ // Set the source file for normalized absolute path
+ filesByName.set(normalizedAbsolutePath, file);
+ var basePath = ts.getDirectoryPath(fileName);
+ if (!options.noResolve) {
+ processReferencedFiles(file, basePath);
+ }
+ // always process imported modules to record module name resolutions
+ processImportedModules(file, basePath);
+ if (isDefaultLib) {
+ file.isDefaultLib = true;
+ files.unshift(file);
+ }
+ else {
+ files.push(file);
}
- return file;
}
- function getSourceFileFromCache(fileName, canonicalName, useAbsolutePath) {
- var file = filesByName.get(canonicalName);
+ return file;
+ function getSourceFileFromCache(fileName, useAbsolutePath) {
+ var file = filesByName.get(fileName);
if (file && host.useCaseSensitiveFileNames()) {
var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
- if (canonicalName !== sourceFileName) {
+ if (ts.normalizeSlashes(fileName) !== ts.normalizeSlashes(sourceFileName)) {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
}
@@ -35869,11 +36713,7 @@ var ts;
if (importedFile && resolution.isExternalLibraryImport) {
if (!ts.isExternalModule(importedFile)) {
var start_2 = ts.getTokenPosOfNode(file.imports[i], file);
- fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.File_0_is_not_a_module, importedFile.fileName));
- }
- else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) {
- var start_3 = ts.getTokenPosOfNode(file.imports[i], file);
- fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
}
else if (importedFile.referencedFiles.length) {
var firstRef = importedFile.referencedFiles[0];
@@ -36005,9 +36845,9 @@ var ts;
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
}
- // Cannot specify module gen target when in es6 or above
- if (options.module && languageVersion >= 2 /* ES6 */) {
- programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
+ // Cannot specify module gen target of es6 when below es6
+ if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) {
+ programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower));
}
// there has to be common source directory if user specified --outdir || --sourceRoot
// if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted
@@ -36048,10 +36888,6 @@ var ts;
!options.experimentalDecorators) {
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
}
- if (options.experimentalAsyncFunctions &&
- options.target !== 2 /* ES6 */) {
- programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
- }
}
}
ts.createProgram = createProgram;
@@ -36133,11 +36969,13 @@ var ts;
"commonjs": 1 /* CommonJS */,
"amd": 2 /* AMD */,
"system": 4 /* System */,
- "umd": 3 /* UMD */
+ "umd": 3 /* UMD */,
+ "es6": 5 /* ES6 */,
+ "es2015": 5 /* ES2015 */
},
- description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd,
+ description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6,
paramType: ts.Diagnostics.KIND,
- error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd
+ error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6
},
{
name: "newLine",
@@ -36262,7 +37100,12 @@ var ts;
{
name: "target",
shortName: "t",
- type: { "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, "es6": 2 /* ES6 */ },
+ type: {
+ "es3": 0 /* ES3 */,
+ "es5": 1 /* ES5 */,
+ "es6": 2 /* ES6 */,
+ "es2015": 2 /* ES2015 */
+ },
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental,
paramType: ts.Diagnostics.VERSION,
error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6
@@ -36279,11 +37122,6 @@ var ts;
type: "boolean",
description: ts.Diagnostics.Watch_input_files
},
- {
- name: "experimentalAsyncFunctions",
- type: "boolean",
- description: ts.Diagnostics.Enables_experimental_support_for_ES7_async_functions
- },
{
name: "experimentalDecorators",
type: "boolean",
@@ -36424,15 +37262,15 @@ var ts;
* Read tsconfig.json file
* @param fileName The path to the config file
*/
- function readConfigFile(fileName) {
+ function readConfigFile(fileName, readFile) {
var text = "";
try {
- text = ts.sys.readFile(fileName);
+ text = readFile(fileName);
}
catch (e) {
return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
}
- return parseConfigFileText(fileName, text);
+ return parseConfigFileTextToJson(fileName, text);
}
ts.readConfigFile = readConfigFile;
/**
@@ -36440,7 +37278,7 @@ var ts;
* @param fileName The path to the config file
* @param jsonText The text of the config file
*/
- function parseConfigFileText(fileName, jsonText) {
+ function parseConfigFileTextToJson(fileName, jsonText) {
try {
return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} };
}
@@ -36448,14 +37286,14 @@ var ts;
return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) };
}
}
- ts.parseConfigFileText = parseConfigFileText;
+ ts.parseConfigFileTextToJson = parseConfigFileTextToJson;
/**
* Parse the contents of a config file (tsconfig.json).
* @param json The contents of the config file to parse
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
- function parseConfigFile(json, host, basePath) {
+ function parseJsonConfigFileContent(json, host, basePath) {
var errors = [];
return {
options: getCompilerOptions(),
@@ -36489,6 +37327,9 @@ var ts;
}
if (opt.isFilePath) {
value = ts.normalizePath(ts.combinePaths(basePath, value));
+ if (value === "") {
+ value = ".";
+ }
}
options[opt.name] = value;
}
@@ -36517,27 +37358,27 @@ var ts;
var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined;
var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
for (var i = 0; i < sysFiles.length; i++) {
- var name_27 = sysFiles[i];
- if (ts.fileExtensionIs(name_27, ".d.ts")) {
- var baseName = name_27.substr(0, name_27.length - ".d.ts".length);
+ var name_28 = sysFiles[i];
+ if (ts.fileExtensionIs(name_28, ".d.ts")) {
+ var baseName = name_28.substr(0, name_28.length - ".d.ts".length);
if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) {
- fileNames.push(name_27);
+ fileNames.push(name_28);
}
}
- else if (ts.fileExtensionIs(name_27, ".ts")) {
- if (!ts.contains(sysFiles, name_27 + "x")) {
- fileNames.push(name_27);
+ else if (ts.fileExtensionIs(name_28, ".ts")) {
+ if (!ts.contains(sysFiles, name_28 + "x")) {
+ fileNames.push(name_28);
}
}
else {
- fileNames.push(name_27);
+ fileNames.push(name_28);
}
}
}
return fileNames;
}
}
- ts.parseConfigFile = parseConfigFile;
+ ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
})(ts || (ts = {}));
/* @internal */
var ts;
@@ -36611,7 +37452,7 @@ var ts;
}
}
function autoCollapse(node) {
- return ts.isFunctionBlock(node) && node.parent.kind !== 172 /* ArrowFunction */;
+ return ts.isFunctionBlock(node) && node.parent.kind !== 174 /* ArrowFunction */;
}
var depth = 0;
var maxDepth = 20;
@@ -36623,7 +37464,7 @@ var ts;
addOutliningForLeadingCommentsForNode(n);
}
switch (n.kind) {
- case 190 /* Block */:
+ case 192 /* Block */:
if (!ts.isFunctionBlock(n)) {
var parent_7 = n.parent;
var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile);
@@ -36631,18 +37472,18 @@ var ts;
// Check if the block is standalone, or 'attached' to some parent statement.
// If the latter, we want to collaps the block, but consider its hint span
// to be the entire span of the parent.
- if (parent_7.kind === 195 /* DoStatement */ ||
- parent_7.kind === 198 /* ForInStatement */ ||
- parent_7.kind === 199 /* ForOfStatement */ ||
- parent_7.kind === 197 /* ForStatement */ ||
- parent_7.kind === 194 /* IfStatement */ ||
- parent_7.kind === 196 /* WhileStatement */ ||
- parent_7.kind === 203 /* WithStatement */ ||
- parent_7.kind === 242 /* CatchClause */) {
+ if (parent_7.kind === 197 /* DoStatement */ ||
+ parent_7.kind === 200 /* ForInStatement */ ||
+ parent_7.kind === 201 /* ForOfStatement */ ||
+ parent_7.kind === 199 /* ForStatement */ ||
+ parent_7.kind === 196 /* IfStatement */ ||
+ parent_7.kind === 198 /* WhileStatement */ ||
+ parent_7.kind === 205 /* WithStatement */ ||
+ parent_7.kind === 244 /* CatchClause */) {
addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n));
break;
}
- if (parent_7.kind === 207 /* TryStatement */) {
+ if (parent_7.kind === 209 /* TryStatement */) {
// Could be the try-block, or the finally-block.
var tryStatement = parent_7;
if (tryStatement.tryBlock === n) {
@@ -36650,7 +37491,7 @@ var ts;
break;
}
else if (tryStatement.finallyBlock === n) {
- var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile);
+ var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile);
if (finallyKeyword) {
addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n));
break;
@@ -36669,23 +37510,23 @@ var ts;
break;
}
// Fallthrough.
- case 217 /* ModuleBlock */: {
+ case 219 /* ModuleBlock */: {
var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile);
var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile);
addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n));
break;
}
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 215 /* EnumDeclaration */:
- case 163 /* ObjectLiteralExpression */:
- case 218 /* CaseBlock */: {
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 165 /* ObjectLiteralExpression */:
+ case 220 /* CaseBlock */: {
var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile);
var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile);
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
break;
}
- case 162 /* ArrayLiteralExpression */:
+ case 164 /* ArrayLiteralExpression */:
var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile);
var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile);
addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n));
@@ -36713,12 +37554,12 @@ var ts;
ts.forEach(program.getSourceFiles(), function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
var nameToDeclarations = sourceFile.getNamedDeclarations();
- for (var name_28 in nameToDeclarations) {
- var declarations = ts.getProperty(nameToDeclarations, name_28);
+ for (var name_29 in nameToDeclarations) {
+ var declarations = ts.getProperty(nameToDeclarations, name_29);
if (declarations) {
// First do a quick check to see if the name of the declaration matches the
// last portion of the (possibly) dotted name they're searching for.
- var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28);
+ var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_29);
if (!matches) {
continue;
}
@@ -36731,14 +37572,14 @@ var ts;
if (!containers) {
return undefined;
}
- matches = patternMatcher.getMatches(containers, name_28);
+ matches = patternMatcher.getMatches(containers, name_29);
if (!matches) {
continue;
}
}
var fileName = sourceFile.fileName;
var matchKind = bestMatchKind(matches);
- rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration });
+ rawItems.push({ name: name_29, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration });
}
}
}
@@ -36762,7 +37603,7 @@ var ts;
}
function getTextOfIdentifierOrLiteral(node) {
if (node) {
- if (node.kind === 67 /* Identifier */ ||
+ if (node.kind === 69 /* Identifier */ ||
node.kind === 9 /* StringLiteral */ ||
node.kind === 8 /* NumericLiteral */) {
return node.text;
@@ -36776,7 +37617,7 @@ var ts;
if (text !== undefined) {
containers.unshift(text);
}
- else if (declaration.name.kind === 134 /* ComputedPropertyName */) {
+ else if (declaration.name.kind === 136 /* ComputedPropertyName */) {
return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true);
}
else {
@@ -36797,7 +37638,7 @@ var ts;
}
return true;
}
- if (expression.kind === 164 /* PropertyAccessExpression */) {
+ if (expression.kind === 166 /* PropertyAccessExpression */) {
var propertyAccess = expression;
if (includeLastPortion) {
containers.unshift(propertyAccess.name.text);
@@ -36810,7 +37651,7 @@ var ts;
var containers = [];
// First, if we started with a computed property name, then add all but the last
// portion into the container array.
- if (declaration.name.kind === 134 /* ComputedPropertyName */) {
+ if (declaration.name.kind === 136 /* ComputedPropertyName */) {
if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) {
return undefined;
}
@@ -36886,17 +37727,17 @@ var ts;
var current = node.parent;
while (current) {
switch (current.kind) {
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
// If we have a module declared as A.B.C, it is more "intuitive"
// to say it only has a single layer of depth
do {
current = current.parent;
- } while (current.kind === 216 /* ModuleDeclaration */);
+ } while (current.kind === 218 /* ModuleDeclaration */);
// fall through
- case 212 /* ClassDeclaration */:
- case 215 /* EnumDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 211 /* FunctionDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 213 /* FunctionDeclaration */:
indent++;
}
current = current.parent;
@@ -36907,21 +37748,21 @@ var ts;
var childNodes = [];
function visit(node) {
switch (node.kind) {
- case 191 /* VariableStatement */:
+ case 193 /* VariableStatement */:
ts.forEach(node.declarationList.declarations, visit);
break;
- case 159 /* ObjectBindingPattern */:
- case 160 /* ArrayBindingPattern */:
+ case 161 /* ObjectBindingPattern */:
+ case 162 /* ArrayBindingPattern */:
ts.forEach(node.elements, visit);
break;
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
// Handle named exports case e.g.:
// export {a, b as B} from "mod";
if (node.exportClause) {
ts.forEach(node.exportClause.elements, visit);
}
break;
- case 220 /* ImportDeclaration */:
+ case 222 /* ImportDeclaration */:
var importClause = node.importClause;
if (importClause) {
// Handle default import case e.g.:
@@ -36933,7 +37774,7 @@ var ts;
// import * as NS from "mod";
// import {a, b as B} from "mod";
if (importClause.namedBindings) {
- if (importClause.namedBindings.kind === 222 /* NamespaceImport */) {
+ if (importClause.namedBindings.kind === 224 /* NamespaceImport */) {
childNodes.push(importClause.namedBindings);
}
else {
@@ -36942,21 +37783,21 @@ var ts;
}
}
break;
- case 161 /* BindingElement */:
- case 209 /* VariableDeclaration */:
+ case 163 /* BindingElement */:
+ case 211 /* VariableDeclaration */:
if (ts.isBindingPattern(node.name)) {
visit(node.name);
break;
}
// Fall through
- case 212 /* ClassDeclaration */:
- case 215 /* EnumDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 216 /* ModuleDeclaration */:
- case 211 /* FunctionDeclaration */:
- case 219 /* ImportEqualsDeclaration */:
- case 224 /* ImportSpecifier */:
- case 228 /* ExportSpecifier */:
+ case 214 /* ClassDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 218 /* ModuleDeclaration */:
+ case 213 /* FunctionDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 226 /* ImportSpecifier */:
+ case 230 /* ExportSpecifier */:
childNodes.push(node);
break;
}
@@ -37004,17 +37845,17 @@ var ts;
for (var _i = 0; _i < nodes.length; _i++) {
var node = nodes[_i];
switch (node.kind) {
- case 212 /* ClassDeclaration */:
- case 215 /* EnumDeclaration */:
- case 213 /* InterfaceDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 215 /* InterfaceDeclaration */:
topLevelNodes.push(node);
break;
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
var moduleDeclaration = node;
topLevelNodes.push(node);
addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes);
break;
- case 211 /* FunctionDeclaration */:
+ case 213 /* FunctionDeclaration */:
var functionDeclaration = node;
if (isTopLevelFunctionDeclaration(functionDeclaration)) {
topLevelNodes.push(node);
@@ -37025,12 +37866,12 @@ var ts;
}
}
function isTopLevelFunctionDeclaration(functionDeclaration) {
- if (functionDeclaration.kind === 211 /* FunctionDeclaration */) {
+ if (functionDeclaration.kind === 213 /* FunctionDeclaration */) {
// A function declaration is 'top level' if it contains any function declarations
// within it.
- if (functionDeclaration.body && functionDeclaration.body.kind === 190 /* Block */) {
+ if (functionDeclaration.body && functionDeclaration.body.kind === 192 /* Block */) {
// Proper function declarations can only have identifier names
- if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) {
+ if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 213 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) {
return true;
}
// Or if it is not parented by another function. i.e all functions
@@ -37090,7 +37931,7 @@ var ts;
}
function createChildItem(node) {
switch (node.kind) {
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
if (ts.isBindingPattern(node.name)) {
break;
}
@@ -37098,36 +37939,36 @@ var ts;
return undefined;
}
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement);
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement);
- case 143 /* GetAccessor */:
+ case 145 /* GetAccessor */:
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement);
- case 144 /* SetAccessor */:
+ case 146 /* SetAccessor */:
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement);
- case 147 /* IndexSignature */:
+ case 149 /* IndexSignature */:
return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement);
- case 245 /* EnumMember */:
+ case 247 /* EnumMember */:
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement);
- case 145 /* CallSignature */:
+ case 147 /* CallSignature */:
return createItem(node, "()", ts.ScriptElementKind.callSignatureElement);
- case 146 /* ConstructSignature */:
+ case 148 /* ConstructSignature */:
return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement);
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement);
- case 211 /* FunctionDeclaration */:
+ case 213 /* FunctionDeclaration */:
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement);
- case 209 /* VariableDeclaration */:
- case 161 /* BindingElement */:
+ case 211 /* VariableDeclaration */:
+ case 163 /* BindingElement */:
var variableDeclarationNode;
- var name_29;
- if (node.kind === 161 /* BindingElement */) {
- name_29 = node.name;
+ var name_30;
+ if (node.kind === 163 /* BindingElement */) {
+ name_30 = node.name;
variableDeclarationNode = node;
// binding elements are added only for variable declarations
// bubble up to the containing variable declaration
- while (variableDeclarationNode && variableDeclarationNode.kind !== 209 /* VariableDeclaration */) {
+ while (variableDeclarationNode && variableDeclarationNode.kind !== 211 /* VariableDeclaration */) {
variableDeclarationNode = variableDeclarationNode.parent;
}
ts.Debug.assert(variableDeclarationNode !== undefined);
@@ -37135,24 +37976,24 @@ var ts;
else {
ts.Debug.assert(!ts.isBindingPattern(node.name));
variableDeclarationNode = node;
- name_29 = node.name;
+ name_30 = node.name;
}
if (ts.isConst(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement);
+ return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.constElement);
}
else if (ts.isLet(variableDeclarationNode)) {
- return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement);
+ return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.letElement);
}
else {
- return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement);
+ return createItem(node, getTextOfNode(name_30), ts.ScriptElementKind.variableElement);
}
- case 142 /* Constructor */:
+ case 144 /* Constructor */:
return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement);
- case 228 /* ExportSpecifier */:
- case 224 /* ImportSpecifier */:
- case 219 /* ImportEqualsDeclaration */:
- case 221 /* ImportClause */:
- case 222 /* NamespaceImport */:
+ case 230 /* ExportSpecifier */:
+ case 226 /* ImportSpecifier */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 223 /* ImportClause */:
+ case 224 /* NamespaceImport */:
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias);
}
return undefined;
@@ -37182,17 +38023,17 @@ var ts;
}
function createTopLevelItem(node) {
switch (node.kind) {
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
return createSourceFileItem(node);
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
return createClassItem(node);
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
return createEnumItem(node);
- case 213 /* InterfaceDeclaration */:
+ case 215 /* InterfaceDeclaration */:
return createIterfaceItem(node);
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
return createModuleItem(node);
- case 211 /* FunctionDeclaration */:
+ case 213 /* FunctionDeclaration */:
return createFunctionItem(node);
}
return undefined;
@@ -37204,7 +38045,7 @@ var ts;
// Otherwise, we need to aggregate each identifier to build up the qualified name.
var result = [];
result.push(moduleDeclaration.name.text);
- while (moduleDeclaration.body && moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) {
+ while (moduleDeclaration.body && moduleDeclaration.body.kind === 218 /* ModuleDeclaration */) {
moduleDeclaration = moduleDeclaration.body;
result.push(moduleDeclaration.name.text);
}
@@ -37216,7 +38057,7 @@ var ts;
return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node));
}
function createFunctionItem(node) {
- if (node.body && node.body.kind === 190 /* Block */) {
+ if (node.body && node.body.kind === 192 /* Block */) {
var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem);
return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node));
}
@@ -37237,7 +38078,7 @@ var ts;
var childItems;
if (node.members) {
var constructor = ts.forEach(node.members, function (member) {
- return member.kind === 142 /* Constructor */ && member;
+ return member.kind === 144 /* Constructor */ && member;
});
// Add the constructor parameters in as children of the class (for property parameters).
// Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that
@@ -37261,7 +38102,7 @@ var ts;
}
}
function removeComputedProperties(node) {
- return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134 /* ComputedPropertyName */; });
+ return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 136 /* ComputedPropertyName */; });
}
/**
* Like removeComputedProperties, but retains the properties with well known symbol names
@@ -37270,13 +38111,13 @@ var ts;
return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); });
}
function getInnermostModule(node) {
- while (node.body.kind === 216 /* ModuleDeclaration */) {
+ while (node.body.kind === 218 /* ModuleDeclaration */) {
node = node.body;
}
return node;
}
function getNodeSpan(node) {
- return node.kind === 246 /* SourceFile */
+ return node.kind === 248 /* SourceFile */
? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd())
: ts.createTextSpanFromBounds(node.getStart(), node.getEnd());
}
@@ -38071,15 +38912,15 @@ var ts;
}
return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo);
function createJavaScriptSignatureHelpItems(argumentInfo) {
- if (argumentInfo.invocation.kind !== 166 /* CallExpression */) {
+ if (argumentInfo.invocation.kind !== 168 /* CallExpression */) {
return undefined;
}
// See if we can find some symbol with the call expression name that has call signatures.
var callExpression = argumentInfo.invocation;
var expression = callExpression.expression;
- var name = expression.kind === 67 /* Identifier */
+ var name = expression.kind === 69 /* Identifier */
? expression
- : expression.kind === 164 /* PropertyAccessExpression */
+ : expression.kind === 166 /* PropertyAccessExpression */
? expression.name
: undefined;
if (!name || !name.text) {
@@ -38112,7 +38953,7 @@ var ts;
* in the argument of an invocation; returns undefined otherwise.
*/
function getImmediatelyContainingArgumentInfo(node) {
- if (node.parent.kind === 166 /* CallExpression */ || node.parent.kind === 167 /* NewExpression */) {
+ if (node.parent.kind === 168 /* CallExpression */ || node.parent.kind === 169 /* NewExpression */) {
var callExpression = node.parent;
// There are 3 cases to handle:
// 1. The token introduces a list, and should begin a sig help session
@@ -38165,25 +39006,25 @@ var ts;
};
}
}
- else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 168 /* TaggedTemplateExpression */) {
+ else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 170 /* TaggedTemplateExpression */) {
// Check if we're actually inside the template;
// otherwise we'll fall out and return undefined.
if (ts.isInsideTemplateLiteral(node, position)) {
return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0);
}
}
- else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 168 /* TaggedTemplateExpression */) {
+ else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 170 /* TaggedTemplateExpression */) {
var templateExpression = node.parent;
var tagExpression = templateExpression.parent;
- ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */);
+ ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */);
var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1;
return getArgumentListInfoForTemplate(tagExpression, argumentIndex);
}
- else if (node.parent.kind === 188 /* TemplateSpan */ && node.parent.parent.parent.kind === 168 /* TaggedTemplateExpression */) {
+ else if (node.parent.kind === 190 /* TemplateSpan */ && node.parent.parent.parent.kind === 170 /* TaggedTemplateExpression */) {
var templateSpan = node.parent;
var templateExpression = templateSpan.parent;
var tagExpression = templateExpression.parent;
- ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */);
+ ts.Debug.assert(templateExpression.kind === 183 /* TemplateExpression */);
// If we're just after a template tail, don't show signature help.
if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) {
return undefined;
@@ -38301,7 +39142,7 @@ var ts;
//
// This is because a Missing node has no width. However, what we actually want is to include trivia
// leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail.
- if (template.kind === 181 /* TemplateExpression */) {
+ if (template.kind === 183 /* TemplateExpression */) {
var lastSpan = ts.lastOrUndefined(template.templateSpans);
if (lastSpan.literal.getFullWidth() === 0) {
applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false);
@@ -38310,7 +39151,7 @@ var ts;
return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
}
function getContainingArgumentInfo(node) {
- for (var n = node; n.kind !== 246 /* SourceFile */; n = n.parent) {
+ for (var n = node; n.kind !== 248 /* SourceFile */; n = n.parent) {
if (ts.isFunctionBlock(n)) {
return undefined;
}
@@ -38510,40 +39351,40 @@ var ts;
return false;
}
switch (n.kind) {
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 215 /* EnumDeclaration */:
- case 163 /* ObjectLiteralExpression */:
- case 159 /* ObjectBindingPattern */:
- case 153 /* TypeLiteral */:
- case 190 /* Block */:
- case 217 /* ModuleBlock */:
- case 218 /* CaseBlock */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 165 /* ObjectLiteralExpression */:
+ case 161 /* ObjectBindingPattern */:
+ case 155 /* TypeLiteral */:
+ case 192 /* Block */:
+ case 219 /* ModuleBlock */:
+ case 220 /* CaseBlock */:
return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile);
- case 242 /* CatchClause */:
+ case 244 /* CatchClause */:
return isCompletedNode(n.block, sourceFile);
- case 167 /* NewExpression */:
+ case 169 /* NewExpression */:
if (!n.arguments) {
return true;
}
// fall through
- case 166 /* CallExpression */:
- case 170 /* ParenthesizedExpression */:
- case 158 /* ParenthesizedType */:
+ case 168 /* CallExpression */:
+ case 172 /* ParenthesizedExpression */:
+ case 160 /* ParenthesizedType */:
return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile);
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
return isCompletedNode(n.type, sourceFile);
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 146 /* ConstructSignature */:
- case 145 /* CallSignature */:
- case 172 /* ArrowFunction */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 148 /* ConstructSignature */:
+ case 147 /* CallSignature */:
+ case 174 /* ArrowFunction */:
if (n.body) {
return isCompletedNode(n.body, sourceFile);
}
@@ -38553,63 +39394,64 @@ var ts;
// Even though type parameters can be unclosed, we can get away with
// having at least a closing paren.
return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile);
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
return n.body && isCompletedNode(n.body, sourceFile);
- case 194 /* IfStatement */:
+ case 196 /* IfStatement */:
if (n.elseStatement) {
return isCompletedNode(n.elseStatement, sourceFile);
}
return isCompletedNode(n.thenStatement, sourceFile);
- case 193 /* ExpressionStatement */:
- return isCompletedNode(n.expression, sourceFile);
- case 162 /* ArrayLiteralExpression */:
- case 160 /* ArrayBindingPattern */:
- case 165 /* ElementAccessExpression */:
- case 134 /* ComputedPropertyName */:
- case 155 /* TupleType */:
+ case 195 /* ExpressionStatement */:
+ return isCompletedNode(n.expression, sourceFile) ||
+ hasChildOfKind(n, 23 /* SemicolonToken */);
+ case 164 /* ArrayLiteralExpression */:
+ case 162 /* ArrayBindingPattern */:
+ case 167 /* ElementAccessExpression */:
+ case 136 /* ComputedPropertyName */:
+ case 157 /* TupleType */:
return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile);
- case 147 /* IndexSignature */:
+ case 149 /* IndexSignature */:
if (n.type) {
return isCompletedNode(n.type, sourceFile);
}
return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile);
- case 239 /* CaseClause */:
- case 240 /* DefaultClause */:
+ case 241 /* CaseClause */:
+ case 242 /* DefaultClause */:
// there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed
return false;
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 196 /* WhileStatement */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 198 /* WhileStatement */:
return isCompletedNode(n.statement, sourceFile);
- case 195 /* DoStatement */:
+ case 197 /* DoStatement */:
// rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')';
- var hasWhileKeyword = findChildOfKind(n, 102 /* WhileKeyword */, sourceFile);
+ var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile);
if (hasWhileKeyword) {
return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile);
}
return isCompletedNode(n.statement, sourceFile);
- case 152 /* TypeQuery */:
+ case 154 /* TypeQuery */:
return isCompletedNode(n.exprName, sourceFile);
- case 174 /* TypeOfExpression */:
- case 173 /* DeleteExpression */:
- case 175 /* VoidExpression */:
- case 182 /* YieldExpression */:
- case 183 /* SpreadElementExpression */:
+ case 176 /* TypeOfExpression */:
+ case 175 /* DeleteExpression */:
+ case 177 /* VoidExpression */:
+ case 184 /* YieldExpression */:
+ case 185 /* SpreadElementExpression */:
var unaryWordExpression = n;
return isCompletedNode(unaryWordExpression.expression, sourceFile);
- case 168 /* TaggedTemplateExpression */:
+ case 170 /* TaggedTemplateExpression */:
return isCompletedNode(n.template, sourceFile);
- case 181 /* TemplateExpression */:
+ case 183 /* TemplateExpression */:
var lastSpan = ts.lastOrUndefined(n.templateSpans);
return isCompletedNode(lastSpan, sourceFile);
- case 188 /* TemplateSpan */:
+ case 190 /* TemplateSpan */:
return ts.nodeIsPresent(n.literal);
- case 177 /* PrefixUnaryExpression */:
+ case 179 /* PrefixUnaryExpression */:
return isCompletedNode(n.operand, sourceFile);
- case 179 /* BinaryExpression */:
+ case 181 /* BinaryExpression */:
return isCompletedNode(n.right, sourceFile);
- case 180 /* ConditionalExpression */:
+ case 182 /* ConditionalExpression */:
return isCompletedNode(n.whenFalse, sourceFile);
default:
return true;
@@ -38665,7 +39507,7 @@ var ts;
// for the position of the relevant node (or comma).
var syntaxList = ts.forEach(node.parent.getChildren(), function (c) {
// find syntax list that covers the span of the node
- if (c.kind === 269 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) {
+ if (c.kind === 271 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) {
return c;
}
});
@@ -38771,7 +39613,7 @@ var ts;
function findPrecedingToken(position, sourceFile, startNode) {
return find(startNode || sourceFile);
function findRightmostToken(n) {
- if (isToken(n) || n.kind === 234 /* JsxText */) {
+ if (isToken(n) || n.kind === 236 /* JsxText */) {
return n;
}
var children = n.getChildren();
@@ -38779,7 +39621,7 @@ var ts;
return candidate && findRightmostToken(candidate);
}
function find(n) {
- if (isToken(n) || n.kind === 234 /* JsxText */) {
+ if (isToken(n) || n.kind === 236 /* JsxText */) {
return n;
}
var children = n.getChildren();
@@ -38793,10 +39635,10 @@ var ts;
// if no - position is in the node itself so we should recurse in it.
// NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia).
// if this is the case - then we should assume that token in question is located in previous child.
- if (position < child.end && (nodeHasTokens(child) || child.kind === 234 /* JsxText */)) {
+ if (position < child.end && (nodeHasTokens(child) || child.kind === 236 /* JsxText */)) {
var start = child.getStart(sourceFile);
var lookInPreviousChild = (start >= position) ||
- (child.kind === 234 /* JsxText */ && start === child.end); // whitespace only JsxText
+ (child.kind === 236 /* JsxText */ && start === child.end); // whitespace only JsxText
if (lookInPreviousChild) {
// actual start of the node is past the position - previous token should be at the end of previous child
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
@@ -38808,7 +39650,7 @@ var ts;
}
}
}
- ts.Debug.assert(startNode !== undefined || n.kind === 246 /* SourceFile */);
+ ts.Debug.assert(startNode !== undefined || n.kind === 248 /* SourceFile */);
// Here we know that none of child token nodes embrace the position,
// the only known case is when position is at the end of the file.
// Try to find the rightmost token in the file without filtering.
@@ -38883,9 +39725,9 @@ var ts;
var node = ts.getTokenAtPosition(sourceFile, position);
if (isToken(node)) {
switch (node.kind) {
- case 100 /* VarKeyword */:
- case 106 /* LetKeyword */:
- case 72 /* ConstKeyword */:
+ case 102 /* VarKeyword */:
+ case 108 /* LetKeyword */:
+ case 74 /* ConstKeyword */:
// if the current token is var, let or const, skip the VariableDeclarationList
node = node.parent === undefined ? undefined : node.parent.parent;
break;
@@ -38934,21 +39776,21 @@ var ts;
}
ts.getNodeModifiers = getNodeModifiers;
function getTypeArgumentOrTypeParameterList(node) {
- if (node.kind === 149 /* TypeReference */ || node.kind === 166 /* CallExpression */) {
+ if (node.kind === 151 /* TypeReference */ || node.kind === 168 /* CallExpression */) {
return node.typeArguments;
}
- if (ts.isFunctionLike(node) || node.kind === 212 /* ClassDeclaration */ || node.kind === 213 /* InterfaceDeclaration */) {
+ if (ts.isFunctionLike(node) || node.kind === 214 /* ClassDeclaration */ || node.kind === 215 /* InterfaceDeclaration */) {
return node.typeParameters;
}
return undefined;
}
ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList;
function isToken(n) {
- return n.kind >= 0 /* FirstToken */ && n.kind <= 132 /* LastToken */;
+ return n.kind >= 0 /* FirstToken */ && n.kind <= 134 /* LastToken */;
}
ts.isToken = isToken;
function isWord(kind) {
- return kind === 67 /* Identifier */ || ts.isKeyword(kind);
+ return kind === 69 /* Identifier */ || ts.isKeyword(kind);
}
ts.isWord = isWord;
function isPropertyName(kind) {
@@ -38958,8 +39800,17 @@ var ts;
return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */;
}
ts.isComment = isComment;
+ function isStringOrRegularExpressionOrTemplateLiteral(kind) {
+ if (kind === 9 /* StringLiteral */
+ || kind === 10 /* RegularExpressionLiteral */
+ || ts.isTemplateLiteralKind(kind)) {
+ return true;
+ }
+ return false;
+ }
+ ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral;
function isPunctuation(kind) {
- return 15 /* FirstPunctuation */ <= kind && kind <= 66 /* LastPunctuation */;
+ return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */;
}
ts.isPunctuation = isPunctuation;
function isInsideTemplateLiteral(node, position) {
@@ -38969,9 +39820,9 @@ var ts;
ts.isInsideTemplateLiteral = isInsideTemplateLiteral;
function isAccessibilityModifier(kind) {
switch (kind) {
- case 110 /* PublicKeyword */:
- case 108 /* PrivateKeyword */:
- case 109 /* ProtectedKeyword */:
+ case 112 /* PublicKeyword */:
+ case 110 /* PrivateKeyword */:
+ case 111 /* ProtectedKeyword */:
return true;
}
return false;
@@ -38999,7 +39850,7 @@ var ts;
var ts;
(function (ts) {
function isFirstDeclarationOfSymbolParameter(symbol) {
- return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136 /* Parameter */;
+ return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 138 /* Parameter */;
}
ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter;
var displayPartWriter = getDisplayPartWriter();
@@ -39021,7 +39872,8 @@ var ts;
increaseIndent: function () { indent++; },
decreaseIndent: function () { indent--; },
clear: resetWriter,
- trackSymbol: function () { }
+ trackSymbol: function () { },
+ reportInaccessibleThisError: function () { }
};
function writeIndent() {
if (lineStart) {
@@ -39186,7 +40038,7 @@ var ts;
ts.getDeclaredName = getDeclaredName;
function isImportOrExportSpecifierName(location) {
return location.parent &&
- (location.parent.kind === 224 /* ImportSpecifier */ || location.parent.kind === 228 /* ExportSpecifier */) &&
+ (location.parent.kind === 226 /* ImportSpecifier */ || location.parent.kind === 230 /* ExportSpecifier */) &&
location.parent.propertyName === location;
}
ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName;
@@ -39214,7 +40066,12 @@ var ts;
(function (ts) {
var formatting;
(function (formatting) {
- var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false);
+ var standardScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */);
+ var jsxScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */);
+ /**
+ * Scanner that is currently used for formatting
+ */
+ var scanner;
var ScanAction;
(function (ScanAction) {
ScanAction[ScanAction["Scan"] = 0] = "Scan";
@@ -39224,6 +40081,8 @@ var ts;
ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier";
})(ScanAction || (ScanAction = {}));
function getFormattingScanner(sourceFile, startPos, endPos) {
+ ts.Debug.assert(scanner === undefined);
+ scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner;
scanner.setText(sourceFile.text);
scanner.setTextPos(startPos);
var wasNewLine = true;
@@ -39238,11 +40097,14 @@ var ts;
isOnToken: isOnToken,
lastTrailingTriviaWasNewLine: function () { return wasNewLine; },
close: function () {
+ ts.Debug.assert(scanner !== undefined);
lastTokenInfo = undefined;
scanner.setText(undefined);
+ scanner = undefined;
}
};
function advance() {
+ ts.Debug.assert(scanner !== undefined);
lastTokenInfo = undefined;
var isStarted = scanner.getStartPos() !== startPos;
if (isStarted) {
@@ -39286,10 +40148,10 @@ var ts;
if (node) {
switch (node.kind) {
case 29 /* GreaterThanEqualsToken */:
- case 62 /* GreaterThanGreaterThanEqualsToken */:
- case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
- case 44 /* GreaterThanGreaterThanGreaterThanToken */:
- case 43 /* GreaterThanGreaterThanToken */:
+ case 64 /* GreaterThanGreaterThanEqualsToken */:
+ case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 45 /* GreaterThanGreaterThanGreaterThanToken */:
+ case 44 /* GreaterThanGreaterThanToken */:
return true;
}
}
@@ -39298,11 +40160,11 @@ var ts;
function shouldRescanJsxIdentifier(node) {
if (node.parent) {
switch (node.parent.kind) {
- case 236 /* JsxAttribute */:
- case 233 /* JsxOpeningElement */:
- case 235 /* JsxClosingElement */:
- case 232 /* JsxSelfClosingElement */:
- return node.kind === 67 /* Identifier */;
+ case 238 /* JsxAttribute */:
+ case 235 /* JsxOpeningElement */:
+ case 237 /* JsxClosingElement */:
+ case 234 /* JsxSelfClosingElement */:
+ return node.kind === 69 /* Identifier */;
}
}
return false;
@@ -39315,9 +40177,10 @@ var ts;
container.kind === 14 /* TemplateTail */;
}
function startsWithSlashToken(t) {
- return t === 38 /* SlashToken */ || t === 59 /* SlashEqualsToken */;
+ return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */;
}
function readTokenInfo(n) {
+ ts.Debug.assert(scanner !== undefined);
if (!isOnToken()) {
// scanner is not on the token (either advance was not called yet or scanner is already past the end position)
return {
@@ -39367,7 +40230,7 @@ var ts;
currentToken = scanner.reScanTemplateToken();
lastScanAction = 3 /* RescanTemplateToken */;
}
- else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 67 /* Identifier */) {
+ else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) {
currentToken = scanner.scanJsxIdentifier();
lastScanAction = 4 /* RescanJsxIdentifier */;
}
@@ -39411,6 +40274,7 @@ var ts;
return fixTokenKind(lastTokenInfo, n);
}
function isOnToken() {
+ ts.Debug.assert(scanner !== undefined);
var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken();
var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos();
return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current);
@@ -39689,17 +40553,17 @@ var ts;
this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */));
// Space after keyword but not before ; or : or ?
this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */));
- this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */));
- this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */));
- this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */));
- this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */));
+ this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */));
+ this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */));
+ this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */));
+ this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// Space after }.
this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */));
// Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied
- this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 78 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 102 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// No space for dot
this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
@@ -39711,10 +40575,10 @@ var ts;
this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments;
this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */);
// Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc)
- this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */, 71 /* ClassKeyword */]);
+ this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */]);
this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */);
// Place a space before open brace in a control flow construct
- this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]);
+ this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]);
this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */);
// Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}.
this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */));
@@ -39728,55 +40592,55 @@ var ts;
// Prefix operators generally shouldn't have a space between
// them and their target unary expression.
this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */));
- this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// More unary operator special-casing.
// DevDiv 181814: Be careful when removing leading whitespace
// around unary operators. Examples:
// 1 - -2 --X--> 1--2
// a + ++b --X--> a+++b
- this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
+ this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
- this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
- this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
+ this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
+ this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
- this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
+ this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */));
+ this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */));
this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */));
- this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
+ this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */));
- this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */));
- this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */));
+ this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Add a space between statements. All keywords except (do,else,case) has open/close parens after them.
// So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any]
- this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 77 /* DoKeyword */, 78 /* ElseKeyword */, 69 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */));
+ this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */));
// This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter.
- this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98 /* TryKeyword */, 83 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// get x() {}
// set x(val) {}
- this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121 /* GetKeyword */, 127 /* SetKeyword */]), 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
+ this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 129 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
// Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options.
this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
// TypeScript-specific higher priority rules
// Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses
- this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Use of module as a function call. e.g.: import m2 = module("m2");
- this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 127 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Add a space around certain TypeScript keywords
- this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 129 /* SetKeyword */, 113 /* StaticKeyword */, 132 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */));
// Lambda expressions
this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// Optional parameters and let args
- this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */));
+ this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */));
// generics and type assertions
this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */));
this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */));
@@ -39787,31 +40651,20 @@ var ts;
// Remove spaces in empty interface literals. e.g.: x: {}
this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */));
// decorators
- this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 67 /* Identifier */, 80 /* ExportKeyword */, 75 /* DefaultKeyword */, 71 /* ClassKeyword */, 111 /* StaticKeyword */, 110 /* PublicKeyword */, 108 /* PrivateKeyword */, 109 /* ProtectedKeyword */, 121 /* GetKeyword */, 127 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */));
- this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */));
- this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */));
- this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */));
- this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */));
+ this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 129 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */));
+ this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */));
+ this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */));
+ this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */));
+ this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */));
// Async-await
- this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- // Type alias declaration
- this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// template string
- this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- // type operation
- this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceBeforeAmpersand = new formatting.Rule(formatting.RuleDescriptor.create3(45 /* AmpersandToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.SpaceAfterAmpersand = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 45 /* AmpersandToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
+ this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -39838,12 +40691,8 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
- this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
- this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
- this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
- this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
- this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
- this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand,
+ this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword,
+ this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
@@ -39911,14 +40760,14 @@ var ts;
this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Insert space after function keyword for anonymous functions
- this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
- this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */));
+ this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
+ this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */));
}
Rules.prototype.getRuleName = function (rule) {
var o = this;
- for (var name_30 in o) {
- if (o[name_30] === rule) {
- return name_30;
+ for (var name_31 in o) {
+ if (o[name_31] === rule) {
+ return name_31;
}
}
throw new Error("Unknown rule");
@@ -39927,38 +40776,40 @@ var ts;
/// Contexts
///
Rules.IsForContext = function (context) {
- return context.contextNode.kind === 197 /* ForStatement */;
+ return context.contextNode.kind === 199 /* ForStatement */;
};
Rules.IsNotForContext = function (context) {
return !Rules.IsForContext(context);
};
Rules.IsBinaryOpContext = function (context) {
switch (context.contextNode.kind) {
- case 179 /* BinaryExpression */:
- case 180 /* ConditionalExpression */:
- case 187 /* AsExpression */:
- case 148 /* TypePredicate */:
+ case 181 /* BinaryExpression */:
+ case 182 /* ConditionalExpression */:
+ case 189 /* AsExpression */:
+ case 150 /* TypePredicate */:
+ case 158 /* UnionType */:
+ case 159 /* IntersectionType */:
return true;
// equals in binding elements: function foo([[x, y] = [1, 2]])
- case 161 /* BindingElement */:
+ case 163 /* BindingElement */:
// equals in type X = ...
- case 214 /* TypeAliasDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
// equal in import a = module('a');
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
// equal in let a = 0;
- case 209 /* VariableDeclaration */:
+ case 211 /* VariableDeclaration */:
// equal in p = 0;
- case 136 /* Parameter */:
- case 245 /* EnumMember */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- return context.currentTokenSpan.kind === 55 /* EqualsToken */ || context.nextTokenSpan.kind === 55 /* EqualsToken */;
+ case 138 /* Parameter */:
+ case 247 /* EnumMember */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */;
// "in" keyword in for (let x in []) { }
- case 198 /* ForInStatement */:
- return context.currentTokenSpan.kind === 88 /* InKeyword */ || context.nextTokenSpan.kind === 88 /* InKeyword */;
+ case 200 /* ForInStatement */:
+ return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */;
// Technically, "of" is not a binary operator, but format it the same way as "in"
- case 199 /* ForOfStatement */:
- return context.currentTokenSpan.kind === 132 /* OfKeyword */ || context.nextTokenSpan.kind === 132 /* OfKeyword */;
+ case 201 /* ForOfStatement */:
+ return context.currentTokenSpan.kind === 134 /* OfKeyword */ || context.nextTokenSpan.kind === 134 /* OfKeyword */;
}
return false;
};
@@ -39966,7 +40817,7 @@ var ts;
return !Rules.IsBinaryOpContext(context);
};
Rules.IsConditionalOperatorContext = function (context) {
- return context.contextNode.kind === 180 /* ConditionalExpression */;
+ return context.contextNode.kind === 182 /* ConditionalExpression */;
};
Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) {
//// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction.
@@ -40010,93 +40861,93 @@ var ts;
return true;
}
switch (node.kind) {
- case 190 /* Block */:
- case 218 /* CaseBlock */:
- case 163 /* ObjectLiteralExpression */:
- case 217 /* ModuleBlock */:
+ case 192 /* Block */:
+ case 220 /* CaseBlock */:
+ case 165 /* ObjectLiteralExpression */:
+ case 219 /* ModuleBlock */:
return true;
}
return false;
};
Rules.IsFunctionDeclContext = function (context) {
switch (context.contextNode.kind) {
- case 211 /* FunctionDeclaration */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 213 /* FunctionDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
//case SyntaxKind.MemberFunctionDeclaration:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
///case SyntaxKind.MethodSignature:
- case 145 /* CallSignature */:
- case 171 /* FunctionExpression */:
- case 142 /* Constructor */:
- case 172 /* ArrowFunction */:
+ case 147 /* CallSignature */:
+ case 173 /* FunctionExpression */:
+ case 144 /* Constructor */:
+ case 174 /* ArrowFunction */:
//case SyntaxKind.ConstructorDeclaration:
//case SyntaxKind.SimpleArrowFunctionExpression:
//case SyntaxKind.ParenthesizedArrowFunctionExpression:
- case 213 /* InterfaceDeclaration */:
+ case 215 /* InterfaceDeclaration */:
return true;
}
return false;
};
Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) {
- return context.contextNode.kind === 211 /* FunctionDeclaration */ || context.contextNode.kind === 171 /* FunctionExpression */;
+ return context.contextNode.kind === 213 /* FunctionDeclaration */ || context.contextNode.kind === 173 /* FunctionExpression */;
};
Rules.IsTypeScriptDeclWithBlockContext = function (context) {
return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode);
};
Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) {
switch (node.kind) {
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
- case 213 /* InterfaceDeclaration */:
- case 215 /* EnumDeclaration */:
- case 153 /* TypeLiteral */:
- case 216 /* ModuleDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
+ case 215 /* InterfaceDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 155 /* TypeLiteral */:
+ case 218 /* ModuleDeclaration */:
return true;
}
return false;
};
Rules.IsAfterCodeBlockContext = function (context) {
switch (context.currentTokenParent.kind) {
- case 212 /* ClassDeclaration */:
- case 216 /* ModuleDeclaration */:
- case 215 /* EnumDeclaration */:
- case 190 /* Block */:
- case 242 /* CatchClause */:
- case 217 /* ModuleBlock */:
- case 204 /* SwitchStatement */:
+ case 214 /* ClassDeclaration */:
+ case 218 /* ModuleDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 192 /* Block */:
+ case 244 /* CatchClause */:
+ case 219 /* ModuleBlock */:
+ case 206 /* SwitchStatement */:
return true;
}
return false;
};
Rules.IsControlDeclContext = function (context) {
switch (context.contextNode.kind) {
- case 194 /* IfStatement */:
- case 204 /* SwitchStatement */:
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 196 /* WhileStatement */:
- case 207 /* TryStatement */:
- case 195 /* DoStatement */:
- case 203 /* WithStatement */:
+ case 196 /* IfStatement */:
+ case 206 /* SwitchStatement */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 198 /* WhileStatement */:
+ case 209 /* TryStatement */:
+ case 197 /* DoStatement */:
+ case 205 /* WithStatement */:
// TODO
// case SyntaxKind.ElseClause:
- case 242 /* CatchClause */:
+ case 244 /* CatchClause */:
return true;
default:
return false;
}
};
Rules.IsObjectContext = function (context) {
- return context.contextNode.kind === 163 /* ObjectLiteralExpression */;
+ return context.contextNode.kind === 165 /* ObjectLiteralExpression */;
};
Rules.IsFunctionCallContext = function (context) {
- return context.contextNode.kind === 166 /* CallExpression */;
+ return context.contextNode.kind === 168 /* CallExpression */;
};
Rules.IsNewContext = function (context) {
- return context.contextNode.kind === 167 /* NewExpression */;
+ return context.contextNode.kind === 169 /* NewExpression */;
};
Rules.IsFunctionCallOrNewContext = function (context) {
return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context);
@@ -40104,6 +40955,9 @@ var ts;
Rules.IsPreviousTokenNotComma = function (context) {
return context.currentTokenSpan.kind !== 24 /* CommaToken */;
};
+ Rules.IsArrowFunctionContext = function (context) {
+ return context.contextNode.kind === 174 /* ArrowFunction */;
+ };
Rules.IsSameLineTokenContext = function (context) {
return context.TokensAreOnSameLine();
};
@@ -40120,41 +40974,41 @@ var ts;
while (ts.isExpression(node)) {
node = node.parent;
}
- return node.kind === 137 /* Decorator */;
+ return node.kind === 139 /* Decorator */;
};
Rules.IsStartOfVariableDeclarationList = function (context) {
- return context.currentTokenParent.kind === 210 /* VariableDeclarationList */ &&
+ return context.currentTokenParent.kind === 212 /* VariableDeclarationList */ &&
context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos;
};
Rules.IsNotFormatOnEnter = function (context) {
return context.formattingRequestKind !== 2 /* FormatOnEnter */;
};
Rules.IsModuleDeclContext = function (context) {
- return context.contextNode.kind === 216 /* ModuleDeclaration */;
+ return context.contextNode.kind === 218 /* ModuleDeclaration */;
};
Rules.IsObjectTypeContext = function (context) {
- return context.contextNode.kind === 153 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration;
+ return context.contextNode.kind === 155 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration;
};
Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) {
if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) {
return false;
}
switch (parent.kind) {
- case 149 /* TypeReference */:
- case 169 /* TypeAssertionExpression */:
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
- case 213 /* InterfaceDeclaration */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */:
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
- case 186 /* ExpressionWithTypeArguments */:
+ case 151 /* TypeReference */:
+ case 171 /* TypeAssertionExpression */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
+ case 215 /* InterfaceDeclaration */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
+ case 188 /* ExpressionWithTypeArguments */:
return true;
default:
return false;
@@ -40165,13 +41019,13 @@ var ts;
Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent);
};
Rules.IsTypeAssertionContext = function (context) {
- return context.contextNode.kind === 169 /* TypeAssertionExpression */;
+ return context.contextNode.kind === 171 /* TypeAssertionExpression */;
};
Rules.IsVoidOpContext = function (context) {
- return context.currentTokenSpan.kind === 101 /* VoidKeyword */ && context.currentTokenParent.kind === 175 /* VoidExpression */;
+ return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 177 /* VoidExpression */;
};
Rules.IsYieldOrYieldStarWithOperand = function (context) {
- return context.contextNode.kind === 182 /* YieldExpression */ && context.contextNode.expression !== undefined;
+ return context.contextNode.kind === 184 /* YieldExpression */ && context.contextNode.expression !== undefined;
};
return Rules;
})();
@@ -40195,7 +41049,7 @@ var ts;
return result;
};
RulesMap.prototype.Initialize = function (rules) {
- this.mapRowLength = 132 /* LastToken */ + 1;
+ this.mapRowLength = 134 /* LastToken */ + 1;
this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength);
// This array is used only during construction of the rulesbucket in the map
var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length);
@@ -40390,7 +41244,7 @@ var ts;
}
TokenAllAccess.prototype.GetTokens = function () {
var result = [];
- for (var token = 0 /* FirstToken */; token <= 132 /* LastToken */; token++) {
+ for (var token = 0 /* FirstToken */; token <= 134 /* LastToken */; token++) {
result.push(token);
}
return result;
@@ -40432,17 +41286,17 @@ var ts;
};
TokenRange.Any = TokenRange.AllTokens();
TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */]));
- TokenRange.Keywords = TokenRange.FromRange(68 /* FirstKeyword */, 132 /* LastKeyword */);
- TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 66 /* LastBinaryOperator */);
- TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88 /* InKeyword */, 89 /* InstanceOfKeyword */, 132 /* OfKeyword */, 114 /* AsKeyword */, 122 /* IsKeyword */]);
- TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40 /* PlusPlusToken */, 41 /* MinusMinusToken */, 49 /* TildeToken */, 48 /* ExclamationToken */]);
- TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 67 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]);
- TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]);
- TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]);
- TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]);
- TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]);
+ TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 134 /* LastKeyword */);
+ TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */);
+ TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 134 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]);
+ TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]);
+ TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]);
+ TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]);
+ TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]);
+ TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]);
+ TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]);
TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]);
- TokenRange.TypeNames = TokenRange.FromTokens([67 /* Identifier */, 126 /* NumberKeyword */, 128 /* StringKeyword */, 118 /* BooleanKeyword */, 129 /* SymbolKeyword */, 101 /* VoidKeyword */, 115 /* AnyKeyword */]);
+ TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 128 /* NumberKeyword */, 130 /* StringKeyword */, 120 /* BooleanKeyword */, 131 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]);
return TokenRange;
})();
Shared.TokenRange = TokenRange;
@@ -40656,17 +41510,17 @@ var ts;
// i.e. parent is class declaration with the list of members and node is one of members.
function isListElement(parent, node) {
switch (parent.kind) {
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
return ts.rangeContainsRange(parent.members, node);
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
var body = parent.body;
- return body && body.kind === 190 /* Block */ && ts.rangeContainsRange(body.statements, node);
- case 246 /* SourceFile */:
- case 190 /* Block */:
- case 217 /* ModuleBlock */:
+ return body && body.kind === 192 /* Block */ && ts.rangeContainsRange(body.statements, node);
+ case 248 /* SourceFile */:
+ case 192 /* Block */:
+ case 219 /* ModuleBlock */:
return ts.rangeContainsRange(parent.statements, node);
- case 242 /* CatchClause */:
+ case 244 /* CatchClause */:
return ts.rangeContainsRange(parent.block.statements, node);
}
return false;
@@ -40839,9 +41693,9 @@ var ts;
// - source file
// - switch\default clauses
if (isSomeBlock(parent.kind) ||
- parent.kind === 246 /* SourceFile */ ||
- parent.kind === 239 /* CaseClause */ ||
- parent.kind === 240 /* DefaultClause */) {
+ parent.kind === 248 /* SourceFile */ ||
+ parent.kind === 241 /* CaseClause */ ||
+ parent.kind === 242 /* DefaultClause */) {
indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta();
}
else {
@@ -40877,25 +41731,25 @@ var ts;
return node.modifiers[0].kind;
}
switch (node.kind) {
- case 212 /* ClassDeclaration */: return 71 /* ClassKeyword */;
- case 213 /* InterfaceDeclaration */: return 105 /* InterfaceKeyword */;
- case 211 /* FunctionDeclaration */: return 85 /* FunctionKeyword */;
- case 215 /* EnumDeclaration */: return 215 /* EnumDeclaration */;
- case 143 /* GetAccessor */: return 121 /* GetKeyword */;
- case 144 /* SetAccessor */: return 127 /* SetKeyword */;
- case 141 /* MethodDeclaration */:
+ case 214 /* ClassDeclaration */: return 73 /* ClassKeyword */;
+ case 215 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */;
+ case 213 /* FunctionDeclaration */: return 87 /* FunctionKeyword */;
+ case 217 /* EnumDeclaration */: return 217 /* EnumDeclaration */;
+ case 145 /* GetAccessor */: return 123 /* GetKeyword */;
+ case 146 /* SetAccessor */: return 129 /* SetKeyword */;
+ case 143 /* MethodDeclaration */:
if (node.asteriskToken) {
return 37 /* AsteriskToken */;
}
// fall-through
- case 139 /* PropertyDeclaration */:
- case 136 /* Parameter */:
+ case 141 /* PropertyDeclaration */:
+ case 138 /* Parameter */:
return node.name.kind;
}
}
function getDynamicIndentation(node, nodeStartLine, indentation, delta) {
return {
- getIndentationForComment: function (kind) {
+ getIndentationForComment: function (kind, tokenIndentation) {
switch (kind) {
// preceding comment to the token that closes the indentation scope inherits the indentation from the scope
// .. {
@@ -40903,9 +41757,10 @@ var ts;
// }
case 16 /* CloseBraceToken */:
case 20 /* CloseBracketToken */:
+ case 18 /* CloseParenToken */:
return indentation + delta;
}
- return indentation;
+ return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation;
},
getIndentationForToken: function (line, kind) {
if (nodeStartLine !== line && node.decorators) {
@@ -40922,9 +41777,9 @@ var ts;
case 20 /* CloseBracketToken */:
case 17 /* OpenParenToken */:
case 18 /* CloseParenToken */:
- case 78 /* ElseKeyword */:
- case 102 /* WhileKeyword */:
- case 54 /* AtToken */:
+ case 80 /* ElseKeyword */:
+ case 104 /* WhileKeyword */:
+ case 55 /* AtToken */:
return indentation;
default:
// if token line equals to the line of containing node (this is a first token in the node) - use node indentation
@@ -41024,7 +41879,7 @@ var ts;
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation);
return inheritedIndentation;
}
- var effectiveParentStartLine = child.kind === 137 /* Decorator */ ? childStartLine : undecoratedParentStartLine;
+ var effectiveParentStartLine = child.kind === 139 /* Decorator */ ? childStartLine : undecoratedParentStartLine;
var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine);
processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta);
childContextNode = node;
@@ -41107,8 +41962,12 @@ var ts;
processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation);
}
if (indentToken) {
- var indentNextTokenOrTrivia = true;
+ var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
+ dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) :
+ -1 /* Unknown */;
if (currentTokenInfo.leadingTrivia) {
+ var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation);
+ var indentNextTokenOrTrivia = true;
for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) {
var triviaItem = _a[_i];
if (!ts.rangeContainsRange(originalRange, triviaItem)) {
@@ -41116,14 +41975,12 @@ var ts;
}
switch (triviaItem.kind) {
case 3 /* MultiLineCommentTrivia */:
- var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia);
indentNextTokenOrTrivia = false;
break;
case 2 /* SingleLineCommentTrivia */:
if (indentNextTokenOrTrivia) {
- var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
- insertIndentation(triviaItem.pos, commentIndentation_1, /*lineAdded*/ false);
+ insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false);
indentNextTokenOrTrivia = false;
}
break;
@@ -41134,8 +41991,7 @@ var ts;
}
}
// indent token only if is it is in target range and does not overlap with any error ranges
- if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
- var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
+ if (tokenIndentation !== -1 /* Unknown */) {
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
lastIndentedLine = tokenStart.line;
indentationOnLastIndentedLine = tokenIndentation;
@@ -41280,8 +42136,8 @@ var ts;
for (var line = line1; line < line2; ++line) {
var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile);
var lineEndPosition = ts.getEndLinePosition(line, sourceFile);
- // do not trim whitespaces in comments
- if (range && ts.isComment(range.kind) && range.pos <= lineEndPosition && range.end > lineEndPosition) {
+ // do not trim whitespaces in comments or template expression
+ if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) {
continue;
}
var pos = lineEndPosition;
@@ -41347,20 +42203,20 @@ var ts;
}
function isSomeBlock(kind) {
switch (kind) {
- case 190 /* Block */:
- case 217 /* ModuleBlock */:
+ case 192 /* Block */:
+ case 219 /* ModuleBlock */:
return true;
}
return false;
}
function getOpenTokenForList(node, list) {
switch (node.kind) {
- case 142 /* Constructor */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 172 /* ArrowFunction */:
+ case 144 /* Constructor */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 174 /* ArrowFunction */:
if (node.typeParameters === list) {
return 25 /* LessThanToken */;
}
@@ -41368,8 +42224,8 @@ var ts;
return 17 /* OpenParenToken */;
}
break;
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
if (node.typeArguments === list) {
return 25 /* LessThanToken */;
}
@@ -41377,7 +42233,7 @@ var ts;
return 17 /* OpenParenToken */;
}
break;
- case 149 /* TypeReference */:
+ case 151 /* TypeReference */:
if (node.typeArguments === list) {
return 25 /* LessThanToken */;
}
@@ -41461,22 +42317,39 @@ var ts;
if (position > sourceFile.text.length) {
return 0; // past EOF
}
+ // no indentation when the indent style is set to none,
+ // so we can return fast
+ if (options.IndentStyle === ts.IndentStyle.None) {
+ return 0;
+ }
var precedingToken = ts.findPrecedingToken(position, sourceFile);
if (!precedingToken) {
return 0;
}
// no indentation in string \regex\template literals
- var precedingTokenIsLiteral = precedingToken.kind === 9 /* StringLiteral */ ||
- precedingToken.kind === 10 /* RegularExpressionLiteral */ ||
- precedingToken.kind === 11 /* NoSubstitutionTemplateLiteral */ ||
- precedingToken.kind === 12 /* TemplateHead */ ||
- precedingToken.kind === 13 /* TemplateMiddle */ ||
- precedingToken.kind === 14 /* TemplateTail */;
+ var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind);
if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) {
return 0;
}
var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
- if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 179 /* BinaryExpression */) {
+ // indentation is first non-whitespace character in a previous line
+ // for block indentation, we should look for a line which contains something that's not
+ // whitespace.
+ if (options.IndentStyle === ts.IndentStyle.Block) {
+ // move backwards until we find a line with a non-whitespace character,
+ // then find the first non-whitespace character for that line.
+ var current_1 = position;
+ while (current_1 > 0) {
+ var char = sourceFile.text.charCodeAt(current_1);
+ if (!ts.isWhiteSpace(char) && !ts.isLineBreak(char)) {
+ break;
+ }
+ current_1--;
+ }
+ var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile);
+ return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options);
+ }
+ if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 181 /* BinaryExpression */) {
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
if (actualIndentation !== -1 /* Unknown */) {
@@ -41595,7 +42468,7 @@ var ts;
// - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually
// - parent and child are not on the same line
var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) &&
- (parent.kind === 246 /* SourceFile */ || !parentAndChildShareLine);
+ (parent.kind === 248 /* SourceFile */ || !parentAndChildShareLine);
if (!useActualIndentation) {
return -1 /* Unknown */;
}
@@ -41628,8 +42501,8 @@ var ts;
return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
}
function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) {
- if (parent.kind === 194 /* IfStatement */ && parent.elseStatement === child) {
- var elseKeyword = ts.findChildOfKind(parent, 78 /* ElseKeyword */, sourceFile);
+ if (parent.kind === 196 /* IfStatement */ && parent.elseStatement === child) {
+ var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile);
ts.Debug.assert(elseKeyword !== undefined);
var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line;
return elseKeywordStartLine === childStartLine;
@@ -41640,23 +42513,23 @@ var ts;
function getContainingList(node, sourceFile) {
if (node.parent) {
switch (node.parent.kind) {
- case 149 /* TypeReference */:
+ case 151 /* TypeReference */:
if (node.parent.typeArguments &&
ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) {
return node.parent.typeArguments;
}
break;
- case 163 /* ObjectLiteralExpression */:
+ case 165 /* ObjectLiteralExpression */:
return node.parent.properties;
- case 162 /* ArrayLiteralExpression */:
+ case 164 /* ArrayLiteralExpression */:
return node.parent.elements;
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */: {
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */: {
var start = node.getStart(sourceFile);
if (node.parent.typeParameters &&
ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) {
@@ -41667,8 +42540,8 @@ var ts;
}
break;
}
- case 167 /* NewExpression */:
- case 166 /* CallExpression */: {
+ case 169 /* NewExpression */:
+ case 168 /* CallExpression */: {
var start = node.getStart(sourceFile);
if (node.parent.typeArguments &&
ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) {
@@ -41698,8 +42571,8 @@ var ts;
if (node.kind === 18 /* CloseParenToken */) {
return -1 /* Unknown */;
}
- if (node.parent && (node.parent.kind === 166 /* CallExpression */ ||
- node.parent.kind === 167 /* NewExpression */) &&
+ if (node.parent && (node.parent.kind === 168 /* CallExpression */ ||
+ node.parent.kind === 169 /* NewExpression */) &&
node.parent.expression !== node) {
var fullCallOrNewExpression = node.parent.expression;
var startingExpression = getStartingExpression(fullCallOrNewExpression);
@@ -41717,10 +42590,10 @@ var ts;
function getStartingExpression(node) {
while (true) {
switch (node.kind) {
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
- case 164 /* PropertyAccessExpression */:
- case 165 /* ElementAccessExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
+ case 166 /* PropertyAccessExpression */:
+ case 167 /* ElementAccessExpression */:
node = node.expression;
break;
default:
@@ -41785,42 +42658,43 @@ var ts;
SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn;
function nodeContentIsAlwaysIndented(kind) {
switch (kind) {
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
- case 213 /* InterfaceDeclaration */:
- case 215 /* EnumDeclaration */:
- case 214 /* TypeAliasDeclaration */:
- case 162 /* ArrayLiteralExpression */:
- case 190 /* Block */:
- case 217 /* ModuleBlock */:
- case 163 /* ObjectLiteralExpression */:
- case 153 /* TypeLiteral */:
- case 155 /* TupleType */:
- case 218 /* CaseBlock */:
- case 240 /* DefaultClause */:
- case 239 /* CaseClause */:
- case 170 /* ParenthesizedExpression */:
- case 164 /* PropertyAccessExpression */:
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
- case 191 /* VariableStatement */:
- case 209 /* VariableDeclaration */:
- case 225 /* ExportAssignment */:
- case 202 /* ReturnStatement */:
- case 180 /* ConditionalExpression */:
- case 160 /* ArrayBindingPattern */:
- case 159 /* ObjectBindingPattern */:
- case 231 /* JsxElement */:
- case 232 /* JsxSelfClosingElement */:
- case 140 /* MethodSignature */:
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */:
- case 136 /* Parameter */:
- case 150 /* FunctionType */:
- case 151 /* ConstructorType */:
- case 158 /* ParenthesizedType */:
- case 168 /* TaggedTemplateExpression */:
- case 176 /* AwaitExpression */:
+ case 195 /* ExpressionStatement */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
+ case 215 /* InterfaceDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
+ case 164 /* ArrayLiteralExpression */:
+ case 192 /* Block */:
+ case 219 /* ModuleBlock */:
+ case 165 /* ObjectLiteralExpression */:
+ case 155 /* TypeLiteral */:
+ case 157 /* TupleType */:
+ case 220 /* CaseBlock */:
+ case 242 /* DefaultClause */:
+ case 241 /* CaseClause */:
+ case 172 /* ParenthesizedExpression */:
+ case 166 /* PropertyAccessExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
+ case 193 /* VariableStatement */:
+ case 211 /* VariableDeclaration */:
+ case 227 /* ExportAssignment */:
+ case 204 /* ReturnStatement */:
+ case 182 /* ConditionalExpression */:
+ case 162 /* ArrayBindingPattern */:
+ case 161 /* ObjectBindingPattern */:
+ case 233 /* JsxElement */:
+ case 234 /* JsxSelfClosingElement */:
+ case 142 /* MethodSignature */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 138 /* Parameter */:
+ case 152 /* FunctionType */:
+ case 153 /* ConstructorType */:
+ case 160 /* ParenthesizedType */:
+ case 170 /* TaggedTemplateExpression */:
+ case 178 /* AwaitExpression */:
return true;
}
return false;
@@ -41830,20 +42704,20 @@ var ts;
return true;
}
switch (parent) {
- case 195 /* DoStatement */:
- case 196 /* WhileStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 197 /* ForStatement */:
- case 194 /* IfStatement */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 141 /* MethodDeclaration */:
- case 172 /* ArrowFunction */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- return child !== 190 /* Block */;
+ case 197 /* DoStatement */:
+ case 198 /* WhileStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 199 /* ForStatement */:
+ case 196 /* IfStatement */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 143 /* MethodDeclaration */:
+ case 174 /* ArrowFunction */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ return child !== 192 /* Block */;
default:
return false;
}
@@ -41985,7 +42859,7 @@ var ts;
return pos;
};
NodeObject.prototype.createSyntaxList = function (nodes) {
- var list = createNode(269 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this);
+ var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this);
list._children = [];
var pos = nodes.pos;
for (var _i = 0; _i < nodes.length; _i++) {
@@ -42004,7 +42878,7 @@ var ts;
NodeObject.prototype.createChildren = function (sourceFile) {
var _this = this;
var children;
- if (this.kind >= 133 /* FirstNode */) {
+ if (this.kind >= 135 /* FirstNode */) {
scanner.setText((sourceFile || this.getSourceFile()).text);
children = [];
var pos = this.pos;
@@ -42051,7 +42925,7 @@ var ts;
return undefined;
}
var child = children[0];
- return child.kind < 133 /* FirstNode */ ? child : child.getFirstToken(sourceFile);
+ return child.kind < 135 /* FirstNode */ ? child : child.getFirstToken(sourceFile);
};
NodeObject.prototype.getLastToken = function (sourceFile) {
var children = this.getChildren(sourceFile);
@@ -42059,7 +42933,7 @@ var ts;
if (!child) {
return undefined;
}
- return child.kind < 133 /* FirstNode */ ? child : child.getLastToken(sourceFile);
+ return child.kind < 135 /* FirstNode */ ? child : child.getLastToken(sourceFile);
};
return NodeObject;
})();
@@ -42108,7 +42982,7 @@ var ts;
if (ts.indexOf(declarations, declaration) === indexOfDeclaration) {
var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration);
// If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments
- if (canUseParsedParamTagComments && declaration.kind === 136 /* Parameter */) {
+ if (canUseParsedParamTagComments && declaration.kind === 138 /* Parameter */) {
ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) {
var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
if (cleanedParamJsDocComment) {
@@ -42117,15 +42991,15 @@ var ts;
});
}
// If this is left side of dotted module declaration, there is no doc comments associated with this node
- if (declaration.kind === 216 /* ModuleDeclaration */ && declaration.body.kind === 216 /* ModuleDeclaration */) {
+ if (declaration.kind === 218 /* ModuleDeclaration */ && declaration.body.kind === 218 /* ModuleDeclaration */) {
return;
}
// If this is dotted module name, get the doc comments from the parent
- while (declaration.kind === 216 /* ModuleDeclaration */ && declaration.parent.kind === 216 /* ModuleDeclaration */) {
+ while (declaration.kind === 218 /* ModuleDeclaration */ && declaration.parent.kind === 218 /* ModuleDeclaration */) {
declaration = declaration.parent;
}
// Get the cleaned js doc comment text from the declaration
- ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) {
+ ts.forEach(getJsDocCommentTextRange(declaration.kind === 211 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) {
var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
if (cleanedJsDocComment) {
ts.addRange(jsDocCommentParts, cleanedJsDocComment);
@@ -42469,9 +43343,9 @@ var ts;
if (result_2 !== undefined) {
return result_2;
}
- if (declaration.name.kind === 134 /* ComputedPropertyName */) {
+ if (declaration.name.kind === 136 /* ComputedPropertyName */) {
var expr = declaration.name.expression;
- if (expr.kind === 164 /* PropertyAccessExpression */) {
+ if (expr.kind === 166 /* PropertyAccessExpression */) {
return expr.name.text;
}
return getTextOfIdentifierOrLiteral(expr);
@@ -42481,7 +43355,7 @@ var ts;
}
function getTextOfIdentifierOrLiteral(node) {
if (node) {
- if (node.kind === 67 /* Identifier */ ||
+ if (node.kind === 69 /* Identifier */ ||
node.kind === 9 /* StringLiteral */ ||
node.kind === 8 /* NumericLiteral */) {
return node.text;
@@ -42491,9 +43365,9 @@ var ts;
}
function visit(node) {
switch (node.kind) {
- case 211 /* FunctionDeclaration */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 213 /* FunctionDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
var functionDeclaration = node;
var declarationName = getDeclarationName(functionDeclaration);
if (declarationName) {
@@ -42513,60 +43387,60 @@ var ts;
ts.forEachChild(node, visit);
}
break;
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 214 /* TypeAliasDeclaration */:
- case 215 /* EnumDeclaration */:
- case 216 /* ModuleDeclaration */:
- case 219 /* ImportEqualsDeclaration */:
- case 228 /* ExportSpecifier */:
- case 224 /* ImportSpecifier */:
- case 219 /* ImportEqualsDeclaration */:
- case 221 /* ImportClause */:
- case 222 /* NamespaceImport */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 153 /* TypeLiteral */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 218 /* ModuleDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 230 /* ExportSpecifier */:
+ case 226 /* ImportSpecifier */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 223 /* ImportClause */:
+ case 224 /* NamespaceImport */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 155 /* TypeLiteral */:
addDeclaration(node);
// fall through
- case 142 /* Constructor */:
- case 191 /* VariableStatement */:
- case 210 /* VariableDeclarationList */:
- case 159 /* ObjectBindingPattern */:
- case 160 /* ArrayBindingPattern */:
- case 217 /* ModuleBlock */:
+ case 144 /* Constructor */:
+ case 193 /* VariableStatement */:
+ case 212 /* VariableDeclarationList */:
+ case 161 /* ObjectBindingPattern */:
+ case 162 /* ArrayBindingPattern */:
+ case 219 /* ModuleBlock */:
ts.forEachChild(node, visit);
break;
- case 190 /* Block */:
+ case 192 /* Block */:
if (ts.isFunctionBlock(node)) {
ts.forEachChild(node, visit);
}
break;
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
// Only consider properties defined as constructor parameters
if (!(node.flags & 112 /* AccessibilityModifier */)) {
break;
}
// fall through
- case 209 /* VariableDeclaration */:
- case 161 /* BindingElement */:
+ case 211 /* VariableDeclaration */:
+ case 163 /* BindingElement */:
if (ts.isBindingPattern(node.name)) {
ts.forEachChild(node.name, visit);
break;
}
- case 245 /* EnumMember */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
+ case 247 /* EnumMember */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
addDeclaration(node);
break;
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
// Handle named exports case e.g.:
// export {a, b as B} from "mod";
if (node.exportClause) {
ts.forEach(node.exportClause.elements, visit);
}
break;
- case 220 /* ImportDeclaration */:
+ case 222 /* ImportDeclaration */:
var importClause = node.importClause;
if (importClause) {
// Handle default import case e.g.:
@@ -42578,7 +43452,7 @@ var ts;
// import * as NS from "mod";
// import {a, b as B} from "mod";
if (importClause.namedBindings) {
- if (importClause.namedBindings.kind === 222 /* NamespaceImport */) {
+ if (importClause.namedBindings.kind === 224 /* NamespaceImport */) {
addDeclaration(importClause.namedBindings);
}
else {
@@ -42605,6 +43479,12 @@ var ts;
HighlightSpanKind.reference = "reference";
HighlightSpanKind.writtenReference = "writtenReference";
})(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {}));
+ (function (IndentStyle) {
+ IndentStyle[IndentStyle["None"] = 0] = "None";
+ IndentStyle[IndentStyle["Block"] = 1] = "Block";
+ IndentStyle[IndentStyle["Smart"] = 2] = "Smart";
+ })(ts.IndentStyle || (ts.IndentStyle = {}));
+ var IndentStyle = ts.IndentStyle;
(function (SymbolDisplayPartKind) {
SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName";
SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className";
@@ -42782,16 +43662,16 @@ var ts;
}
return ts.forEach(symbol.declarations, function (declaration) {
// Function expressions are local
- if (declaration.kind === 171 /* FunctionExpression */) {
+ if (declaration.kind === 173 /* FunctionExpression */) {
return true;
}
- if (declaration.kind !== 209 /* VariableDeclaration */ && declaration.kind !== 211 /* FunctionDeclaration */) {
+ if (declaration.kind !== 211 /* VariableDeclaration */ && declaration.kind !== 213 /* FunctionDeclaration */) {
return false;
}
// If the parent is not sourceFile or module block it is local variable
for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) {
// Reached source file or module block
- if (parent_8.kind === 246 /* SourceFile */ || parent_8.kind === 217 /* ModuleBlock */) {
+ if (parent_8.kind === 248 /* SourceFile */ || parent_8.kind === 219 /* ModuleBlock */) {
return false;
}
}
@@ -42928,8 +43808,8 @@ var ts;
// We are not doing a full typecheck, we are not resolving the whole context,
// so pass --noResolve to avoid reporting missing file errors.
options.noResolve = true;
- // Parse
- var inputFileName = transpileOptions.fileName || "module.ts";
+ // if jsx is specified then treat file as .tsx
+ var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts");
var sourceFile = ts.createSourceFile(inputFileName, input, options.target);
if (transpileOptions.moduleName) {
sourceFile.moduleName = transpileOptions.moduleName;
@@ -43191,10 +44071,10 @@ var ts;
// export {a as b} from "mod"
// export import i = require("mod")
while (token !== 1 /* EndOfFileToken */) {
- if (token === 120 /* DeclareKeyword */) {
+ if (token === 122 /* DeclareKeyword */) {
// declare module "mod"
token = scanner.scan();
- if (token === 123 /* ModuleKeyword */) {
+ if (token === 125 /* ModuleKeyword */) {
token = scanner.scan();
if (token === 9 /* StringLiteral */) {
recordAmbientExternalModule();
@@ -43202,7 +44082,7 @@ var ts;
}
}
}
- else if (token === 87 /* ImportKeyword */) {
+ else if (token === 89 /* ImportKeyword */) {
token = scanner.scan();
if (token === 9 /* StringLiteral */) {
// import "mod";
@@ -43210,9 +44090,9 @@ var ts;
continue;
}
else {
- if (token === 67 /* Identifier */ || ts.isKeyword(token)) {
+ if (token === 69 /* Identifier */ || ts.isKeyword(token)) {
token = scanner.scan();
- if (token === 131 /* FromKeyword */) {
+ if (token === 133 /* FromKeyword */) {
token = scanner.scan();
if (token === 9 /* StringLiteral */) {
// import d from "mod";
@@ -43220,9 +44100,9 @@ var ts;
continue;
}
}
- else if (token === 55 /* EqualsToken */) {
+ else if (token === 56 /* EqualsToken */) {
token = scanner.scan();
- if (token === 125 /* RequireKeyword */) {
+ if (token === 127 /* RequireKeyword */) {
token = scanner.scan();
if (token === 17 /* OpenParenToken */) {
token = scanner.scan();
@@ -43251,7 +44131,7 @@ var ts;
}
if (token === 16 /* CloseBraceToken */) {
token = scanner.scan();
- if (token === 131 /* FromKeyword */) {
+ if (token === 133 /* FromKeyword */) {
token = scanner.scan();
if (token === 9 /* StringLiteral */) {
// import {a as A} from "mod";
@@ -43263,11 +44143,11 @@ var ts;
}
else if (token === 37 /* AsteriskToken */) {
token = scanner.scan();
- if (token === 114 /* AsKeyword */) {
+ if (token === 116 /* AsKeyword */) {
token = scanner.scan();
- if (token === 67 /* Identifier */ || ts.isKeyword(token)) {
+ if (token === 69 /* Identifier */ || ts.isKeyword(token)) {
token = scanner.scan();
- if (token === 131 /* FromKeyword */) {
+ if (token === 133 /* FromKeyword */) {
token = scanner.scan();
if (token === 9 /* StringLiteral */) {
// import * as NS from "mod"
@@ -43280,7 +44160,7 @@ var ts;
}
}
}
- else if (token === 80 /* ExportKeyword */) {
+ else if (token === 82 /* ExportKeyword */) {
token = scanner.scan();
if (token === 15 /* OpenBraceToken */) {
token = scanner.scan();
@@ -43290,7 +44170,7 @@ var ts;
}
if (token === 16 /* CloseBraceToken */) {
token = scanner.scan();
- if (token === 131 /* FromKeyword */) {
+ if (token === 133 /* FromKeyword */) {
token = scanner.scan();
if (token === 9 /* StringLiteral */) {
// export {a as A} from "mod";
@@ -43302,7 +44182,7 @@ var ts;
}
else if (token === 37 /* AsteriskToken */) {
token = scanner.scan();
- if (token === 131 /* FromKeyword */) {
+ if (token === 133 /* FromKeyword */) {
token = scanner.scan();
if (token === 9 /* StringLiteral */) {
// export * from "mod"
@@ -43310,13 +44190,13 @@ var ts;
}
}
}
- else if (token === 87 /* ImportKeyword */) {
+ else if (token === 89 /* ImportKeyword */) {
token = scanner.scan();
- if (token === 67 /* Identifier */ || ts.isKeyword(token)) {
+ if (token === 69 /* Identifier */ || ts.isKeyword(token)) {
token = scanner.scan();
- if (token === 55 /* EqualsToken */) {
+ if (token === 56 /* EqualsToken */) {
token = scanner.scan();
- if (token === 125 /* RequireKeyword */) {
+ if (token === 127 /* RequireKeyword */) {
token = scanner.scan();
if (token === 17 /* OpenParenToken */) {
token = scanner.scan();
@@ -43344,7 +44224,7 @@ var ts;
/// Helpers
function getTargetLabel(referenceNode, labelName) {
while (referenceNode) {
- if (referenceNode.kind === 205 /* LabeledStatement */ && referenceNode.label.text === labelName) {
+ if (referenceNode.kind === 207 /* LabeledStatement */ && referenceNode.label.text === labelName) {
return referenceNode.label;
}
referenceNode = referenceNode.parent;
@@ -43352,13 +44232,13 @@ var ts;
return undefined;
}
function isJumpStatementTarget(node) {
- return node.kind === 67 /* Identifier */ &&
- (node.parent.kind === 201 /* BreakStatement */ || node.parent.kind === 200 /* ContinueStatement */) &&
+ return node.kind === 69 /* Identifier */ &&
+ (node.parent.kind === 203 /* BreakStatement */ || node.parent.kind === 202 /* ContinueStatement */) &&
node.parent.label === node;
}
function isLabelOfLabeledStatement(node) {
- return node.kind === 67 /* Identifier */ &&
- node.parent.kind === 205 /* LabeledStatement */ &&
+ return node.kind === 69 /* Identifier */ &&
+ node.parent.kind === 207 /* LabeledStatement */ &&
node.parent.label === node;
}
/**
@@ -43366,7 +44246,7 @@ var ts;
* Note: 'node' cannot be a SourceFile.
*/
function isLabeledBy(node, labelName) {
- for (var owner = node.parent; owner.kind === 205 /* LabeledStatement */; owner = owner.parent) {
+ for (var owner = node.parent; owner.kind === 207 /* LabeledStatement */; owner = owner.parent) {
if (owner.label.text === labelName) {
return true;
}
@@ -43377,49 +44257,49 @@ var ts;
return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node);
}
function isRightSideOfQualifiedName(node) {
- return node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node;
+ return node.parent.kind === 135 /* QualifiedName */ && node.parent.right === node;
}
function isRightSideOfPropertyAccess(node) {
- return node && node.parent && node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node;
+ return node && node.parent && node.parent.kind === 166 /* PropertyAccessExpression */ && node.parent.name === node;
}
function isCallExpressionTarget(node) {
if (isRightSideOfPropertyAccess(node)) {
node = node.parent;
}
- return node && node.parent && node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node;
+ return node && node.parent && node.parent.kind === 168 /* CallExpression */ && node.parent.expression === node;
}
function isNewExpressionTarget(node) {
if (isRightSideOfPropertyAccess(node)) {
node = node.parent;
}
- return node && node.parent && node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node;
+ return node && node.parent && node.parent.kind === 169 /* NewExpression */ && node.parent.expression === node;
}
function isNameOfModuleDeclaration(node) {
- return node.parent.kind === 216 /* ModuleDeclaration */ && node.parent.name === node;
+ return node.parent.kind === 218 /* ModuleDeclaration */ && node.parent.name === node;
}
function isNameOfFunctionDeclaration(node) {
- return node.kind === 67 /* Identifier */ &&
+ return node.kind === 69 /* Identifier */ &&
ts.isFunctionLike(node.parent) && node.parent.name === node;
}
/** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */
function isNameOfPropertyAssignment(node) {
- return (node.kind === 67 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) &&
- (node.parent.kind === 243 /* PropertyAssignment */ || node.parent.kind === 244 /* ShorthandPropertyAssignment */) && node.parent.name === node;
+ return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) &&
+ (node.parent.kind === 245 /* PropertyAssignment */ || node.parent.kind === 246 /* ShorthandPropertyAssignment */) && node.parent.name === node;
}
function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) {
if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) {
switch (node.parent.kind) {
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 243 /* PropertyAssignment */:
- case 245 /* EnumMember */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 216 /* ModuleDeclaration */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 245 /* PropertyAssignment */:
+ case 247 /* EnumMember */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 218 /* ModuleDeclaration */:
return node.parent.name === node;
- case 165 /* ElementAccessExpression */:
+ case 167 /* ElementAccessExpression */:
return node.parent.argumentExpression === node;
}
}
@@ -43478,7 +44358,7 @@ var ts;
})(BreakContinueSearchType || (BreakContinueSearchType = {}));
// A cache of completion entries for keywords, these do not change between sessions
var keywordCompletions = [];
- for (var i = 68 /* FirstKeyword */; i <= 132 /* LastKeyword */; i++) {
+ for (var i = 70 /* FirstKeyword */; i <= 134 /* LastKeyword */; i++) {
keywordCompletions.push({
name: ts.tokenToString(i),
kind: ScriptElementKind.keyword,
@@ -43493,17 +44373,17 @@ var ts;
return undefined;
}
switch (node.kind) {
- case 246 /* SourceFile */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 215 /* EnumDeclaration */:
- case 216 /* ModuleDeclaration */:
+ case 248 /* SourceFile */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 218 /* ModuleDeclaration */:
return node;
}
}
@@ -43511,38 +44391,38 @@ var ts;
ts.getContainerNode = getContainerNode;
/* @internal */ function getNodeKind(node) {
switch (node.kind) {
- case 216 /* ModuleDeclaration */: return ScriptElementKind.moduleElement;
- case 212 /* ClassDeclaration */: return ScriptElementKind.classElement;
- case 213 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement;
- case 214 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement;
- case 215 /* EnumDeclaration */: return ScriptElementKind.enumElement;
- case 209 /* VariableDeclaration */:
+ case 218 /* ModuleDeclaration */: return ScriptElementKind.moduleElement;
+ case 214 /* ClassDeclaration */: return ScriptElementKind.classElement;
+ case 215 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement;
+ case 216 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement;
+ case 217 /* EnumDeclaration */: return ScriptElementKind.enumElement;
+ case 211 /* VariableDeclaration */:
return ts.isConst(node)
? ScriptElementKind.constElement
: ts.isLet(node)
? ScriptElementKind.letElement
: ScriptElementKind.variableElement;
- case 211 /* FunctionDeclaration */: return ScriptElementKind.functionElement;
- case 143 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement;
- case 144 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement;
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 213 /* FunctionDeclaration */: return ScriptElementKind.functionElement;
+ case 145 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement;
+ case 146 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement;
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
return ScriptElementKind.memberFunctionElement;
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
return ScriptElementKind.memberVariableElement;
- case 147 /* IndexSignature */: return ScriptElementKind.indexSignatureElement;
- case 146 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement;
- case 145 /* CallSignature */: return ScriptElementKind.callSignatureElement;
- case 142 /* Constructor */: return ScriptElementKind.constructorImplementationElement;
- case 135 /* TypeParameter */: return ScriptElementKind.typeParameterElement;
- case 245 /* EnumMember */: return ScriptElementKind.variableElement;
- case 136 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
- case 219 /* ImportEqualsDeclaration */:
- case 224 /* ImportSpecifier */:
- case 221 /* ImportClause */:
- case 228 /* ExportSpecifier */:
- case 222 /* NamespaceImport */:
+ case 149 /* IndexSignature */: return ScriptElementKind.indexSignatureElement;
+ case 148 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement;
+ case 147 /* CallSignature */: return ScriptElementKind.callSignatureElement;
+ case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement;
+ case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement;
+ case 247 /* EnumMember */: return ScriptElementKind.variableElement;
+ case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
+ case 221 /* ImportEqualsDeclaration */:
+ case 226 /* ImportSpecifier */:
+ case 223 /* ImportClause */:
+ case 230 /* ExportSpecifier */:
+ case 224 /* NamespaceImport */:
return ScriptElementKind.alias;
}
return ScriptElementKind.unknown;
@@ -43788,44 +44668,44 @@ var ts;
return false;
}
switch (node.kind) {
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file));
return true;
- case 225 /* ExportAssignment */:
+ case 227 /* ExportAssignment */:
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file));
return true;
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
var classDeclaration = node;
if (checkModifiers(classDeclaration.modifiers) ||
checkTypeParameters(classDeclaration.typeParameters)) {
return true;
}
break;
- case 241 /* HeritageClause */:
+ case 243 /* HeritageClause */:
var heritageClause = node;
- if (heritageClause.token === 104 /* ImplementsKeyword */) {
+ if (heritageClause.token === 106 /* ImplementsKeyword */) {
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file));
return true;
}
break;
- case 213 /* InterfaceDeclaration */:
+ case 215 /* InterfaceDeclaration */:
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file));
return true;
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file));
return true;
- case 214 /* TypeAliasDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file));
return true;
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 171 /* FunctionExpression */:
- case 211 /* FunctionDeclaration */:
- case 172 /* ArrowFunction */:
- case 211 /* FunctionDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 173 /* FunctionExpression */:
+ case 213 /* FunctionDeclaration */:
+ case 174 /* ArrowFunction */:
+ case 213 /* FunctionDeclaration */:
var functionDeclaration = node;
if (checkModifiers(functionDeclaration.modifiers) ||
checkTypeParameters(functionDeclaration.typeParameters) ||
@@ -43833,20 +44713,20 @@ var ts;
return true;
}
break;
- case 191 /* VariableStatement */:
+ case 193 /* VariableStatement */:
var variableStatement = node;
if (checkModifiers(variableStatement.modifiers)) {
return true;
}
break;
- case 209 /* VariableDeclaration */:
+ case 211 /* VariableDeclaration */:
var variableDeclaration = node;
if (checkTypeAnnotation(variableDeclaration.type)) {
return true;
}
break;
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
var expression = node;
if (expression.typeArguments && expression.typeArguments.length > 0) {
var start = expression.typeArguments.pos;
@@ -43854,7 +44734,7 @@ var ts;
return true;
}
break;
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
var parameter = node;
if (parameter.modifiers) {
var start = parameter.modifiers.pos;
@@ -43870,17 +44750,17 @@ var ts;
return true;
}
break;
- case 139 /* PropertyDeclaration */:
+ case 141 /* PropertyDeclaration */:
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file));
return true;
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file));
return true;
- case 169 /* TypeAssertionExpression */:
+ case 171 /* TypeAssertionExpression */:
var typeAssertionExpression = node;
diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file));
return true;
- case 137 /* Decorator */:
+ case 139 /* Decorator */:
diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file));
return true;
}
@@ -43906,18 +44786,18 @@ var ts;
for (var _i = 0; _i < modifiers.length; _i++) {
var modifier = modifiers[_i];
switch (modifier.kind) {
- case 110 /* PublicKeyword */:
- case 108 /* PrivateKeyword */:
- case 109 /* ProtectedKeyword */:
- case 120 /* DeclareKeyword */:
+ case 112 /* PublicKeyword */:
+ case 110 /* PrivateKeyword */:
+ case 111 /* ProtectedKeyword */:
+ case 122 /* DeclareKeyword */:
diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind)));
return true;
// These are all legal modifiers.
- case 111 /* StaticKeyword */:
- case 80 /* ExportKeyword */:
- case 72 /* ConstKeyword */:
- case 75 /* DefaultKeyword */:
- case 113 /* AbstractKeyword */:
+ case 113 /* StaticKeyword */:
+ case 82 /* ExportKeyword */:
+ case 74 /* ConstKeyword */:
+ case 77 /* DefaultKeyword */:
+ case 115 /* AbstractKeyword */:
}
}
}
@@ -44003,9 +44883,9 @@ var ts;
isJsDocTagName = true;
}
switch (tag.kind) {
- case 267 /* JSDocTypeTag */:
- case 265 /* JSDocParameterTag */:
- case 266 /* JSDocReturnTag */:
+ case 269 /* JSDocTypeTag */:
+ case 267 /* JSDocParameterTag */:
+ case 268 /* JSDocReturnTag */:
var tagWithExpression = tag;
if (tagWithExpression.typeExpression) {
insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end;
@@ -44032,9 +44912,9 @@ var ts;
// Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS|
// Skip this partial identifier and adjust the contextToken to the token that precedes it.
if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) {
- var start_4 = new Date().getTime();
+ var start_3 = new Date().getTime();
contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile);
- log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_4));
+ log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_3));
}
// Find the node where completion is requested on.
// Also determine whether we are trying to complete with members of that node
@@ -44042,6 +44922,7 @@ var ts;
var node = currentToken;
var isRightOfDot = false;
var isRightOfOpenTag = false;
+ var isStartingCloseTag = false;
var location = ts.getTouchingPropertyName(sourceFile, position);
if (contextToken) {
// Bail out if this is a known invalid completion location
@@ -44051,11 +44932,11 @@ var ts;
}
var parent_9 = contextToken.parent, kind = contextToken.kind;
if (kind === 21 /* DotToken */) {
- if (parent_9.kind === 164 /* PropertyAccessExpression */) {
+ if (parent_9.kind === 166 /* PropertyAccessExpression */) {
node = contextToken.parent.expression;
isRightOfDot = true;
}
- else if (parent_9.kind === 133 /* QualifiedName */) {
+ else if (parent_9.kind === 135 /* QualifiedName */) {
node = contextToken.parent.left;
isRightOfDot = true;
}
@@ -44065,9 +44946,14 @@ var ts;
return undefined;
}
}
- else if (kind === 25 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) {
- isRightOfOpenTag = true;
- location = contextToken;
+ else if (sourceFile.languageVariant === 1 /* JSX */) {
+ if (kind === 25 /* LessThanToken */) {
+ isRightOfOpenTag = true;
+ location = contextToken;
+ }
+ else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 237 /* JsxClosingElement */) {
+ isStartingCloseTag = true;
+ }
}
}
var semanticStart = new Date().getTime();
@@ -44088,6 +44974,12 @@ var ts;
isMemberCompletion = true;
isNewIdentifierLocation = false;
}
+ else if (isStartingCloseTag) {
+ var tagName = contextToken.parent.parent.openingElement.tagName;
+ symbols = [typeChecker.getSymbolAtLocation(tagName)];
+ isMemberCompletion = true;
+ isNewIdentifierLocation = false;
+ }
else {
// For JavaScript or TypeScript, if we're not after a dot, then just try to get the
// global symbols in scope. These results should be valid for either language as
@@ -44102,7 +44994,7 @@ var ts;
// Right of dot member completion list
isMemberCompletion = true;
isNewIdentifierLocation = false;
- if (node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */) {
+ if (node.kind === 69 /* Identifier */ || node.kind === 135 /* QualifiedName */ || node.kind === 166 /* PropertyAccessExpression */) {
var symbol = typeChecker.getSymbolAtLocation(node);
// This is an alias, follow what it aliases
if (symbol && symbol.flags & 8388608 /* Alias */) {
@@ -44158,7 +45050,7 @@ var ts;
}
if (jsxContainer = tryGetContainingJsxElement(contextToken)) {
var attrsType;
- if ((jsxContainer.kind === 232 /* JsxSelfClosingElement */) || (jsxContainer.kind === 233 /* JsxOpeningElement */)) {
+ if ((jsxContainer.kind === 234 /* JsxSelfClosingElement */) || (jsxContainer.kind === 235 /* JsxOpeningElement */)) {
// Cursor is inside a JSX self-closing element or opening element
attrsType = typeChecker.getJsxElementAttributesType(jsxContainer);
if (attrsType) {
@@ -44224,49 +45116,64 @@ var ts;
var start = new Date().getTime();
var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) ||
isSolelyIdentifierDefinitionLocation(contextToken) ||
- isDotOfNumericLiteral(contextToken);
+ isDotOfNumericLiteral(contextToken) ||
+ isInJsxText(contextToken);
log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start));
return result;
}
+ function isInJsxText(contextToken) {
+ if (contextToken.kind === 236 /* JsxText */) {
+ return true;
+ }
+ if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) {
+ if (contextToken.parent.kind === 235 /* JsxOpeningElement */) {
+ return true;
+ }
+ if (contextToken.parent.kind === 237 /* JsxClosingElement */ || contextToken.parent.kind === 234 /* JsxSelfClosingElement */) {
+ return contextToken.parent.parent && contextToken.parent.parent.kind === 233 /* JsxElement */;
+ }
+ }
+ return false;
+ }
function isNewIdentifierDefinitionLocation(previousToken) {
if (previousToken) {
var containingNodeKind = previousToken.parent.kind;
switch (previousToken.kind) {
case 24 /* CommaToken */:
- return containingNodeKind === 166 /* CallExpression */ // func( a, |
- || containingNodeKind === 142 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
- || containingNodeKind === 167 /* NewExpression */ // new C(a, |
- || containingNodeKind === 162 /* ArrayLiteralExpression */ // [a, |
- || containingNodeKind === 179 /* BinaryExpression */ // let x = (a, |
- || containingNodeKind === 150 /* FunctionType */; // var x: (s: string, list|
+ return containingNodeKind === 168 /* CallExpression */ // func( a, |
+ || containingNodeKind === 144 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
+ || containingNodeKind === 169 /* NewExpression */ // new C(a, |
+ || containingNodeKind === 164 /* ArrayLiteralExpression */ // [a, |
+ || containingNodeKind === 181 /* BinaryExpression */ // let x = (a, |
+ || containingNodeKind === 152 /* FunctionType */; // var x: (s: string, list|
case 17 /* OpenParenToken */:
- return containingNodeKind === 166 /* CallExpression */ // func( |
- || containingNodeKind === 142 /* Constructor */ // constructor( |
- || containingNodeKind === 167 /* NewExpression */ // new C(a|
- || containingNodeKind === 170 /* ParenthesizedExpression */ // let x = (a|
- || containingNodeKind === 158 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */
+ return containingNodeKind === 168 /* CallExpression */ // func( |
+ || containingNodeKind === 144 /* Constructor */ // constructor( |
+ || containingNodeKind === 169 /* NewExpression */ // new C(a|
+ || containingNodeKind === 172 /* ParenthesizedExpression */ // let x = (a|
+ || containingNodeKind === 160 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */
case 19 /* OpenBracketToken */:
- return containingNodeKind === 162 /* ArrayLiteralExpression */ // [ |
- || containingNodeKind === 147 /* IndexSignature */ // [ | : string ]
- || containingNodeKind === 134 /* ComputedPropertyName */; // [ | /* this can become an index signature */
- case 123 /* ModuleKeyword */: // module |
- case 124 /* NamespaceKeyword */:
+ return containingNodeKind === 164 /* ArrayLiteralExpression */ // [ |
+ || containingNodeKind === 149 /* IndexSignature */ // [ | : string ]
+ || containingNodeKind === 136 /* ComputedPropertyName */; // [ | /* this can become an index signature */
+ case 125 /* ModuleKeyword */: // module |
+ case 126 /* NamespaceKeyword */:
return true;
case 21 /* DotToken */:
- return containingNodeKind === 216 /* ModuleDeclaration */; // module A.|
+ return containingNodeKind === 218 /* ModuleDeclaration */; // module A.|
case 15 /* OpenBraceToken */:
- return containingNodeKind === 212 /* ClassDeclaration */; // class A{ |
- case 55 /* EqualsToken */:
- return containingNodeKind === 209 /* VariableDeclaration */ // let x = a|
- || containingNodeKind === 179 /* BinaryExpression */; // x = a|
+ return containingNodeKind === 214 /* ClassDeclaration */; // class A{ |
+ case 56 /* EqualsToken */:
+ return containingNodeKind === 211 /* VariableDeclaration */ // let x = a|
+ || containingNodeKind === 181 /* BinaryExpression */; // x = a|
case 12 /* TemplateHead */:
- return containingNodeKind === 181 /* TemplateExpression */; // `aa ${|
+ return containingNodeKind === 183 /* TemplateExpression */; // `aa ${|
case 13 /* TemplateMiddle */:
- return containingNodeKind === 188 /* TemplateSpan */; // `aa ${10} dd ${|
- case 110 /* PublicKeyword */:
- case 108 /* PrivateKeyword */:
- case 109 /* ProtectedKeyword */:
- return containingNodeKind === 139 /* PropertyDeclaration */; // class A{ public |
+ return containingNodeKind === 190 /* TemplateSpan */; // `aa ${10} dd ${|
+ case 112 /* PublicKeyword */:
+ case 110 /* PrivateKeyword */:
+ case 111 /* ProtectedKeyword */:
+ return containingNodeKind === 141 /* PropertyDeclaration */; // class A{ public |
}
// Previous token may have been a keyword that was converted to an identifier.
switch (previousToken.getText()) {
@@ -44282,13 +45189,13 @@ var ts;
if (contextToken.kind === 9 /* StringLiteral */
|| contextToken.kind === 10 /* RegularExpressionLiteral */
|| ts.isTemplateLiteralKind(contextToken.kind)) {
- var start_5 = contextToken.getStart();
+ var start_4 = contextToken.getStart();
var end = contextToken.getEnd();
// To be "in" one of these literals, the position has to be:
// 1. entirely within the token text.
// 2. at the end position of an unterminated token.
// 3. at the end of a regular expression (due to trailing flags like '/foo/g').
- if (start_5 < position && position < end) {
+ if (start_4 < position && position < end) {
return true;
}
if (position === end) {
@@ -44309,14 +45216,14 @@ var ts;
isMemberCompletion = true;
var typeForObject;
var existingMembers;
- if (objectLikeContainer.kind === 163 /* ObjectLiteralExpression */) {
+ if (objectLikeContainer.kind === 165 /* ObjectLiteralExpression */) {
// We are completing on contextual types, but may also include properties
// other than those within the declared type.
isNewIdentifierLocation = true;
typeForObject = typeChecker.getContextualType(objectLikeContainer);
existingMembers = objectLikeContainer.properties;
}
- else if (objectLikeContainer.kind === 159 /* ObjectBindingPattern */) {
+ else if (objectLikeContainer.kind === 161 /* ObjectBindingPattern */) {
// We are *only* completing on properties from the type being destructured.
isNewIdentifierLocation = false;
var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent);
@@ -44362,9 +45269,9 @@ var ts;
* @returns true if 'symbols' was successfully populated; false otherwise.
*/
function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) {
- var declarationKind = namedImportsOrExports.kind === 223 /* NamedImports */ ?
- 220 /* ImportDeclaration */ :
- 226 /* ExportDeclaration */;
+ var declarationKind = namedImportsOrExports.kind === 225 /* NamedImports */ ?
+ 222 /* ImportDeclaration */ :
+ 228 /* ExportDeclaration */;
var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind);
var moduleSpecifier = importOrExportDeclaration.moduleSpecifier;
if (!moduleSpecifier) {
@@ -44390,7 +45297,7 @@ var ts;
case 15 /* OpenBraceToken */: // let x = { |
case 24 /* CommaToken */:
var parent_10 = contextToken.parent;
- if (parent_10 && (parent_10.kind === 163 /* ObjectLiteralExpression */ || parent_10.kind === 159 /* ObjectBindingPattern */)) {
+ if (parent_10 && (parent_10.kind === 165 /* ObjectLiteralExpression */ || parent_10.kind === 161 /* ObjectBindingPattern */)) {
return parent_10;
}
break;
@@ -44408,8 +45315,8 @@ var ts;
case 15 /* OpenBraceToken */: // import { |
case 24 /* CommaToken */:
switch (contextToken.parent.kind) {
- case 223 /* NamedImports */:
- case 227 /* NamedExports */:
+ case 225 /* NamedImports */:
+ case 229 /* NamedExports */:
return contextToken.parent;
}
}
@@ -44421,30 +45328,33 @@ var ts;
var parent_11 = contextToken.parent;
switch (contextToken.kind) {
case 26 /* LessThanSlashToken */:
- case 38 /* SlashToken */:
- case 67 /* Identifier */:
- case 236 /* JsxAttribute */:
- case 237 /* JsxSpreadAttribute */:
- if (parent_11 && (parent_11.kind === 232 /* JsxSelfClosingElement */ || parent_11.kind === 233 /* JsxOpeningElement */)) {
+ case 39 /* SlashToken */:
+ case 69 /* Identifier */:
+ case 238 /* JsxAttribute */:
+ case 239 /* JsxSpreadAttribute */:
+ if (parent_11 && (parent_11.kind === 234 /* JsxSelfClosingElement */ || parent_11.kind === 235 /* JsxOpeningElement */)) {
return parent_11;
}
+ else if (parent_11.kind === 238 /* JsxAttribute */) {
+ return parent_11.parent;
+ }
break;
// The context token is the closing } or " of an attribute, which means
// its parent is a JsxExpression, whose parent is a JsxAttribute,
// whose parent is a JsxOpeningLikeElement
case 9 /* StringLiteral */:
- if (parent_11 && ((parent_11.kind === 236 /* JsxAttribute */) || (parent_11.kind === 237 /* JsxSpreadAttribute */))) {
+ if (parent_11 && ((parent_11.kind === 238 /* JsxAttribute */) || (parent_11.kind === 239 /* JsxSpreadAttribute */))) {
return parent_11.parent;
}
break;
case 16 /* CloseBraceToken */:
if (parent_11 &&
- parent_11.kind === 238 /* JsxExpression */ &&
+ parent_11.kind === 240 /* JsxExpression */ &&
parent_11.parent &&
- (parent_11.parent.kind === 236 /* JsxAttribute */)) {
+ (parent_11.parent.kind === 238 /* JsxAttribute */)) {
return parent_11.parent.parent;
}
- if (parent_11 && parent_11.kind === 237 /* JsxSpreadAttribute */) {
+ if (parent_11 && parent_11.kind === 239 /* JsxSpreadAttribute */) {
return parent_11.parent;
}
break;
@@ -44454,16 +45364,16 @@ var ts;
}
function isFunction(kind) {
switch (kind) {
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
- case 211 /* FunctionDeclaration */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 145 /* CallSignature */:
- case 146 /* ConstructSignature */:
- case 147 /* IndexSignature */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
+ case 213 /* FunctionDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 147 /* CallSignature */:
+ case 148 /* ConstructSignature */:
+ case 149 /* IndexSignature */:
return true;
}
return false;
@@ -44475,78 +45385,84 @@ var ts;
var containingNodeKind = contextToken.parent.kind;
switch (contextToken.kind) {
case 24 /* CommaToken */:
- return containingNodeKind === 209 /* VariableDeclaration */ ||
- containingNodeKind === 210 /* VariableDeclarationList */ ||
- containingNodeKind === 191 /* VariableStatement */ ||
- containingNodeKind === 215 /* EnumDeclaration */ ||
+ return containingNodeKind === 211 /* VariableDeclaration */ ||
+ containingNodeKind === 212 /* VariableDeclarationList */ ||
+ containingNodeKind === 193 /* VariableStatement */ ||
+ containingNodeKind === 217 /* EnumDeclaration */ ||
isFunction(containingNodeKind) ||
- containingNodeKind === 212 /* ClassDeclaration */ ||
- containingNodeKind === 184 /* ClassExpression */ ||
- containingNodeKind === 213 /* InterfaceDeclaration */ ||
- containingNodeKind === 160 /* ArrayBindingPattern */ ||
- containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, |
+ containingNodeKind === 214 /* ClassDeclaration */ ||
+ containingNodeKind === 186 /* ClassExpression */ ||
+ containingNodeKind === 215 /* InterfaceDeclaration */ ||
+ containingNodeKind === 162 /* ArrayBindingPattern */ ||
+ containingNodeKind === 216 /* TypeAliasDeclaration */; // type Map, K, |
case 21 /* DotToken */:
- return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.|
- case 53 /* ColonToken */:
- return containingNodeKind === 161 /* BindingElement */; // var {x :html|
+ return containingNodeKind === 162 /* ArrayBindingPattern */; // var [.|
+ case 54 /* ColonToken */:
+ return containingNodeKind === 163 /* BindingElement */; // var {x :html|
case 19 /* OpenBracketToken */:
- return containingNodeKind === 160 /* ArrayBindingPattern */; // var [x|
+ return containingNodeKind === 162 /* ArrayBindingPattern */; // var [x|
case 17 /* OpenParenToken */:
- return containingNodeKind === 242 /* CatchClause */ ||
+ return containingNodeKind === 244 /* CatchClause */ ||
isFunction(containingNodeKind);
case 15 /* OpenBraceToken */:
- return containingNodeKind === 215 /* EnumDeclaration */ ||
- containingNodeKind === 213 /* InterfaceDeclaration */ ||
- containingNodeKind === 153 /* TypeLiteral */; // let x : { |
+ return containingNodeKind === 217 /* EnumDeclaration */ ||
+ containingNodeKind === 215 /* InterfaceDeclaration */ ||
+ containingNodeKind === 155 /* TypeLiteral */; // let x : { |
case 23 /* SemicolonToken */:
- return containingNodeKind === 138 /* PropertySignature */ &&
+ return containingNodeKind === 140 /* PropertySignature */ &&
contextToken.parent && contextToken.parent.parent &&
- (contextToken.parent.parent.kind === 213 /* InterfaceDeclaration */ ||
- contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; |
+ (contextToken.parent.parent.kind === 215 /* InterfaceDeclaration */ ||
+ contextToken.parent.parent.kind === 155 /* TypeLiteral */); // let x : { a; |
case 25 /* LessThanToken */:
- return containingNodeKind === 212 /* ClassDeclaration */ ||
- containingNodeKind === 184 /* ClassExpression */ ||
- containingNodeKind === 213 /* InterfaceDeclaration */ ||
- containingNodeKind === 214 /* TypeAliasDeclaration */ ||
+ return containingNodeKind === 214 /* ClassDeclaration */ ||
+ containingNodeKind === 186 /* ClassExpression */ ||
+ containingNodeKind === 215 /* InterfaceDeclaration */ ||
+ containingNodeKind === 216 /* TypeAliasDeclaration */ ||
isFunction(containingNodeKind);
- case 111 /* StaticKeyword */:
- return containingNodeKind === 139 /* PropertyDeclaration */;
+ case 113 /* StaticKeyword */:
+ return containingNodeKind === 141 /* PropertyDeclaration */;
case 22 /* DotDotDotToken */:
- return containingNodeKind === 136 /* Parameter */ ||
+ return containingNodeKind === 138 /* Parameter */ ||
(contextToken.parent && contextToken.parent.parent &&
- contextToken.parent.parent.kind === 160 /* ArrayBindingPattern */); // var [...z|
- case 110 /* PublicKeyword */:
- case 108 /* PrivateKeyword */:
- case 109 /* ProtectedKeyword */:
- return containingNodeKind === 136 /* Parameter */;
- case 114 /* AsKeyword */:
- containingNodeKind === 224 /* ImportSpecifier */ ||
- containingNodeKind === 228 /* ExportSpecifier */ ||
- containingNodeKind === 222 /* NamespaceImport */;
- case 71 /* ClassKeyword */:
- case 79 /* EnumKeyword */:
- case 105 /* InterfaceKeyword */:
- case 85 /* FunctionKeyword */:
- case 100 /* VarKeyword */:
- case 121 /* GetKeyword */:
- case 127 /* SetKeyword */:
- case 87 /* ImportKeyword */:
- case 106 /* LetKeyword */:
- case 72 /* ConstKeyword */:
- case 112 /* YieldKeyword */:
- case 130 /* TypeKeyword */:
+ contextToken.parent.parent.kind === 162 /* ArrayBindingPattern */); // var [...z|
+ case 112 /* PublicKeyword */:
+ case 110 /* PrivateKeyword */:
+ case 111 /* ProtectedKeyword */:
+ return containingNodeKind === 138 /* Parameter */;
+ case 116 /* AsKeyword */:
+ return containingNodeKind === 226 /* ImportSpecifier */ ||
+ containingNodeKind === 230 /* ExportSpecifier */ ||
+ containingNodeKind === 224 /* NamespaceImport */;
+ case 73 /* ClassKeyword */:
+ case 81 /* EnumKeyword */:
+ case 107 /* InterfaceKeyword */:
+ case 87 /* FunctionKeyword */:
+ case 102 /* VarKeyword */:
+ case 123 /* GetKeyword */:
+ case 129 /* SetKeyword */:
+ case 89 /* ImportKeyword */:
+ case 108 /* LetKeyword */:
+ case 74 /* ConstKeyword */:
+ case 114 /* YieldKeyword */:
+ case 132 /* TypeKeyword */:
return true;
}
// Previous token may have been a keyword that was converted to an identifier.
switch (contextToken.getText()) {
+ case "abstract":
+ case "async":
case "class":
- case "interface":
+ case "const":
+ case "declare":
case "enum":
case "function":
- case "var":
- case "static":
+ case "interface":
case "let":
- case "const":
+ case "private":
+ case "protected":
+ case "public":
+ case "static":
+ case "var":
case "yield":
return true;
}
@@ -44576,8 +45492,8 @@ var ts;
if (element.getStart() <= position && position <= element.getEnd()) {
continue;
}
- var name_31 = element.propertyName || element.name;
- exisingImportsOrExports[name_31.text] = true;
+ var name_32 = element.propertyName || element.name;
+ exisingImportsOrExports[name_32.text] = true;
}
if (ts.isEmpty(exisingImportsOrExports)) {
return exportsOfModule;
@@ -44598,9 +45514,9 @@ var ts;
for (var _i = 0; _i < existingMembers.length; _i++) {
var m = existingMembers[_i];
// Ignore omitted expressions for missing members
- if (m.kind !== 243 /* PropertyAssignment */ &&
- m.kind !== 244 /* ShorthandPropertyAssignment */ &&
- m.kind !== 161 /* BindingElement */) {
+ if (m.kind !== 245 /* PropertyAssignment */ &&
+ m.kind !== 246 /* ShorthandPropertyAssignment */ &&
+ m.kind !== 163 /* BindingElement */) {
continue;
}
// If this is the current item we are editing right now, do not filter it out
@@ -44608,7 +45524,7 @@ var ts;
continue;
}
var existingName = void 0;
- if (m.kind === 161 /* BindingElement */ && m.propertyName) {
+ if (m.kind === 163 /* BindingElement */ && m.propertyName) {
existingName = m.propertyName.text;
}
else {
@@ -44635,7 +45551,7 @@ var ts;
if (attr.getStart() <= position && position <= attr.getEnd()) {
continue;
}
- if (attr.kind === 236 /* JsxAttribute */) {
+ if (attr.kind === 238 /* JsxAttribute */) {
seenNames[attr.name.text] = true;
}
}
@@ -44676,10 +45592,10 @@ var ts;
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
var sourceFile = _a[_i];
var nameTable = getNameTable(sourceFile);
- for (var name_32 in nameTable) {
- if (!allNames[name_32]) {
- allNames[name_32] = name_32;
- var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks:*/ true);
+ for (var name_33 in nameTable) {
+ if (!allNames[name_33]) {
+ allNames[name_33] = name_33;
+ var displayName = getCompletionEntryDisplayName(name_33, target, /*performCharacterChecks:*/ true);
if (displayName) {
var entry = {
name: displayName,
@@ -44787,7 +45703,7 @@ var ts;
function getSymbolKind(symbol, location) {
var flags = symbol.getFlags();
if (flags & 32 /* Class */)
- return ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */) ?
+ return ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */) ?
ScriptElementKind.localClassElement : ScriptElementKind.classElement;
if (flags & 384 /* Enum */)
return ScriptElementKind.enumElement;
@@ -44889,7 +45805,7 @@ var ts;
var signature;
type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (type) {
- if (location.parent && location.parent.kind === 164 /* PropertyAccessExpression */) {
+ if (location.parent && location.parent.kind === 166 /* PropertyAccessExpression */) {
var right = location.parent.name;
// Either the location is on the right of a property access, or on the left and the right is missing
if (right === location || (right && right.getFullWidth() === 0)) {
@@ -44898,7 +45814,7 @@ var ts;
}
// try get the call/construct signature from the type if it matches
var callExpression;
- if (location.kind === 166 /* CallExpression */ || location.kind === 167 /* NewExpression */) {
+ if (location.kind === 168 /* CallExpression */ || location.kind === 169 /* NewExpression */) {
callExpression = location;
}
else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) {
@@ -44911,10 +45827,11 @@ var ts;
// Use the first candidate:
signature = candidateSignatures[0];
}
- var useConstructSignatures = callExpression.kind === 167 /* NewExpression */ || callExpression.expression.kind === 93 /* SuperKeyword */;
+ var useConstructSignatures = callExpression.kind === 169 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */;
var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures();
- if (!ts.contains(allSignatures, signature.target || signature)) {
- // Get the first signature if there
+ if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) {
+ // Get the first signature if there is one -- allSignatures may contain
+ // either the original signature or its target, so check for either
signature = allSignatures.length ? allSignatures[0] : undefined;
}
if (signature) {
@@ -44928,7 +45845,7 @@ var ts;
pushTypePart(symbolKind);
displayParts.push(ts.spacePart());
if (useConstructSignatures) {
- displayParts.push(ts.keywordPart(90 /* NewKeyword */));
+ displayParts.push(ts.keywordPart(92 /* NewKeyword */));
displayParts.push(ts.spacePart());
}
addFullSymbolName(symbol);
@@ -44944,10 +45861,10 @@ var ts;
case ScriptElementKind.parameterElement:
case ScriptElementKind.localVariableElement:
// If it is call or construct signature of lambda's write type name
- displayParts.push(ts.punctuationPart(53 /* ColonToken */));
+ displayParts.push(ts.punctuationPart(54 /* ColonToken */));
displayParts.push(ts.spacePart());
if (useConstructSignatures) {
- displayParts.push(ts.keywordPart(90 /* NewKeyword */));
+ displayParts.push(ts.keywordPart(92 /* NewKeyword */));
displayParts.push(ts.spacePart());
}
if (!(type.flags & 65536 /* Anonymous */)) {
@@ -44963,24 +45880,24 @@ var ts;
}
}
else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) ||
- (location.kind === 119 /* ConstructorKeyword */ && location.parent.kind === 142 /* Constructor */)) {
+ (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 144 /* Constructor */)) {
// get the signature from the declaration and write it
var functionDeclaration = location.parent;
- var allSignatures = functionDeclaration.kind === 142 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures();
+ var allSignatures = functionDeclaration.kind === 144 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures();
if (!typeChecker.isImplementationOfOverload(functionDeclaration)) {
signature = typeChecker.getSignatureFromDeclaration(functionDeclaration);
}
else {
signature = allSignatures[0];
}
- if (functionDeclaration.kind === 142 /* Constructor */) {
+ if (functionDeclaration.kind === 144 /* Constructor */) {
// show (constructor) Type(...) signature
symbolKind = ScriptElementKind.constructorImplementationElement;
addPrefixForAnyFunctionOrVar(type.symbol, symbolKind);
}
else {
// (function/method) symbol(..signature)
- addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 /* CallSignature */ &&
+ addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 147 /* CallSignature */ &&
!(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind);
}
addSignatureDisplayParts(signature, allSignatures);
@@ -44989,7 +45906,7 @@ var ts;
}
}
if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) {
- if (ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */)) {
+ if (ts.getDeclarationOfKind(symbol, 186 /* ClassExpression */)) {
// Special case for class expressions because we would like to indicate that
// the class name is local to the class body (similar to function expression)
// (local class) class
@@ -44997,7 +45914,7 @@ var ts;
}
else {
// Class declaration has name which is not local.
- displayParts.push(ts.keywordPart(71 /* ClassKeyword */));
+ displayParts.push(ts.keywordPart(73 /* ClassKeyword */));
}
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
@@ -45005,37 +45922,37 @@ var ts;
}
if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) {
addNewLineIfDisplayPartsExist();
- displayParts.push(ts.keywordPart(105 /* InterfaceKeyword */));
+ displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
}
if (symbolFlags & 524288 /* TypeAlias */) {
addNewLineIfDisplayPartsExist();
- displayParts.push(ts.keywordPart(130 /* TypeKeyword */));
+ displayParts.push(ts.keywordPart(132 /* TypeKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
displayParts.push(ts.spacePart());
- displayParts.push(ts.operatorPart(55 /* EqualsToken */));
+ displayParts.push(ts.operatorPart(56 /* EqualsToken */));
displayParts.push(ts.spacePart());
ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
}
if (symbolFlags & 384 /* Enum */) {
addNewLineIfDisplayPartsExist();
if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) {
- displayParts.push(ts.keywordPart(72 /* ConstKeyword */));
+ displayParts.push(ts.keywordPart(74 /* ConstKeyword */));
displayParts.push(ts.spacePart());
}
- displayParts.push(ts.keywordPart(79 /* EnumKeyword */));
+ displayParts.push(ts.keywordPart(81 /* EnumKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
}
if (symbolFlags & 1536 /* Module */) {
addNewLineIfDisplayPartsExist();
- var declaration = ts.getDeclarationOfKind(symbol, 216 /* ModuleDeclaration */);
- var isNamespace = declaration && declaration.name && declaration.name.kind === 67 /* Identifier */;
- displayParts.push(ts.keywordPart(isNamespace ? 124 /* NamespaceKeyword */ : 123 /* ModuleKeyword */));
+ var declaration = ts.getDeclarationOfKind(symbol, 218 /* ModuleDeclaration */);
+ var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */;
+ displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
}
@@ -45047,7 +45964,7 @@ var ts;
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
displayParts.push(ts.spacePart());
- displayParts.push(ts.keywordPart(88 /* InKeyword */));
+ displayParts.push(ts.keywordPart(90 /* InKeyword */));
displayParts.push(ts.spacePart());
if (symbol.parent) {
// Class/Interface type parameter
@@ -45058,13 +45975,13 @@ var ts;
// Method/function type parameter
var container = ts.getContainingFunction(location);
if (container) {
- var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent;
+ var signatureDeclaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent;
var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
- if (signatureDeclaration.kind === 146 /* ConstructSignature */) {
- displayParts.push(ts.keywordPart(90 /* NewKeyword */));
+ if (signatureDeclaration.kind === 148 /* ConstructSignature */) {
+ displayParts.push(ts.keywordPart(92 /* NewKeyword */));
displayParts.push(ts.spacePart());
}
- else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) {
+ else if (signatureDeclaration.kind !== 147 /* CallSignature */ && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
@@ -45073,8 +45990,8 @@ var ts;
// Type aliash type parameter
// For example
// type list = T[]; // Both T will go through same code path
- var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent;
- displayParts.push(ts.keywordPart(130 /* TypeKeyword */));
+ var declaration = ts.getDeclarationOfKind(symbol, 137 /* TypeParameter */).parent;
+ displayParts.push(ts.keywordPart(132 /* TypeKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(declaration.symbol);
writeTypeParametersOfSymbol(declaration.symbol, sourceFile);
@@ -45084,11 +46001,11 @@ var ts;
if (symbolFlags & 8 /* EnumMember */) {
addPrefixForAnyFunctionOrVar(symbol, "enum member");
var declaration = symbol.declarations[0];
- if (declaration.kind === 245 /* EnumMember */) {
+ if (declaration.kind === 247 /* EnumMember */) {
var constantValue = typeChecker.getConstantValue(declaration);
if (constantValue !== undefined) {
displayParts.push(ts.spacePart());
- displayParts.push(ts.operatorPart(55 /* EqualsToken */));
+ displayParts.push(ts.operatorPart(56 /* EqualsToken */));
displayParts.push(ts.spacePart());
displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral));
}
@@ -45096,17 +46013,17 @@ var ts;
}
if (symbolFlags & 8388608 /* Alias */) {
addNewLineIfDisplayPartsExist();
- displayParts.push(ts.keywordPart(87 /* ImportKeyword */));
+ displayParts.push(ts.keywordPart(89 /* ImportKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
ts.forEach(symbol.declarations, function (declaration) {
- if (declaration.kind === 219 /* ImportEqualsDeclaration */) {
+ if (declaration.kind === 221 /* ImportEqualsDeclaration */) {
var importEqualsDeclaration = declaration;
if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) {
displayParts.push(ts.spacePart());
- displayParts.push(ts.operatorPart(55 /* EqualsToken */));
+ displayParts.push(ts.operatorPart(56 /* EqualsToken */));
displayParts.push(ts.spacePart());
- displayParts.push(ts.keywordPart(125 /* RequireKeyword */));
+ displayParts.push(ts.keywordPart(127 /* RequireKeyword */));
displayParts.push(ts.punctuationPart(17 /* OpenParenToken */));
displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral));
displayParts.push(ts.punctuationPart(18 /* CloseParenToken */));
@@ -45115,7 +46032,7 @@ var ts;
var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference);
if (internalAliasSymbol) {
displayParts.push(ts.spacePart());
- displayParts.push(ts.operatorPart(55 /* EqualsToken */));
+ displayParts.push(ts.operatorPart(56 /* EqualsToken */));
displayParts.push(ts.spacePart());
addFullSymbolName(internalAliasSymbol, enclosingDeclaration);
}
@@ -45132,7 +46049,7 @@ var ts;
if (symbolKind === ScriptElementKind.memberVariableElement ||
symbolFlags & 3 /* Variable */ ||
symbolKind === ScriptElementKind.localVariableElement) {
- displayParts.push(ts.punctuationPart(53 /* ColonToken */));
+ displayParts.push(ts.punctuationPart(54 /* ColonToken */));
displayParts.push(ts.spacePart());
// If the type is type parameter, format it specially
if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) {
@@ -45232,11 +46149,11 @@ var ts;
if (!symbol) {
// Try getting just type at this position and show
switch (node.kind) {
- case 67 /* Identifier */:
- case 164 /* PropertyAccessExpression */:
- case 133 /* QualifiedName */:
- case 95 /* ThisKeyword */:
- case 93 /* SuperKeyword */:
+ case 69 /* Identifier */:
+ case 166 /* PropertyAccessExpression */:
+ case 135 /* QualifiedName */:
+ case 97 /* ThisKeyword */:
+ case 95 /* SuperKeyword */:
// For the identifiers/this/super etc get the type at position
var type = typeChecker.getTypeAtLocation(node);
if (type) {
@@ -45289,7 +46206,7 @@ var ts;
function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) {
// Applicable only if we are in a new expression, or we are on a constructor declaration
// and in either case the symbol has a construct signature definition, i.e. class
- if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) {
+ if (isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) {
if (symbol.flags & 32 /* Class */) {
// Find the first class-like declaration and try to get the construct signature.
for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) {
@@ -45314,8 +46231,8 @@ var ts;
var declarations = [];
var definition;
ts.forEach(signatureDeclarations, function (d) {
- if ((selectConstructors && d.kind === 142 /* Constructor */) ||
- (!selectConstructors && (d.kind === 211 /* FunctionDeclaration */ || d.kind === 141 /* MethodDeclaration */ || d.kind === 140 /* MethodSignature */))) {
+ if ((selectConstructors && d.kind === 144 /* Constructor */) ||
+ (!selectConstructors && (d.kind === 213 /* FunctionDeclaration */ || d.kind === 143 /* MethodDeclaration */ || d.kind === 142 /* MethodSignature */))) {
declarations.push(d);
if (d.body)
definition = d;
@@ -45375,7 +46292,7 @@ var ts;
// to jump to the implementation directly.
if (symbol.flags & 8388608 /* Alias */) {
var declaration = symbol.declarations[0];
- if (node.kind === 67 /* Identifier */ && node.parent === declaration) {
+ if (node.kind === 69 /* Identifier */ && node.parent === declaration) {
symbol = typeChecker.getAliasedSymbol(symbol);
}
}
@@ -45384,7 +46301,7 @@ var ts;
// go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition
// is performed at the location of property access, we would like to go to definition of the property in the short-hand
// assignment. This case and others are handled by the following code.
- if (node.parent.kind === 244 /* ShorthandPropertyAssignment */) {
+ if (node.parent.kind === 246 /* ShorthandPropertyAssignment */) {
var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
if (!shorthandSymbol) {
return [];
@@ -45458,9 +46375,9 @@ var ts;
};
}
function getSemanticDocumentHighlights(node) {
- if (node.kind === 67 /* Identifier */ ||
- node.kind === 95 /* ThisKeyword */ ||
- node.kind === 93 /* SuperKeyword */ ||
+ if (node.kind === 69 /* Identifier */ ||
+ node.kind === 97 /* ThisKeyword */ ||
+ node.kind === 95 /* SuperKeyword */ ||
isLiteralNameOfPropertyDeclarationOrIndexAccess(node) ||
isNameOfExternalModuleImportOrDeclaration(node)) {
var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false);
@@ -45511,77 +46428,77 @@ var ts;
function getHighlightSpans(node) {
if (node) {
switch (node.kind) {
- case 86 /* IfKeyword */:
- case 78 /* ElseKeyword */:
- if (hasKind(node.parent, 194 /* IfStatement */)) {
+ case 88 /* IfKeyword */:
+ case 80 /* ElseKeyword */:
+ if (hasKind(node.parent, 196 /* IfStatement */)) {
return getIfElseOccurrences(node.parent);
}
break;
- case 92 /* ReturnKeyword */:
- if (hasKind(node.parent, 202 /* ReturnStatement */)) {
+ case 94 /* ReturnKeyword */:
+ if (hasKind(node.parent, 204 /* ReturnStatement */)) {
return getReturnOccurrences(node.parent);
}
break;
- case 96 /* ThrowKeyword */:
- if (hasKind(node.parent, 206 /* ThrowStatement */)) {
+ case 98 /* ThrowKeyword */:
+ if (hasKind(node.parent, 208 /* ThrowStatement */)) {
return getThrowOccurrences(node.parent);
}
break;
- case 70 /* CatchKeyword */:
- if (hasKind(parent(parent(node)), 207 /* TryStatement */)) {
+ case 72 /* CatchKeyword */:
+ if (hasKind(parent(parent(node)), 209 /* TryStatement */)) {
return getTryCatchFinallyOccurrences(node.parent.parent);
}
break;
- case 98 /* TryKeyword */:
- case 83 /* FinallyKeyword */:
- if (hasKind(parent(node), 207 /* TryStatement */)) {
+ case 100 /* TryKeyword */:
+ case 85 /* FinallyKeyword */:
+ if (hasKind(parent(node), 209 /* TryStatement */)) {
return getTryCatchFinallyOccurrences(node.parent);
}
break;
- case 94 /* SwitchKeyword */:
- if (hasKind(node.parent, 204 /* SwitchStatement */)) {
+ case 96 /* SwitchKeyword */:
+ if (hasKind(node.parent, 206 /* SwitchStatement */)) {
return getSwitchCaseDefaultOccurrences(node.parent);
}
break;
- case 69 /* CaseKeyword */:
- case 75 /* DefaultKeyword */:
- if (hasKind(parent(parent(parent(node))), 204 /* SwitchStatement */)) {
+ case 71 /* CaseKeyword */:
+ case 77 /* DefaultKeyword */:
+ if (hasKind(parent(parent(parent(node))), 206 /* SwitchStatement */)) {
return getSwitchCaseDefaultOccurrences(node.parent.parent.parent);
}
break;
- case 68 /* BreakKeyword */:
- case 73 /* ContinueKeyword */:
- if (hasKind(node.parent, 201 /* BreakStatement */) || hasKind(node.parent, 200 /* ContinueStatement */)) {
+ case 70 /* BreakKeyword */:
+ case 75 /* ContinueKeyword */:
+ if (hasKind(node.parent, 203 /* BreakStatement */) || hasKind(node.parent, 202 /* ContinueStatement */)) {
return getBreakOrContinueStatementOccurrences(node.parent);
}
break;
- case 84 /* ForKeyword */:
- if (hasKind(node.parent, 197 /* ForStatement */) ||
- hasKind(node.parent, 198 /* ForInStatement */) ||
- hasKind(node.parent, 199 /* ForOfStatement */)) {
+ case 86 /* ForKeyword */:
+ if (hasKind(node.parent, 199 /* ForStatement */) ||
+ hasKind(node.parent, 200 /* ForInStatement */) ||
+ hasKind(node.parent, 201 /* ForOfStatement */)) {
return getLoopBreakContinueOccurrences(node.parent);
}
break;
- case 102 /* WhileKeyword */:
- case 77 /* DoKeyword */:
- if (hasKind(node.parent, 196 /* WhileStatement */) || hasKind(node.parent, 195 /* DoStatement */)) {
+ case 104 /* WhileKeyword */:
+ case 79 /* DoKeyword */:
+ if (hasKind(node.parent, 198 /* WhileStatement */) || hasKind(node.parent, 197 /* DoStatement */)) {
return getLoopBreakContinueOccurrences(node.parent);
}
break;
- case 119 /* ConstructorKeyword */:
- if (hasKind(node.parent, 142 /* Constructor */)) {
+ case 121 /* ConstructorKeyword */:
+ if (hasKind(node.parent, 144 /* Constructor */)) {
return getConstructorOccurrences(node.parent);
}
break;
- case 121 /* GetKeyword */:
- case 127 /* SetKeyword */:
- if (hasKind(node.parent, 143 /* GetAccessor */) || hasKind(node.parent, 144 /* SetAccessor */)) {
+ case 123 /* GetKeyword */:
+ case 129 /* SetKeyword */:
+ if (hasKind(node.parent, 145 /* GetAccessor */) || hasKind(node.parent, 146 /* SetAccessor */)) {
return getGetAndSetOccurrences(node.parent);
}
break;
default:
if (ts.isModifier(node.kind) && node.parent &&
- (ts.isDeclaration(node.parent) || node.parent.kind === 191 /* VariableStatement */)) {
+ (ts.isDeclaration(node.parent) || node.parent.kind === 193 /* VariableStatement */)) {
return getModifierOccurrences(node.kind, node.parent);
}
}
@@ -45597,10 +46514,10 @@ var ts;
aggregate(node);
return statementAccumulator;
function aggregate(node) {
- if (node.kind === 206 /* ThrowStatement */) {
+ if (node.kind === 208 /* ThrowStatement */) {
statementAccumulator.push(node);
}
- else if (node.kind === 207 /* TryStatement */) {
+ else if (node.kind === 209 /* TryStatement */) {
var tryStatement = node;
if (tryStatement.catchClause) {
aggregate(tryStatement.catchClause);
@@ -45629,12 +46546,12 @@ var ts;
var child = throwStatement;
while (child.parent) {
var parent_12 = child.parent;
- if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246 /* SourceFile */) {
+ if (ts.isFunctionBlock(parent_12) || parent_12.kind === 248 /* SourceFile */) {
return parent_12;
}
// A throw-statement is only owned by a try-statement if the try-statement has
// a catch clause, and if the throw-statement occurs within the try block.
- if (parent_12.kind === 207 /* TryStatement */) {
+ if (parent_12.kind === 209 /* TryStatement */) {
var tryStatement = parent_12;
if (tryStatement.tryBlock === child && tryStatement.catchClause) {
return child;
@@ -45649,7 +46566,7 @@ var ts;
aggregate(node);
return statementAccumulator;
function aggregate(node) {
- if (node.kind === 201 /* BreakStatement */ || node.kind === 200 /* ContinueStatement */) {
+ if (node.kind === 203 /* BreakStatement */ || node.kind === 202 /* ContinueStatement */) {
statementAccumulator.push(node);
}
else if (!ts.isFunctionLike(node)) {
@@ -45665,16 +46582,16 @@ var ts;
function getBreakOrContinueOwner(statement) {
for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) {
switch (node_2.kind) {
- case 204 /* SwitchStatement */:
- if (statement.kind === 200 /* ContinueStatement */) {
+ case 206 /* SwitchStatement */:
+ if (statement.kind === 202 /* ContinueStatement */) {
continue;
}
// Fall through.
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 196 /* WhileStatement */:
- case 195 /* DoStatement */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 198 /* WhileStatement */:
+ case 197 /* DoStatement */:
if (!statement.label || isLabeledBy(node_2, statement.label.text)) {
return node_2;
}
@@ -45693,24 +46610,24 @@ var ts;
var container = declaration.parent;
// Make sure we only highlight the keyword when it makes sense to do so.
if (ts.isAccessibilityModifier(modifier)) {
- if (!(container.kind === 212 /* ClassDeclaration */ ||
- container.kind === 184 /* ClassExpression */ ||
- (declaration.kind === 136 /* Parameter */ && hasKind(container, 142 /* Constructor */)))) {
+ if (!(container.kind === 214 /* ClassDeclaration */ ||
+ container.kind === 186 /* ClassExpression */ ||
+ (declaration.kind === 138 /* Parameter */ && hasKind(container, 144 /* Constructor */)))) {
return undefined;
}
}
- else if (modifier === 111 /* StaticKeyword */) {
- if (!(container.kind === 212 /* ClassDeclaration */ || container.kind === 184 /* ClassExpression */)) {
+ else if (modifier === 113 /* StaticKeyword */) {
+ if (!(container.kind === 214 /* ClassDeclaration */ || container.kind === 186 /* ClassExpression */)) {
return undefined;
}
}
- else if (modifier === 80 /* ExportKeyword */ || modifier === 120 /* DeclareKeyword */) {
- if (!(container.kind === 217 /* ModuleBlock */ || container.kind === 246 /* SourceFile */)) {
+ else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) {
+ if (!(container.kind === 219 /* ModuleBlock */ || container.kind === 248 /* SourceFile */)) {
return undefined;
}
}
- else if (modifier === 113 /* AbstractKeyword */) {
- if (!(container.kind === 212 /* ClassDeclaration */ || declaration.kind === 212 /* ClassDeclaration */)) {
+ else if (modifier === 115 /* AbstractKeyword */) {
+ if (!(container.kind === 214 /* ClassDeclaration */ || declaration.kind === 214 /* ClassDeclaration */)) {
return undefined;
}
}
@@ -45722,8 +46639,8 @@ var ts;
var modifierFlag = getFlagFromModifier(modifier);
var nodes;
switch (container.kind) {
- case 217 /* ModuleBlock */:
- case 246 /* SourceFile */:
+ case 219 /* ModuleBlock */:
+ case 248 /* SourceFile */:
// Container is either a class declaration or the declaration is a classDeclaration
if (modifierFlag & 256 /* Abstract */) {
nodes = declaration.members.concat(declaration);
@@ -45732,17 +46649,17 @@ var ts;
nodes = container.statements;
}
break;
- case 142 /* Constructor */:
+ case 144 /* Constructor */:
nodes = container.parameters.concat(container.parent.members);
break;
- case 212 /* ClassDeclaration */:
- case 184 /* ClassExpression */:
+ case 214 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
nodes = container.members;
// If we're an accessibility modifier, we're in an instance member and should search
// the constructor's parameter list for instance members as well.
if (modifierFlag & 112 /* AccessibilityModifier */) {
var constructor = ts.forEach(container.members, function (member) {
- return member.kind === 142 /* Constructor */ && member;
+ return member.kind === 144 /* Constructor */ && member;
});
if (constructor) {
nodes = nodes.concat(constructor.parameters);
@@ -45763,19 +46680,19 @@ var ts;
return ts.map(keywords, getHighlightSpanForNode);
function getFlagFromModifier(modifier) {
switch (modifier) {
- case 110 /* PublicKeyword */:
+ case 112 /* PublicKeyword */:
return 16 /* Public */;
- case 108 /* PrivateKeyword */:
+ case 110 /* PrivateKeyword */:
return 32 /* Private */;
- case 109 /* ProtectedKeyword */:
+ case 111 /* ProtectedKeyword */:
return 64 /* Protected */;
- case 111 /* StaticKeyword */:
+ case 113 /* StaticKeyword */:
return 128 /* Static */;
- case 80 /* ExportKeyword */:
+ case 82 /* ExportKeyword */:
return 1 /* Export */;
- case 120 /* DeclareKeyword */:
+ case 122 /* DeclareKeyword */:
return 2 /* Ambient */;
- case 113 /* AbstractKeyword */:
+ case 115 /* AbstractKeyword */:
return 256 /* Abstract */;
default:
ts.Debug.fail();
@@ -45795,13 +46712,13 @@ var ts;
}
function getGetAndSetOccurrences(accessorDeclaration) {
var keywords = [];
- tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* GetAccessor */);
- tryPushAccessorKeyword(accessorDeclaration.symbol, 144 /* SetAccessor */);
+ tryPushAccessorKeyword(accessorDeclaration.symbol, 145 /* GetAccessor */);
+ tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* SetAccessor */);
return ts.map(keywords, getHighlightSpanForNode);
function tryPushAccessorKeyword(accessorSymbol, accessorKind) {
var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind);
if (accessor) {
- ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121 /* GetKeyword */, 127 /* SetKeyword */); });
+ ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 129 /* SetKeyword */); });
}
}
}
@@ -45810,19 +46727,19 @@ var ts;
var keywords = [];
ts.forEach(declarations, function (declaration) {
ts.forEach(declaration.getChildren(), function (token) {
- return pushKeywordIf(keywords, token, 119 /* ConstructorKeyword */);
+ return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */);
});
});
return ts.map(keywords, getHighlightSpanForNode);
}
function getLoopBreakContinueOccurrences(loopNode) {
var keywords = [];
- if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84 /* ForKeyword */, 102 /* WhileKeyword */, 77 /* DoKeyword */)) {
+ if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) {
// If we succeeded and got a do-while loop, then start looking for a 'while' keyword.
- if (loopNode.kind === 195 /* DoStatement */) {
+ if (loopNode.kind === 197 /* DoStatement */) {
var loopTokens = loopNode.getChildren();
for (var i = loopTokens.length - 1; i >= 0; i--) {
- if (pushKeywordIf(keywords, loopTokens[i], 102 /* WhileKeyword */)) {
+ if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) {
break;
}
}
@@ -45831,7 +46748,7 @@ var ts;
var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement);
ts.forEach(breaksAndContinues, function (statement) {
if (ownsBreakOrContinueStatement(loopNode, statement)) {
- pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */, 73 /* ContinueKeyword */);
+ pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */);
}
});
return ts.map(keywords, getHighlightSpanForNode);
@@ -45840,13 +46757,13 @@ var ts;
var owner = getBreakOrContinueOwner(breakOrContinueStatement);
if (owner) {
switch (owner.kind) {
- case 197 /* ForStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
- case 195 /* DoStatement */:
- case 196 /* WhileStatement */:
+ case 199 /* ForStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
+ case 197 /* DoStatement */:
+ case 198 /* WhileStatement */:
return getLoopBreakContinueOccurrences(owner);
- case 204 /* SwitchStatement */:
+ case 206 /* SwitchStatement */:
return getSwitchCaseDefaultOccurrences(owner);
}
}
@@ -45854,14 +46771,14 @@ var ts;
}
function getSwitchCaseDefaultOccurrences(switchStatement) {
var keywords = [];
- pushKeywordIf(keywords, switchStatement.getFirstToken(), 94 /* SwitchKeyword */);
+ pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */);
// Go through each clause in the switch statement, collecting the 'case'/'default' keywords.
ts.forEach(switchStatement.caseBlock.clauses, function (clause) {
- pushKeywordIf(keywords, clause.getFirstToken(), 69 /* CaseKeyword */, 75 /* DefaultKeyword */);
+ pushKeywordIf(keywords, clause.getFirstToken(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */);
var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause);
ts.forEach(breaksAndContinues, function (statement) {
if (ownsBreakOrContinueStatement(switchStatement, statement)) {
- pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */);
+ pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */);
}
});
});
@@ -45869,13 +46786,13 @@ var ts;
}
function getTryCatchFinallyOccurrences(tryStatement) {
var keywords = [];
- pushKeywordIf(keywords, tryStatement.getFirstToken(), 98 /* TryKeyword */);
+ pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */);
if (tryStatement.catchClause) {
- pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70 /* CatchKeyword */);
+ pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */);
}
if (tryStatement.finallyBlock) {
- var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile);
- pushKeywordIf(keywords, finallyKeyword, 83 /* FinallyKeyword */);
+ var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile);
+ pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */);
}
return ts.map(keywords, getHighlightSpanForNode);
}
@@ -45886,13 +46803,13 @@ var ts;
}
var keywords = [];
ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) {
- pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */);
+ pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */);
});
// If the "owner" is a function, then we equate 'return' and 'throw' statements in their
// ability to "jump out" of the function, and include occurrences for both.
if (ts.isFunctionBlock(owner)) {
ts.forEachReturnStatement(owner, function (returnStatement) {
- pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */);
+ pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */);
});
}
return ts.map(keywords, getHighlightSpanForNode);
@@ -45900,36 +46817,36 @@ var ts;
function getReturnOccurrences(returnStatement) {
var func = ts.getContainingFunction(returnStatement);
// If we didn't find a containing function with a block body, bail out.
- if (!(func && hasKind(func.body, 190 /* Block */))) {
+ if (!(func && hasKind(func.body, 192 /* Block */))) {
return undefined;
}
var keywords = [];
ts.forEachReturnStatement(func.body, function (returnStatement) {
- pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */);
+ pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */);
});
// Include 'throw' statements that do not occur within a try block.
ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) {
- pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */);
+ pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */);
});
return ts.map(keywords, getHighlightSpanForNode);
}
function getIfElseOccurrences(ifStatement) {
var keywords = [];
// Traverse upwards through all parent if-statements linked by their else-branches.
- while (hasKind(ifStatement.parent, 194 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) {
+ while (hasKind(ifStatement.parent, 196 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) {
ifStatement = ifStatement.parent;
}
// Now traverse back down through the else branches, aggregating if/else keywords of if-statements.
while (ifStatement) {
var children = ifStatement.getChildren();
- pushKeywordIf(keywords, children[0], 86 /* IfKeyword */);
+ pushKeywordIf(keywords, children[0], 88 /* IfKeyword */);
// Generally the 'else' keyword is second-to-last, so we traverse backwards.
for (var i = children.length - 1; i >= 0; i--) {
- if (pushKeywordIf(keywords, children[i], 78 /* ElseKeyword */)) {
+ if (pushKeywordIf(keywords, children[i], 80 /* ElseKeyword */)) {
break;
}
}
- if (!hasKind(ifStatement.elseStatement, 194 /* IfStatement */)) {
+ if (!hasKind(ifStatement.elseStatement, 196 /* IfStatement */)) {
break;
}
ifStatement = ifStatement.elseStatement;
@@ -45938,7 +46855,7 @@ var ts;
// We'd like to highlight else/ifs together if they are only separated by whitespace
// (i.e. the keywords are separated by no comments, no newlines).
for (var i = 0; i < keywords.length; i++) {
- if (keywords[i].kind === 78 /* ElseKeyword */ && i < keywords.length - 1) {
+ if (keywords[i].kind === 80 /* ElseKeyword */ && i < keywords.length - 1) {
var elseKeyword = keywords[i];
var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword.
var shouldCombindElseAndIf = true;
@@ -46020,7 +46937,7 @@ var ts;
if (!node) {
return undefined;
}
- if (node.kind !== 67 /* Identifier */ &&
+ if (node.kind !== 69 /* Identifier */ &&
// TODO (drosen): This should be enabled in a later release - currently breaks rename.
//node.kind !== SyntaxKind.ThisKeyword &&
//node.kind !== SyntaxKind.SuperKeyword &&
@@ -46028,7 +46945,7 @@ var ts;
!isNameOfExternalModuleImportOrDeclaration(node)) {
return undefined;
}
- ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */);
+ ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */);
return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments);
}
function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) {
@@ -46046,10 +46963,10 @@ var ts;
return getLabelReferencesInNode(node.parent, node);
}
}
- if (node.kind === 95 /* ThisKeyword */) {
+ if (node.kind === 97 /* ThisKeyword */) {
return getReferencesForThisKeyword(node, sourceFiles);
}
- if (node.kind === 93 /* SuperKeyword */) {
+ if (node.kind === 95 /* SuperKeyword */) {
return getReferencesForSuperKeyword(node);
}
var symbol = typeChecker.getSymbolAtLocation(node);
@@ -46109,7 +47026,7 @@ var ts;
}
function isImportOrExportSpecifierImportSymbol(symbol) {
return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) {
- return declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 228 /* ExportSpecifier */;
+ return declaration.kind === 226 /* ImportSpecifier */ || declaration.kind === 230 /* ExportSpecifier */;
});
}
function getInternedName(symbol, location, declarations) {
@@ -46136,14 +47053,14 @@ var ts;
// If this is the symbol of a named function expression or named class expression,
// then named references are limited to its own scope.
var valueDeclaration = symbol.valueDeclaration;
- if (valueDeclaration && (valueDeclaration.kind === 171 /* FunctionExpression */ || valueDeclaration.kind === 184 /* ClassExpression */)) {
+ if (valueDeclaration && (valueDeclaration.kind === 173 /* FunctionExpression */ || valueDeclaration.kind === 186 /* ClassExpression */)) {
return valueDeclaration;
}
// If this is private property or method, the scope is the containing class
if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) {
var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; });
if (privateDeclaration) {
- return ts.getAncestor(privateDeclaration, 212 /* ClassDeclaration */);
+ return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */);
}
}
// If the symbol is an import we would like to find it if we are looking for what it imports.
@@ -46169,7 +47086,7 @@ var ts;
// Different declarations have different containers, bail out
return undefined;
}
- if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) {
+ if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) {
// This is a global variable and not an external module, any declaration defined
// within this scope is visible outside the file
return undefined;
@@ -46240,7 +47157,7 @@ var ts;
if (node) {
// Compare the length so we filter out strict superstrings of the symbol we are looking for
switch (node.kind) {
- case 67 /* Identifier */:
+ case 69 /* Identifier */:
return node.getWidth() === searchSymbolName.length;
case 9 /* StringLiteral */:
if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) ||
@@ -46342,13 +47259,13 @@ var ts;
// Whether 'super' occurs in a static context within a class.
var staticFlag = 128 /* Static */;
switch (searchSpaceNode.kind) {
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
staticFlag &= searchSpaceNode.flags;
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
break;
@@ -46361,7 +47278,7 @@ var ts;
ts.forEach(possiblePositions, function (position) {
cancellationToken.throwIfCancellationRequested();
var node = ts.getTouchingWord(sourceFile, position);
- if (!node || node.kind !== 93 /* SuperKeyword */) {
+ if (!node || node.kind !== 95 /* SuperKeyword */) {
return;
}
var container = ts.getSuperContainer(node, /*includeFunctions*/ false);
@@ -46380,27 +47297,27 @@ var ts;
// Whether 'this' occurs in a static context within a class.
var staticFlag = 128 /* Static */;
switch (searchSpaceNode.kind) {
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
if (ts.isObjectLiteralMethod(searchSpaceNode)) {
break;
}
// fall through
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
staticFlag &= searchSpaceNode.flags;
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
break;
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
if (ts.isExternalModule(searchSpaceNode)) {
return undefined;
}
// Fall through
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
break;
// Computed properties in classes are not handled here because references to this are illegal,
// so there is no point finding references to them.
@@ -46409,7 +47326,7 @@ var ts;
}
var references = [];
var possiblePositions;
- if (searchSpaceNode.kind === 246 /* SourceFile */) {
+ if (searchSpaceNode.kind === 248 /* SourceFile */) {
ts.forEach(sourceFiles, function (sourceFile) {
possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd());
getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references);
@@ -46435,32 +47352,33 @@ var ts;
ts.forEach(possiblePositions, function (position) {
cancellationToken.throwIfCancellationRequested();
var node = ts.getTouchingWord(sourceFile, position);
- if (!node || node.kind !== 95 /* ThisKeyword */) {
+ if (!node || node.kind !== 97 /* ThisKeyword */) {
return;
}
var container = ts.getThisContainer(node, /* includeArrowFunctions */ false);
switch (searchSpaceNode.kind) {
- case 171 /* FunctionExpression */:
- case 211 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 213 /* FunctionDeclaration */:
if (searchSpaceNode.symbol === container.symbol) {
result.push(getReferenceEntryFromNode(node));
}
break;
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) {
result.push(getReferenceEntryFromNode(node));
}
break;
- case 212 /* ClassDeclaration */:
+ case 186 /* ClassExpression */:
+ case 214 /* ClassDeclaration */:
// Make sure the container belongs to the same class
// and has the appropriate static modifier from the original container.
if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) {
result.push(getReferenceEntryFromNode(node));
}
break;
- case 246 /* SourceFile */:
- if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) {
+ case 248 /* SourceFile */:
+ if (container.kind === 248 /* SourceFile */ && !ts.isExternalModule(container)) {
result.push(getReferenceEntryFromNode(node));
}
break;
@@ -46514,11 +47432,11 @@ var ts;
function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) {
if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) {
ts.forEach(symbol.getDeclarations(), function (declaration) {
- if (declaration.kind === 212 /* ClassDeclaration */) {
+ if (declaration.kind === 214 /* ClassDeclaration */) {
getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration));
ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference);
}
- else if (declaration.kind === 213 /* InterfaceDeclaration */) {
+ else if (declaration.kind === 215 /* InterfaceDeclaration */) {
ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference);
}
});
@@ -46579,19 +47497,19 @@ var ts;
if (isNameOfPropertyAssignment(node)) {
var objectLiteral = node.parent.parent;
var contextualType = typeChecker.getContextualType(objectLiteral);
- var name_33 = node.text;
+ var name_34 = node.text;
if (contextualType) {
if (contextualType.flags & 16384 /* Union */) {
// This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types)
// if not, search the constituent types for the property
- var unionProperty = contextualType.getProperty(name_33);
+ var unionProperty = contextualType.getProperty(name_34);
if (unionProperty) {
return [unionProperty];
}
else {
var result_4 = [];
ts.forEach(contextualType.types, function (t) {
- var symbol = t.getProperty(name_33);
+ var symbol = t.getProperty(name_34);
if (symbol) {
result_4.push(symbol);
}
@@ -46600,7 +47518,7 @@ var ts;
}
}
else {
- var symbol_1 = contextualType.getProperty(name_33);
+ var symbol_1 = contextualType.getProperty(name_34);
if (symbol_1) {
return [symbol_1];
}
@@ -46653,17 +47571,17 @@ var ts;
}
/** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */
function isWriteAccess(node) {
- if (node.kind === 67 /* Identifier */ && ts.isDeclarationName(node)) {
+ if (node.kind === 69 /* Identifier */ && ts.isDeclarationName(node)) {
return true;
}
var parent = node.parent;
if (parent) {
- if (parent.kind === 178 /* PostfixUnaryExpression */ || parent.kind === 177 /* PrefixUnaryExpression */) {
+ if (parent.kind === 180 /* PostfixUnaryExpression */ || parent.kind === 179 /* PrefixUnaryExpression */) {
return true;
}
- else if (parent.kind === 179 /* BinaryExpression */ && parent.left === node) {
+ else if (parent.kind === 181 /* BinaryExpression */ && parent.left === node) {
var operator = parent.operatorToken.kind;
- return 55 /* FirstAssignment */ <= operator && operator <= 66 /* LastAssignment */;
+ return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */;
}
}
return false;
@@ -46695,33 +47613,33 @@ var ts;
}
function getMeaningFromDeclaration(node) {
switch (node.kind) {
- case 136 /* Parameter */:
- case 209 /* VariableDeclaration */:
- case 161 /* BindingElement */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
- case 243 /* PropertyAssignment */:
- case 244 /* ShorthandPropertyAssignment */:
- case 245 /* EnumMember */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 142 /* Constructor */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 211 /* FunctionDeclaration */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
- case 242 /* CatchClause */:
+ case 138 /* Parameter */:
+ case 211 /* VariableDeclaration */:
+ case 163 /* BindingElement */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
+ case 245 /* PropertyAssignment */:
+ case 246 /* ShorthandPropertyAssignment */:
+ case 247 /* EnumMember */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 144 /* Constructor */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 213 /* FunctionDeclaration */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
+ case 244 /* CatchClause */:
return 1 /* Value */;
- case 135 /* TypeParameter */:
- case 213 /* InterfaceDeclaration */:
- case 214 /* TypeAliasDeclaration */:
- case 153 /* TypeLiteral */:
+ case 137 /* TypeParameter */:
+ case 215 /* InterfaceDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
+ case 155 /* TypeLiteral */:
return 2 /* Type */;
- case 212 /* ClassDeclaration */:
- case 215 /* EnumDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 217 /* EnumDeclaration */:
return 1 /* Value */ | 2 /* Type */;
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
if (node.name.kind === 9 /* StringLiteral */) {
return 4 /* Namespace */ | 1 /* Value */;
}
@@ -46731,15 +47649,15 @@ var ts;
else {
return 4 /* Namespace */;
}
- case 223 /* NamedImports */:
- case 224 /* ImportSpecifier */:
- case 219 /* ImportEqualsDeclaration */:
- case 220 /* ImportDeclaration */:
- case 225 /* ExportAssignment */:
- case 226 /* ExportDeclaration */:
+ case 225 /* NamedImports */:
+ case 226 /* ImportSpecifier */:
+ case 221 /* ImportEqualsDeclaration */:
+ case 222 /* ImportDeclaration */:
+ case 227 /* ExportAssignment */:
+ case 228 /* ExportDeclaration */:
return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
// An external module can be a Value
- case 246 /* SourceFile */:
+ case 248 /* SourceFile */:
return 4 /* Namespace */ | 1 /* Value */;
}
return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
@@ -46749,8 +47667,9 @@ var ts;
if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) {
node = node.parent;
}
- return node.parent.kind === 149 /* TypeReference */ ||
- (node.parent.kind === 186 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent));
+ return node.parent.kind === 151 /* TypeReference */ ||
+ (node.parent.kind === 188 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) ||
+ node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node);
}
function isNamespaceReference(node) {
return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node);
@@ -46758,50 +47677,50 @@ var ts;
function isPropertyAccessNamespaceReference(node) {
var root = node;
var isLastClause = true;
- if (root.parent.kind === 164 /* PropertyAccessExpression */) {
- while (root.parent && root.parent.kind === 164 /* PropertyAccessExpression */) {
+ if (root.parent.kind === 166 /* PropertyAccessExpression */) {
+ while (root.parent && root.parent.kind === 166 /* PropertyAccessExpression */) {
root = root.parent;
}
isLastClause = root.name === node;
}
- if (!isLastClause && root.parent.kind === 186 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 241 /* HeritageClause */) {
+ if (!isLastClause && root.parent.kind === 188 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 243 /* HeritageClause */) {
var decl = root.parent.parent.parent;
- return (decl.kind === 212 /* ClassDeclaration */ && root.parent.parent.token === 104 /* ImplementsKeyword */) ||
- (decl.kind === 213 /* InterfaceDeclaration */ && root.parent.parent.token === 81 /* ExtendsKeyword */);
+ return (decl.kind === 214 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) ||
+ (decl.kind === 215 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */);
}
return false;
}
function isQualifiedNameNamespaceReference(node) {
var root = node;
var isLastClause = true;
- if (root.parent.kind === 133 /* QualifiedName */) {
- while (root.parent && root.parent.kind === 133 /* QualifiedName */) {
+ if (root.parent.kind === 135 /* QualifiedName */) {
+ while (root.parent && root.parent.kind === 135 /* QualifiedName */) {
root = root.parent;
}
isLastClause = root.right === node;
}
- return root.parent.kind === 149 /* TypeReference */ && !isLastClause;
+ return root.parent.kind === 151 /* TypeReference */ && !isLastClause;
}
function isInRightSideOfImport(node) {
- while (node.parent.kind === 133 /* QualifiedName */) {
+ while (node.parent.kind === 135 /* QualifiedName */) {
node = node.parent;
}
return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node;
}
function getMeaningFromRightHandSideOfImportEquals(node) {
- ts.Debug.assert(node.kind === 67 /* Identifier */);
+ ts.Debug.assert(node.kind === 69 /* Identifier */);
// import a = |b|; // Namespace
// import a = |b.c|; // Value, type, namespace
// import a = |b.c|.d; // Namespace
- if (node.parent.kind === 133 /* QualifiedName */ &&
+ if (node.parent.kind === 135 /* QualifiedName */ &&
node.parent.right === node &&
- node.parent.parent.kind === 219 /* ImportEqualsDeclaration */) {
+ node.parent.parent.kind === 221 /* ImportEqualsDeclaration */) {
return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
}
return 4 /* Namespace */;
}
function getMeaningFromLocation(node) {
- if (node.parent.kind === 225 /* ExportAssignment */) {
+ if (node.parent.kind === 227 /* ExportAssignment */) {
return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
}
else if (isInRightSideOfImport(node)) {
@@ -46841,15 +47760,15 @@ var ts;
return;
}
switch (node.kind) {
- case 164 /* PropertyAccessExpression */:
- case 133 /* QualifiedName */:
+ case 166 /* PropertyAccessExpression */:
+ case 135 /* QualifiedName */:
case 9 /* StringLiteral */:
- case 82 /* FalseKeyword */:
- case 97 /* TrueKeyword */:
- case 91 /* NullKeyword */:
- case 93 /* SuperKeyword */:
- case 95 /* ThisKeyword */:
- case 67 /* Identifier */:
+ case 84 /* FalseKeyword */:
+ case 99 /* TrueKeyword */:
+ case 93 /* NullKeyword */:
+ case 95 /* SuperKeyword */:
+ case 97 /* ThisKeyword */:
+ case 69 /* Identifier */:
break;
// Cant create the text span
default:
@@ -46865,7 +47784,7 @@ var ts;
// If this is name of a module declarations, check if this is right side of dotted module name
// If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of
// Then this name is name from dotted module
- if (nodeForStartPos.parent.parent.kind === 216 /* ModuleDeclaration */ &&
+ if (nodeForStartPos.parent.parent.kind === 218 /* ModuleDeclaration */ &&
nodeForStartPos.parent.parent.body === nodeForStartPos.parent) {
// Use parent module declarations name for start pos
nodeForStartPos = nodeForStartPos.parent.parent.name;
@@ -46906,10 +47825,10 @@ var ts;
// That means we're calling back into the host around every 1.2k of the file we process.
// Lib.d.ts has similar numbers.
switch (kind) {
- case 216 /* ModuleDeclaration */:
- case 212 /* ClassDeclaration */:
- case 213 /* InterfaceDeclaration */:
- case 211 /* FunctionDeclaration */:
+ case 218 /* ModuleDeclaration */:
+ case 214 /* ClassDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 213 /* FunctionDeclaration */:
cancellationToken.throwIfCancellationRequested();
}
}
@@ -46963,7 +47882,7 @@ var ts;
*/
function hasValueSideModule(symbol) {
return ts.forEach(symbol.declarations, function (declaration) {
- return declaration.kind === 216 /* ModuleDeclaration */ &&
+ return declaration.kind === 218 /* ModuleDeclaration */ &&
ts.getModuleInstanceState(declaration) === 1 /* Instantiated */;
});
}
@@ -46973,7 +47892,7 @@ var ts;
if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) {
var kind = node.kind;
checkForClassificationCancellation(kind);
- if (kind === 67 /* Identifier */ && !ts.nodeIsMissing(node)) {
+ if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) {
var identifier = node;
// Only bother calling into the typechecker if this is an identifier that
// could possibly resolve to a type name. This makes classification run
@@ -47118,16 +48037,16 @@ var ts;
pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */);
pos = tag.tagName.end;
switch (tag.kind) {
- case 265 /* JSDocParameterTag */:
+ case 267 /* JSDocParameterTag */:
processJSDocParameterTag(tag);
break;
- case 268 /* JSDocTemplateTag */:
+ case 270 /* JSDocTemplateTag */:
processJSDocTemplateTag(tag);
break;
- case 267 /* JSDocTypeTag */:
+ case 269 /* JSDocTypeTag */:
processElement(tag.typeExpression);
break;
- case 266 /* JSDocReturnTag */:
+ case 268 /* JSDocReturnTag */:
processElement(tag.typeExpression);
break;
}
@@ -47216,18 +48135,18 @@ var ts;
}
if (ts.isPunctuation(tokenKind)) {
if (token) {
- if (tokenKind === 55 /* EqualsToken */) {
+ if (tokenKind === 56 /* EqualsToken */) {
// the '=' in a variable declaration is special cased here.
- if (token.parent.kind === 209 /* VariableDeclaration */ ||
- token.parent.kind === 139 /* PropertyDeclaration */ ||
- token.parent.kind === 136 /* Parameter */) {
+ if (token.parent.kind === 211 /* VariableDeclaration */ ||
+ token.parent.kind === 141 /* PropertyDeclaration */ ||
+ token.parent.kind === 138 /* Parameter */) {
return 5 /* operator */;
}
}
- if (token.parent.kind === 179 /* BinaryExpression */ ||
- token.parent.kind === 177 /* PrefixUnaryExpression */ ||
- token.parent.kind === 178 /* PostfixUnaryExpression */ ||
- token.parent.kind === 180 /* ConditionalExpression */) {
+ if (token.parent.kind === 181 /* BinaryExpression */ ||
+ token.parent.kind === 179 /* PrefixUnaryExpression */ ||
+ token.parent.kind === 180 /* PostfixUnaryExpression */ ||
+ token.parent.kind === 182 /* ConditionalExpression */) {
return 5 /* operator */;
}
}
@@ -47247,35 +48166,35 @@ var ts;
// TODO (drosen): we should *also* get another classification type for these literals.
return 6 /* stringLiteral */;
}
- else if (tokenKind === 67 /* Identifier */) {
+ else if (tokenKind === 69 /* Identifier */) {
if (token) {
switch (token.parent.kind) {
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
if (token.parent.name === token) {
return 11 /* className */;
}
return;
- case 135 /* TypeParameter */:
+ case 137 /* TypeParameter */:
if (token.parent.name === token) {
return 15 /* typeParameterName */;
}
return;
- case 213 /* InterfaceDeclaration */:
+ case 215 /* InterfaceDeclaration */:
if (token.parent.name === token) {
return 13 /* interfaceName */;
}
return;
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
if (token.parent.name === token) {
return 12 /* enumName */;
}
return;
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
if (token.parent.name === token) {
return 14 /* moduleName */;
}
return;
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
if (token.parent.name === token) {
return 17 /* parameterName */;
}
@@ -47387,8 +48306,12 @@ var ts;
* Checks if position points to a valid position to add JSDoc comments, and if so,
* returns the appropriate template. Otherwise returns an empty string.
* Valid positions are
- * - outside of comments, statements, and expressions, and
- * - preceding a function declaration.
+ * - outside of comments, statements, and expressions, and
+ * - preceding a:
+ * - function/constructor/method declaration
+ * - class declarations
+ * - variable statements
+ * - namespace declarations
*
* Hosts should ideally check that:
* - The line is all whitespace up to 'position' before performing the insertion.
@@ -47412,23 +48335,48 @@ var ts;
return undefined;
}
// TODO: add support for:
- // - methods
- // - constructors
- // - class decls
- var containingFunction = ts.getAncestor(tokenAtPos, 211 /* FunctionDeclaration */);
- if (!containingFunction || containingFunction.getStart() < position) {
+ // - enums/enum members
+ // - interfaces
+ // - property declarations
+ // - potentially property assignments
+ var commentOwner;
+ findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) {
+ switch (commentOwner.kind) {
+ case 213 /* FunctionDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 144 /* Constructor */:
+ case 214 /* ClassDeclaration */:
+ case 193 /* VariableStatement */:
+ break findOwner;
+ case 248 /* SourceFile */:
+ return undefined;
+ case 218 /* ModuleDeclaration */:
+ // If in walking up the tree, we hit a a nested namespace declaration,
+ // then we must be somewhere within a dotted namespace name; however we don't
+ // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'.
+ if (commentOwner.parent.kind === 218 /* ModuleDeclaration */) {
+ return undefined;
+ }
+ break findOwner;
+ }
+ }
+ if (!commentOwner || commentOwner.getStart() < position) {
return undefined;
}
- var parameters = containingFunction.parameters;
+ var parameters = getParametersForJsDocOwningNode(commentOwner);
var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position);
var lineStart = sourceFile.getLineStarts()[posLineAndChar.line];
var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character);
// TODO: call a helper method instead once PR #4133 gets merged in.
var newLine = host.getNewLine ? host.getNewLine() : "\r\n";
- var docParams = parameters.reduce(function (prev, cur, index) {
- return prev +
- indentationStr + " * @param " + (cur.name.kind === 67 /* Identifier */ ? cur.name.text : "param" + index) + newLine;
- }, "");
+ var docParams = "";
+ for (var i = 0, numParams = parameters.length; i < numParams; i++) {
+ var currentName = parameters[i].name;
+ var paramName = currentName.kind === 69 /* Identifier */ ?
+ currentName.text :
+ "param" + i;
+ docParams += indentationStr + " * @param " + paramName + newLine;
+ }
// A doc comment consists of the following
// * The opening comment line
// * the first line (without a param) for the object's untagged info (this is also where the caret ends up)
@@ -47444,6 +48392,46 @@ var ts;
(tokenStart === position ? newLine + indentationStr : "");
return { newText: result, caretOffset: preamble.length };
}
+ function getParametersForJsDocOwningNode(commentOwner) {
+ if (ts.isFunctionLike(commentOwner)) {
+ return commentOwner.parameters;
+ }
+ if (commentOwner.kind === 193 /* VariableStatement */) {
+ var varStatement = commentOwner;
+ var varDeclarations = varStatement.declarationList.declarations;
+ if (varDeclarations.length === 1 && varDeclarations[0].initializer) {
+ return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer);
+ }
+ }
+ return emptyArray;
+ }
+ /**
+ * Digs into an an initializer or RHS operand of an assignment operation
+ * to get the parameters of an apt signature corresponding to a
+ * function expression or a class expression.
+ *
+ * @param rightHandSide the expression which may contain an appropriate set of parameters
+ * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'.
+ */
+ function getParametersFromRightHandSideOfAssignment(rightHandSide) {
+ while (rightHandSide.kind === 172 /* ParenthesizedExpression */) {
+ rightHandSide = rightHandSide.expression;
+ }
+ switch (rightHandSide.kind) {
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
+ return rightHandSide.parameters;
+ case 186 /* ClassExpression */:
+ for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) {
+ var member = _a[_i];
+ if (member.kind === 144 /* Constructor */) {
+ return member.parameters;
+ }
+ }
+ break;
+ }
+ return emptyArray;
+ }
function getTodoComments(fileName, descriptors) {
// Note: while getting todo comments seems like a syntactic operation, we actually
// treat it as a semantic operation here. This is because we expect our host to call
@@ -47574,7 +48562,7 @@ var ts;
var typeChecker = program.getTypeChecker();
var node = ts.getTouchingWord(sourceFile, position);
// Can only rename an identifier.
- if (node && node.kind === 67 /* Identifier */) {
+ if (node && node.kind === 69 /* Identifier */) {
var symbol = typeChecker.getSymbolAtLocation(node);
// Only allow a symbol to be renamed if it actually has at least one declaration.
if (symbol) {
@@ -47675,7 +48663,7 @@ var ts;
sourceFile.nameTable = nameTable;
function walk(node) {
switch (node.kind) {
- case 67 /* Identifier */:
+ case 69 /* Identifier */:
nameTable[node.text] = node.text;
break;
case 9 /* StringLiteral */:
@@ -47685,7 +48673,7 @@ var ts;
// then we want 'something' to be in the name table. Similarly, if we have
// "a['propname']" then we want to store "propname" in the name table.
if (ts.isDeclarationName(node) ||
- node.parent.kind === 230 /* ExternalModuleReference */ ||
+ node.parent.kind === 232 /* ExternalModuleReference */ ||
isArgumentOfElementAccessExpression(node)) {
nameTable[node.text] = node.text;
}
@@ -47698,7 +48686,7 @@ var ts;
function isArgumentOfElementAccessExpression(node) {
return node &&
node.parent &&
- node.parent.kind === 165 /* ElementAccessExpression */ &&
+ node.parent.kind === 167 /* ElementAccessExpression */ &&
node.parent.argumentExpression === node;
}
/// Classifier
@@ -47709,18 +48697,18 @@ var ts;
/// we have a series of divide operator. this list allows us to be more accurate by ruling out
/// locations where a regexp cannot exist.
var noRegexTable = [];
- noRegexTable[67 /* Identifier */] = true;
+ noRegexTable[69 /* Identifier */] = true;
noRegexTable[9 /* StringLiteral */] = true;
noRegexTable[8 /* NumericLiteral */] = true;
noRegexTable[10 /* RegularExpressionLiteral */] = true;
- noRegexTable[95 /* ThisKeyword */] = true;
- noRegexTable[40 /* PlusPlusToken */] = true;
- noRegexTable[41 /* MinusMinusToken */] = true;
+ noRegexTable[97 /* ThisKeyword */] = true;
+ noRegexTable[41 /* PlusPlusToken */] = true;
+ noRegexTable[42 /* MinusMinusToken */] = true;
noRegexTable[18 /* CloseParenToken */] = true;
noRegexTable[20 /* CloseBracketToken */] = true;
noRegexTable[16 /* CloseBraceToken */] = true;
- noRegexTable[97 /* TrueKeyword */] = true;
- noRegexTable[82 /* FalseKeyword */] = true;
+ noRegexTable[99 /* TrueKeyword */] = true;
+ noRegexTable[84 /* FalseKeyword */] = true;
// Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact)
// classification on template strings. Because of the context free nature of templates,
// the only precise way to classify a template portion would be by propagating the stack across
@@ -47745,10 +48733,10 @@ var ts;
/** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */
function canFollow(keyword1, keyword2) {
if (ts.isAccessibilityModifier(keyword1)) {
- if (keyword2 === 121 /* GetKeyword */ ||
- keyword2 === 127 /* SetKeyword */ ||
- keyword2 === 119 /* ConstructorKeyword */ ||
- keyword2 === 111 /* StaticKeyword */) {
+ if (keyword2 === 123 /* GetKeyword */ ||
+ keyword2 === 129 /* SetKeyword */ ||
+ keyword2 === 121 /* ConstructorKeyword */ ||
+ keyword2 === 113 /* StaticKeyword */) {
// Allow things like "public get", "public constructor" and "public static".
// These are all legal.
return true;
@@ -47878,22 +48866,22 @@ var ts;
do {
token = scanner.scan();
if (!ts.isTrivia(token)) {
- if ((token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) {
+ if ((token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) {
if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) {
token = 10 /* RegularExpressionLiteral */;
}
}
else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) {
- token = 67 /* Identifier */;
+ token = 69 /* Identifier */;
}
else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) {
// We have two keywords in a row. Only treat the second as a keyword if
// it's a sequence that could legally occur in the language. Otherwise
// treat it as an identifier. This way, if someone writes "private var"
// we recognize that 'var' is actually an identifier here.
- token = 67 /* Identifier */;
+ token = 69 /* Identifier */;
}
- else if (lastNonTriviaToken === 67 /* Identifier */ &&
+ else if (lastNonTriviaToken === 69 /* Identifier */ &&
token === 25 /* LessThanToken */) {
// Could be the start of something generic. Keep track of that by bumping
// up the current count of generic contexts we may be in.
@@ -47904,16 +48892,16 @@ var ts;
// generic entity is complete.
angleBracketStack--;
}
- else if (token === 115 /* AnyKeyword */ ||
- token === 128 /* StringKeyword */ ||
- token === 126 /* NumberKeyword */ ||
- token === 118 /* BooleanKeyword */ ||
- token === 129 /* SymbolKeyword */) {
+ else if (token === 117 /* AnyKeyword */ ||
+ token === 130 /* StringKeyword */ ||
+ token === 128 /* NumberKeyword */ ||
+ token === 120 /* BooleanKeyword */ ||
+ token === 131 /* SymbolKeyword */) {
if (angleBracketStack > 0 && !syntacticClassifierAbsent) {
// If it looks like we're could be in something generic, don't classify this
// as a keyword. We may just get overwritten by the syntactic classifier,
// causing a noisy experience for the user.
- token = 67 /* Identifier */;
+ token = 69 /* Identifier */;
}
}
else if (token === 12 /* TemplateHead */) {
@@ -48025,40 +49013,41 @@ var ts;
function isBinaryExpressionOperatorToken(token) {
switch (token) {
case 37 /* AsteriskToken */:
- case 38 /* SlashToken */:
- case 39 /* PercentToken */:
+ case 39 /* SlashToken */:
+ case 40 /* PercentToken */:
case 35 /* PlusToken */:
case 36 /* MinusToken */:
- case 42 /* LessThanLessThanToken */:
- case 43 /* GreaterThanGreaterThanToken */:
- case 44 /* GreaterThanGreaterThanGreaterThanToken */:
+ case 43 /* LessThanLessThanToken */:
+ case 44 /* GreaterThanGreaterThanToken */:
+ case 45 /* GreaterThanGreaterThanGreaterThanToken */:
case 25 /* LessThanToken */:
case 27 /* GreaterThanToken */:
case 28 /* LessThanEqualsToken */:
case 29 /* GreaterThanEqualsToken */:
- case 89 /* InstanceOfKeyword */:
- case 88 /* InKeyword */:
+ case 91 /* InstanceOfKeyword */:
+ case 90 /* InKeyword */:
+ case 116 /* AsKeyword */:
case 30 /* EqualsEqualsToken */:
case 31 /* ExclamationEqualsToken */:
case 32 /* EqualsEqualsEqualsToken */:
case 33 /* ExclamationEqualsEqualsToken */:
- case 45 /* AmpersandToken */:
- case 47 /* CaretToken */:
- case 46 /* BarToken */:
- case 50 /* AmpersandAmpersandToken */:
- case 51 /* BarBarToken */:
- case 65 /* BarEqualsToken */:
- case 64 /* AmpersandEqualsToken */:
- case 66 /* CaretEqualsToken */:
- case 61 /* LessThanLessThanEqualsToken */:
- case 62 /* GreaterThanGreaterThanEqualsToken */:
- case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
- case 56 /* PlusEqualsToken */:
- case 57 /* MinusEqualsToken */:
- case 58 /* AsteriskEqualsToken */:
- case 59 /* SlashEqualsToken */:
- case 60 /* PercentEqualsToken */:
- case 55 /* EqualsToken */:
+ case 46 /* AmpersandToken */:
+ case 48 /* CaretToken */:
+ case 47 /* BarToken */:
+ case 51 /* AmpersandAmpersandToken */:
+ case 52 /* BarBarToken */:
+ case 67 /* BarEqualsToken */:
+ case 66 /* AmpersandEqualsToken */:
+ case 68 /* CaretEqualsToken */:
+ case 63 /* LessThanLessThanEqualsToken */:
+ case 64 /* GreaterThanGreaterThanEqualsToken */:
+ case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 57 /* PlusEqualsToken */:
+ case 58 /* MinusEqualsToken */:
+ case 59 /* AsteriskEqualsToken */:
+ case 61 /* SlashEqualsToken */:
+ case 62 /* PercentEqualsToken */:
+ case 56 /* EqualsToken */:
case 24 /* CommaToken */:
return true;
default:
@@ -48069,17 +49058,17 @@ var ts;
switch (token) {
case 35 /* PlusToken */:
case 36 /* MinusToken */:
- case 49 /* TildeToken */:
- case 48 /* ExclamationToken */:
- case 40 /* PlusPlusToken */:
- case 41 /* MinusMinusToken */:
+ case 50 /* TildeToken */:
+ case 49 /* ExclamationToken */:
+ case 41 /* PlusPlusToken */:
+ case 42 /* MinusMinusToken */:
return true;
default:
return false;
}
}
function isKeyword(token) {
- return token >= 68 /* FirstKeyword */ && token <= 132 /* LastKeyword */;
+ return token >= 70 /* FirstKeyword */ && token <= 134 /* LastKeyword */;
}
function classFromKind(token) {
if (isKeyword(token)) {
@@ -48088,7 +49077,7 @@ var ts;
else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) {
return 5 /* operator */;
}
- else if (token >= 15 /* FirstPunctuation */ && token <= 66 /* LastPunctuation */) {
+ else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) {
return 10 /* punctuation */;
}
switch (token) {
@@ -48105,7 +49094,7 @@ var ts;
case 5 /* WhitespaceTrivia */:
case 4 /* NewLineTrivia */:
return 8 /* whiteSpace */;
- case 67 /* Identifier */:
+ case 69 /* Identifier */:
default:
if (ts.isTemplateLiteralKind(token)) {
return 6 /* stringLiteral */;
@@ -48137,7 +49126,7 @@ var ts;
getNodeConstructor: function (kind) {
function Node() {
}
- var proto = kind === 246 /* SourceFile */ ? new SourceFileObject() : new NodeObject();
+ var proto = kind === 248 /* SourceFile */ ? new SourceFileObject() : new NodeObject();
proto.kind = kind;
proto.pos = -1;
proto.end = -1;
@@ -48207,125 +49196,125 @@ var ts;
function spanInNode(node) {
if (node) {
if (ts.isExpression(node)) {
- if (node.parent.kind === 195 /* DoStatement */) {
+ if (node.parent.kind === 197 /* DoStatement */) {
// Set span as if on while keyword
return spanInPreviousNode(node);
}
- if (node.parent.kind === 197 /* ForStatement */) {
+ if (node.parent.kind === 199 /* ForStatement */) {
// For now lets set the span on this expression, fix it later
return textSpan(node);
}
- if (node.parent.kind === 179 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) {
+ if (node.parent.kind === 181 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) {
// if this is comma expression, the breakpoint is possible in this expression
return textSpan(node);
}
- if (node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node) {
+ if (node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node) {
// If this is body of arrow function, it is allowed to have the breakpoint
return textSpan(node);
}
}
switch (node.kind) {
- case 191 /* VariableStatement */:
+ case 193 /* VariableStatement */:
// Span on first variable declaration
return spanInVariableDeclaration(node.declarationList.declarations[0]);
- case 209 /* VariableDeclaration */:
- case 139 /* PropertyDeclaration */:
- case 138 /* PropertySignature */:
+ case 211 /* VariableDeclaration */:
+ case 141 /* PropertyDeclaration */:
+ case 140 /* PropertySignature */:
return spanInVariableDeclaration(node);
- case 136 /* Parameter */:
+ case 138 /* Parameter */:
return spanInParameterDeclaration(node);
- case 211 /* FunctionDeclaration */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 142 /* Constructor */:
- case 171 /* FunctionExpression */:
- case 172 /* ArrowFunction */:
+ case 213 /* FunctionDeclaration */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 144 /* Constructor */:
+ case 173 /* FunctionExpression */:
+ case 174 /* ArrowFunction */:
return spanInFunctionDeclaration(node);
- case 190 /* Block */:
+ case 192 /* Block */:
if (ts.isFunctionBlock(node)) {
return spanInFunctionBlock(node);
}
// Fall through
- case 217 /* ModuleBlock */:
+ case 219 /* ModuleBlock */:
return spanInBlock(node);
- case 242 /* CatchClause */:
+ case 244 /* CatchClause */:
return spanInBlock(node.block);
- case 193 /* ExpressionStatement */:
+ case 195 /* ExpressionStatement */:
// span on the expression
return textSpan(node.expression);
- case 202 /* ReturnStatement */:
+ case 204 /* ReturnStatement */:
// span on return keyword and expression if present
return textSpan(node.getChildAt(0), node.expression);
- case 196 /* WhileStatement */:
+ case 198 /* WhileStatement */:
// Span on while(...)
return textSpan(node, ts.findNextToken(node.expression, node));
- case 195 /* DoStatement */:
+ case 197 /* DoStatement */:
// span in statement of the do statement
return spanInNode(node.statement);
- case 208 /* DebuggerStatement */:
+ case 210 /* DebuggerStatement */:
// span on debugger keyword
return textSpan(node.getChildAt(0));
- case 194 /* IfStatement */:
+ case 196 /* IfStatement */:
// set on if(..) span
return textSpan(node, ts.findNextToken(node.expression, node));
- case 205 /* LabeledStatement */:
+ case 207 /* LabeledStatement */:
// span in statement
return spanInNode(node.statement);
- case 201 /* BreakStatement */:
- case 200 /* ContinueStatement */:
+ case 203 /* BreakStatement */:
+ case 202 /* ContinueStatement */:
// On break or continue keyword and label if present
return textSpan(node.getChildAt(0), node.label);
- case 197 /* ForStatement */:
+ case 199 /* ForStatement */:
return spanInForStatement(node);
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
// span on for (a in ...)
return textSpan(node, ts.findNextToken(node.expression, node));
- case 204 /* SwitchStatement */:
+ case 206 /* SwitchStatement */:
// span on switch(...)
return textSpan(node, ts.findNextToken(node.expression, node));
- case 239 /* CaseClause */:
- case 240 /* DefaultClause */:
+ case 241 /* CaseClause */:
+ case 242 /* DefaultClause */:
// span in first statement of the clause
return spanInNode(node.statements[0]);
- case 207 /* TryStatement */:
+ case 209 /* TryStatement */:
// span in try block
return spanInBlock(node.tryBlock);
- case 206 /* ThrowStatement */:
+ case 208 /* ThrowStatement */:
// span in throw ...
return textSpan(node, node.expression);
- case 225 /* ExportAssignment */:
+ case 227 /* ExportAssignment */:
// span on export = id
return textSpan(node, node.expression);
- case 219 /* ImportEqualsDeclaration */:
+ case 221 /* ImportEqualsDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleReference);
- case 220 /* ImportDeclaration */:
+ case 222 /* ImportDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleSpecifier);
- case 226 /* ExportDeclaration */:
+ case 228 /* ExportDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleSpecifier);
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
// span on complete module if it is instantiated
if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
return undefined;
}
- case 212 /* ClassDeclaration */:
- case 215 /* EnumDeclaration */:
- case 245 /* EnumMember */:
- case 166 /* CallExpression */:
- case 167 /* NewExpression */:
+ case 214 /* ClassDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 247 /* EnumMember */:
+ case 168 /* CallExpression */:
+ case 169 /* NewExpression */:
// span on complete node
return textSpan(node);
- case 203 /* WithStatement */:
+ case 205 /* WithStatement */:
// span in statement
return spanInNode(node.statement);
// No breakpoint in interface, type alias
- case 213 /* InterfaceDeclaration */:
- case 214 /* TypeAliasDeclaration */:
+ case 215 /* InterfaceDeclaration */:
+ case 216 /* TypeAliasDeclaration */:
return undefined;
// Tokens:
case 23 /* SemicolonToken */:
@@ -48341,25 +49330,25 @@ var ts;
return spanInOpenParenToken(node);
case 18 /* CloseParenToken */:
return spanInCloseParenToken(node);
- case 53 /* ColonToken */:
+ case 54 /* ColonToken */:
return spanInColonToken(node);
case 27 /* GreaterThanToken */:
case 25 /* LessThanToken */:
return spanInGreaterThanOrLessThanToken(node);
// Keywords:
- case 102 /* WhileKeyword */:
+ case 104 /* WhileKeyword */:
return spanInWhileKeyword(node);
- case 78 /* ElseKeyword */:
- case 70 /* CatchKeyword */:
- case 83 /* FinallyKeyword */:
+ case 80 /* ElseKeyword */:
+ case 72 /* CatchKeyword */:
+ case 85 /* FinallyKeyword */:
return spanInNextNode(node);
default:
// If this is name of property assignment, set breakpoint in the initializer
- if (node.parent.kind === 243 /* PropertyAssignment */ && node.parent.name === node) {
+ if (node.parent.kind === 245 /* PropertyAssignment */ && node.parent.name === node) {
return spanInNode(node.parent.initializer);
}
// Breakpoint in type assertion goes to its operand
- if (node.parent.kind === 169 /* TypeAssertionExpression */ && node.parent.type === node) {
+ if (node.parent.kind === 171 /* TypeAssertionExpression */ && node.parent.type === node) {
return spanInNode(node.parent.expression);
}
// return type of function go to previous token
@@ -48372,12 +49361,12 @@ var ts;
}
function spanInVariableDeclaration(variableDeclaration) {
// If declaration of for in statement, just set the span in parent
- if (variableDeclaration.parent.parent.kind === 198 /* ForInStatement */ ||
- variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */) {
+ if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ ||
+ variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) {
return spanInNode(variableDeclaration.parent.parent);
}
- var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191 /* VariableStatement */;
- var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration);
+ var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */;
+ var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration);
var declarations = isParentVariableStatement
? variableDeclaration.parent.parent.declarationList.declarations
: isDeclarationOfForStatement
@@ -48431,7 +49420,7 @@ var ts;
}
function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) {
return !!(functionDeclaration.flags & 1 /* Export */) ||
- (functionDeclaration.parent.kind === 212 /* ClassDeclaration */ && functionDeclaration.kind !== 142 /* Constructor */);
+ (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */);
}
function spanInFunctionDeclaration(functionDeclaration) {
// No breakpoints in the function signature
@@ -48454,18 +49443,18 @@ var ts;
}
function spanInBlock(block) {
switch (block.parent.kind) {
- case 216 /* ModuleDeclaration */:
+ case 218 /* ModuleDeclaration */:
if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) {
return undefined;
}
// Set on parent if on same line otherwise on first statement
- case 196 /* WhileStatement */:
- case 194 /* IfStatement */:
- case 198 /* ForInStatement */:
- case 199 /* ForOfStatement */:
+ case 198 /* WhileStatement */:
+ case 196 /* IfStatement */:
+ case 200 /* ForInStatement */:
+ case 201 /* ForOfStatement */:
return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]);
// Set span on previous token if it starts on same line otherwise on the first statement of the block
- case 197 /* ForStatement */:
+ case 199 /* ForStatement */:
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]);
}
// Default action is to set on first statement
@@ -48473,7 +49462,7 @@ var ts;
}
function spanInForStatement(forStatement) {
if (forStatement.initializer) {
- if (forStatement.initializer.kind === 210 /* VariableDeclarationList */) {
+ if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) {
var variableDeclarationList = forStatement.initializer;
if (variableDeclarationList.declarations.length > 0) {
return spanInNode(variableDeclarationList.declarations[0]);
@@ -48493,13 +49482,13 @@ var ts;
// Tokens:
function spanInOpenBraceToken(node) {
switch (node.parent.kind) {
- case 215 /* EnumDeclaration */:
+ case 217 /* EnumDeclaration */:
var enumDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile));
- case 212 /* ClassDeclaration */:
+ case 214 /* ClassDeclaration */:
var classDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile));
- case 218 /* CaseBlock */:
+ case 220 /* CaseBlock */:
return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]);
}
// Default to parent node
@@ -48507,25 +49496,25 @@ var ts;
}
function spanInCloseBraceToken(node) {
switch (node.parent.kind) {
- case 217 /* ModuleBlock */:
+ case 219 /* ModuleBlock */:
// If this is not instantiated module block no bp span
if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) {
return undefined;
}
- case 215 /* EnumDeclaration */:
- case 212 /* ClassDeclaration */:
+ case 217 /* EnumDeclaration */:
+ case 214 /* ClassDeclaration */:
// Span on close brace token
return textSpan(node);
- case 190 /* Block */:
+ case 192 /* Block */:
if (ts.isFunctionBlock(node.parent)) {
// Span on close brace token
return textSpan(node);
}
// fall through.
- case 242 /* CatchClause */:
+ case 244 /* CatchClause */:
return spanInNode(ts.lastOrUndefined(node.parent.statements));
;
- case 218 /* CaseBlock */:
+ case 220 /* CaseBlock */:
// breakpoint in last statement of the last clause
var caseBlock = node.parent;
var lastClause = ts.lastOrUndefined(caseBlock.clauses);
@@ -48539,7 +49528,7 @@ var ts;
}
}
function spanInOpenParenToken(node) {
- if (node.parent.kind === 195 /* DoStatement */) {
+ if (node.parent.kind === 197 /* DoStatement */) {
// Go to while keyword and do action instead
return spanInPreviousNode(node);
}
@@ -48549,17 +49538,17 @@ var ts;
function spanInCloseParenToken(node) {
// Is this close paren token of parameter list, set span in previous token
switch (node.parent.kind) {
- case 171 /* FunctionExpression */:
- case 211 /* FunctionDeclaration */:
- case 172 /* ArrowFunction */:
- case 141 /* MethodDeclaration */:
- case 140 /* MethodSignature */:
- case 143 /* GetAccessor */:
- case 144 /* SetAccessor */:
- case 142 /* Constructor */:
- case 196 /* WhileStatement */:
- case 195 /* DoStatement */:
- case 197 /* ForStatement */:
+ case 173 /* FunctionExpression */:
+ case 213 /* FunctionDeclaration */:
+ case 174 /* ArrowFunction */:
+ case 143 /* MethodDeclaration */:
+ case 142 /* MethodSignature */:
+ case 145 /* GetAccessor */:
+ case 146 /* SetAccessor */:
+ case 144 /* Constructor */:
+ case 198 /* WhileStatement */:
+ case 197 /* DoStatement */:
+ case 199 /* ForStatement */:
return spanInPreviousNode(node);
// Default to parent node
default:
@@ -48570,19 +49559,19 @@ var ts;
}
function spanInColonToken(node) {
// Is this : specifying return annotation of the function declaration
- if (ts.isFunctionLike(node.parent) || node.parent.kind === 243 /* PropertyAssignment */) {
+ if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) {
return spanInPreviousNode(node);
}
return spanInNode(node.parent);
}
function spanInGreaterThanOrLessThanToken(node) {
- if (node.parent.kind === 169 /* TypeAssertionExpression */) {
+ if (node.parent.kind === 171 /* TypeAssertionExpression */) {
return spanInNode(node.parent.expression);
}
return spanInNode(node.parent);
}
function spanInWhileKeyword(node) {
- if (node.parent.kind === 195 /* DoStatement */) {
+ if (node.parent.kind === 197 /* DoStatement */) {
// Set span on while expression
return textSpan(node, ts.findNextToken(node.parent.expression, node.parent));
}
@@ -49247,7 +50236,7 @@ var ts;
var _this = this;
return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () {
var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength());
- var result = ts.parseConfigFileText(fileName, text);
+ var result = ts.parseConfigFileTextToJson(fileName, text);
if (result.error) {
return {
options: {},
@@ -49255,7 +50244,7 @@ var ts;
errors: [realizeDiagnostic(result.error, '\r\n')]
};
}
- var configFile = ts.parseConfigFile(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName)));
+ var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName)));
return {
options: configFile.options,
files: configFile.fileNames,
@@ -49347,4 +50336,4 @@ var TypeScript;
})(Services = TypeScript.Services || (TypeScript.Services = {}));
})(TypeScript || (TypeScript = {}));
/* @internal */
-var toolsVersion = "1.6";
+var toolsVersion = "1.7";