diff --git a/package.json b/package.json index e4b8071f2ae6..c14ed3ff34b5 100644 --- a/package.json +++ b/package.json @@ -56,9 +56,6 @@ "packages/angular_devkit/*", "packages/ngtools/*", "packages/schematics/*" - ], - "nohoist": [ - "@angular/compiler-cli" ] }, "resolutions": { @@ -221,7 +218,7 @@ "tree-kill": "1.2.2", "ts-node": "^10.0.0", "tslib": "2.3.1", - "typescript": "4.3.5", + "typescript": "4.4.3", "verdaccio": "5.1.6", "verdaccio-auth-memory": "^10.0.0", "webpack": "5.54.0", diff --git a/packages/angular_devkit/build_optimizer/package.json b/packages/angular_devkit/build_optimizer/package.json index 008063fb0f5c..58156c7500ac 100644 --- a/packages/angular_devkit/build_optimizer/package.json +++ b/packages/angular_devkit/build_optimizer/package.json @@ -11,7 +11,7 @@ "dependencies": { "source-map": "0.7.3", "tslib": "2.3.1", - "typescript": "4.3.5" + "typescript": "4.4.3" }, "peerDependencies": { "webpack": "^5.30.0" diff --git a/packages/angular_devkit/schematics_cli/blank/project-files/package.json b/packages/angular_devkit/schematics_cli/blank/project-files/package.json index c593822394b3..6fc01d828bfc 100644 --- a/packages/angular_devkit/schematics_cli/blank/project-files/package.json +++ b/packages/angular_devkit/schematics_cli/blank/project-files/package.json @@ -15,7 +15,7 @@ "dependencies": { "@angular-devkit/core": "^<%= coreVersion %>", "@angular-devkit/schematics": "^<%= schematicsVersion %>", - "typescript": "~4.3.2" + "typescript": "~4.4.3" }, "devDependencies": { "@types/node": "^12.11.1", diff --git a/packages/angular_devkit/schematics_cli/schematic/files/package.json b/packages/angular_devkit/schematics_cli/schematic/files/package.json index 161b1754c55d..2b7c8625c0b0 100644 --- a/packages/angular_devkit/schematics_cli/schematic/files/package.json +++ b/packages/angular_devkit/schematics_cli/schematic/files/package.json @@ -15,7 +15,7 @@ "dependencies": { "@angular-devkit/core": "^<%= coreVersion %>", "@angular-devkit/schematics": "^<%= schematicsVersion %>", - "typescript": "~4.3.2" + "typescript": "~4.4.3" }, "devDependencies": { "@types/node": "^12.11.1", diff --git a/packages/ngtools/webpack/package.json b/packages/ngtools/webpack/package.json index 866bb8f42db6..725c337e7acc 100644 --- a/packages/ngtools/webpack/package.json +++ b/packages/ngtools/webpack/package.json @@ -23,14 +23,14 @@ "dependencies": {}, "peerDependencies": { "@angular/compiler-cli": "^13.0.0 || ^13.0.0-next", - "typescript": "~4.2.3 || ~4.3.2", + "typescript": "~4.4.3", "webpack": "^5.30.0" }, "devDependencies": { "@angular-devkit/core": "0.0.0", "@angular/compiler": "12.2.7", "@angular/compiler-cli": "12.2.7", - "typescript": "4.3.5", + "typescript": "4.4.3", "webpack": "5.54.0" } } diff --git a/packages/ngtools/webpack/src/transformers/replace_resources_spec.ts b/packages/ngtools/webpack/src/transformers/replace_resources_spec.ts index 3a41dd0f8e98..59d554c6748b 100644 --- a/packages/ngtools/webpack/src/transformers/replace_resources_spec.ts +++ b/packages/ngtools/webpack/src/transformers/replace_resources_spec.ts @@ -88,6 +88,7 @@ describe('@ngtools/webpack transformers', () => { title = 'app'; } `; + const output = tags.stripIndent` "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -98,8 +99,8 @@ describe('@ngtools/webpack transformers', () => { let AppComponent = class AppComponent { constructor() { this.title = 'app'; } }; - AppComponent = tslib_1.__decorate([ - core_1.Component({ + AppComponent = (0, tslib_1.__decorate)([ + (0, core_1.Component)({ selector: 'app-root', template: require("!${DirectAngularResourceLoaderPath}!./app.component.html").default, styles: [require("./app.component.css").default, require("./app.component.2.css").default] }) ], AppComponent); diff --git a/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/BUILD.bazel b/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/BUILD.bazel index cd36c96e2130..9f6607b6bde8 100644 --- a/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/BUILD.bazel +++ b/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/BUILD.bazel @@ -1,7 +1,7 @@ load("//tools:defaults.bzl", "ts_library") -# files fetched on 2021-03-17 from -# https://github.com/microsoft/TypeScript/releases/tag/v4.2.3 +# files fetched on 2021-09-28 from +# https://github.com/microsoft/TypeScript/releases/tag/v4.4.3 licenses(["notice"]) # Apache 2.0 ts_library( diff --git a/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.d.ts b/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.d.ts index b86a3a29970a..4902d45ad317 100644 --- a/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.d.ts +++ b/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "4.3"; + const versionMajorMinor = "4.4"; /** The version of the TypeScript compiler release */ const version: string; /** @@ -166,306 +166,312 @@ declare namespace ts { QuestionQuestionToken = 60, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ BacktickToken = 61, - EqualsToken = 62, - PlusEqualsToken = 63, - MinusEqualsToken = 64, - AsteriskEqualsToken = 65, - AsteriskAsteriskEqualsToken = 66, - SlashEqualsToken = 67, - PercentEqualsToken = 68, - LessThanLessThanEqualsToken = 69, - GreaterThanGreaterThanEqualsToken = 70, - GreaterThanGreaterThanGreaterThanEqualsToken = 71, - AmpersandEqualsToken = 72, - BarEqualsToken = 73, - BarBarEqualsToken = 74, - AmpersandAmpersandEqualsToken = 75, - QuestionQuestionEqualsToken = 76, - CaretEqualsToken = 77, - Identifier = 78, - PrivateIdentifier = 79, - BreakKeyword = 80, - CaseKeyword = 81, - CatchKeyword = 82, - ClassKeyword = 83, - ConstKeyword = 84, - ContinueKeyword = 85, - DebuggerKeyword = 86, - DefaultKeyword = 87, - DeleteKeyword = 88, - DoKeyword = 89, - ElseKeyword = 90, - EnumKeyword = 91, - ExportKeyword = 92, - ExtendsKeyword = 93, - FalseKeyword = 94, - FinallyKeyword = 95, - ForKeyword = 96, - FunctionKeyword = 97, - IfKeyword = 98, - ImportKeyword = 99, - InKeyword = 100, - InstanceOfKeyword = 101, - NewKeyword = 102, - NullKeyword = 103, - ReturnKeyword = 104, - SuperKeyword = 105, - SwitchKeyword = 106, - ThisKeyword = 107, - ThrowKeyword = 108, - TrueKeyword = 109, - TryKeyword = 110, - TypeOfKeyword = 111, - VarKeyword = 112, - VoidKeyword = 113, - WhileKeyword = 114, - WithKeyword = 115, - ImplementsKeyword = 116, - InterfaceKeyword = 117, - LetKeyword = 118, - PackageKeyword = 119, - PrivateKeyword = 120, - ProtectedKeyword = 121, - PublicKeyword = 122, - StaticKeyword = 123, - YieldKeyword = 124, - AbstractKeyword = 125, - AsKeyword = 126, - AssertsKeyword = 127, - AnyKeyword = 128, - AsyncKeyword = 129, - AwaitKeyword = 130, - BooleanKeyword = 131, - ConstructorKeyword = 132, - DeclareKeyword = 133, - GetKeyword = 134, - InferKeyword = 135, - IntrinsicKeyword = 136, - IsKeyword = 137, - KeyOfKeyword = 138, - ModuleKeyword = 139, - NamespaceKeyword = 140, - NeverKeyword = 141, - ReadonlyKeyword = 142, - RequireKeyword = 143, - NumberKeyword = 144, - ObjectKeyword = 145, - SetKeyword = 146, - StringKeyword = 147, - SymbolKeyword = 148, - TypeKeyword = 149, - UndefinedKeyword = 150, - UniqueKeyword = 151, - UnknownKeyword = 152, - FromKeyword = 153, - GlobalKeyword = 154, - BigIntKeyword = 155, - OverrideKeyword = 156, - OfKeyword = 157, - QualifiedName = 158, - ComputedPropertyName = 159, - TypeParameter = 160, - Parameter = 161, - Decorator = 162, - PropertySignature = 163, - PropertyDeclaration = 164, - MethodSignature = 165, - MethodDeclaration = 166, - Constructor = 167, - GetAccessor = 168, - SetAccessor = 169, - CallSignature = 170, - ConstructSignature = 171, - IndexSignature = 172, - TypePredicate = 173, - TypeReference = 174, - FunctionType = 175, - ConstructorType = 176, - TypeQuery = 177, - TypeLiteral = 178, - ArrayType = 179, - TupleType = 180, - OptionalType = 181, - RestType = 182, - UnionType = 183, - IntersectionType = 184, - ConditionalType = 185, - InferType = 186, - ParenthesizedType = 187, - ThisType = 188, - TypeOperator = 189, - IndexedAccessType = 190, - MappedType = 191, - LiteralType = 192, - NamedTupleMember = 193, - TemplateLiteralType = 194, - TemplateLiteralTypeSpan = 195, - ImportType = 196, - ObjectBindingPattern = 197, - ArrayBindingPattern = 198, - BindingElement = 199, - ArrayLiteralExpression = 200, - ObjectLiteralExpression = 201, - PropertyAccessExpression = 202, - ElementAccessExpression = 203, - CallExpression = 204, - NewExpression = 205, - TaggedTemplateExpression = 206, - TypeAssertionExpression = 207, - ParenthesizedExpression = 208, - FunctionExpression = 209, - ArrowFunction = 210, - DeleteExpression = 211, - TypeOfExpression = 212, - VoidExpression = 213, - AwaitExpression = 214, - PrefixUnaryExpression = 215, - PostfixUnaryExpression = 216, - BinaryExpression = 217, - ConditionalExpression = 218, - TemplateExpression = 219, - YieldExpression = 220, - SpreadElement = 221, - ClassExpression = 222, - OmittedExpression = 223, - ExpressionWithTypeArguments = 224, - AsExpression = 225, - NonNullExpression = 226, - MetaProperty = 227, - SyntheticExpression = 228, - TemplateSpan = 229, - SemicolonClassElement = 230, - Block = 231, - EmptyStatement = 232, - VariableStatement = 233, - ExpressionStatement = 234, - IfStatement = 235, - DoStatement = 236, - WhileStatement = 237, - ForStatement = 238, - ForInStatement = 239, - ForOfStatement = 240, - ContinueStatement = 241, - BreakStatement = 242, - ReturnStatement = 243, - WithStatement = 244, - SwitchStatement = 245, - LabeledStatement = 246, - ThrowStatement = 247, - TryStatement = 248, - DebuggerStatement = 249, - VariableDeclaration = 250, - VariableDeclarationList = 251, - FunctionDeclaration = 252, - ClassDeclaration = 253, - InterfaceDeclaration = 254, - TypeAliasDeclaration = 255, - EnumDeclaration = 256, - ModuleDeclaration = 257, - ModuleBlock = 258, - CaseBlock = 259, - NamespaceExportDeclaration = 260, - ImportEqualsDeclaration = 261, - ImportDeclaration = 262, - ImportClause = 263, - NamespaceImport = 264, - NamedImports = 265, - ImportSpecifier = 266, - ExportAssignment = 267, - ExportDeclaration = 268, - NamedExports = 269, - NamespaceExport = 270, - ExportSpecifier = 271, - MissingDeclaration = 272, - ExternalModuleReference = 273, - JsxElement = 274, - JsxSelfClosingElement = 275, - JsxOpeningElement = 276, - JsxClosingElement = 277, - JsxFragment = 278, - JsxOpeningFragment = 279, - JsxClosingFragment = 280, - JsxAttribute = 281, - JsxAttributes = 282, - JsxSpreadAttribute = 283, - JsxExpression = 284, - CaseClause = 285, - DefaultClause = 286, - HeritageClause = 287, - CatchClause = 288, - PropertyAssignment = 289, - ShorthandPropertyAssignment = 290, - SpreadAssignment = 291, - EnumMember = 292, - UnparsedPrologue = 293, - UnparsedPrepend = 294, - UnparsedText = 295, - UnparsedInternalText = 296, - UnparsedSyntheticReference = 297, - SourceFile = 298, - Bundle = 299, - UnparsedSource = 300, - InputFiles = 301, - JSDocTypeExpression = 302, - JSDocNameReference = 303, - JSDocAllType = 304, - JSDocUnknownType = 305, - JSDocNullableType = 306, - JSDocNonNullableType = 307, - JSDocOptionalType = 308, - JSDocFunctionType = 309, - JSDocVariadicType = 310, - JSDocNamepathType = 311, - JSDocComment = 312, - JSDocText = 313, - JSDocTypeLiteral = 314, - JSDocSignature = 315, - JSDocLink = 316, - JSDocTag = 317, - JSDocAugmentsTag = 318, - JSDocImplementsTag = 319, - JSDocAuthorTag = 320, - JSDocDeprecatedTag = 321, - JSDocClassTag = 322, - JSDocPublicTag = 323, - JSDocPrivateTag = 324, - JSDocProtectedTag = 325, - JSDocReadonlyTag = 326, - JSDocOverrideTag = 327, - JSDocCallbackTag = 328, - JSDocEnumTag = 329, - JSDocParameterTag = 330, - JSDocReturnTag = 331, - JSDocThisTag = 332, - JSDocTypeTag = 333, - JSDocTemplateTag = 334, - JSDocTypedefTag = 335, - JSDocSeeTag = 336, - JSDocPropertyTag = 337, - SyntaxList = 338, - NotEmittedStatement = 339, - PartiallyEmittedExpression = 340, - CommaListExpression = 341, - MergeDeclarationMarker = 342, - EndOfDeclarationMarker = 343, - SyntheticReferenceExpression = 344, - Count = 345, - FirstAssignment = 62, - LastAssignment = 77, - FirstCompoundAssignment = 63, - LastCompoundAssignment = 77, - FirstReservedWord = 80, - LastReservedWord = 115, - FirstKeyword = 80, - LastKeyword = 157, - FirstFutureReservedWord = 116, - LastFutureReservedWord = 124, - FirstTypeNode = 173, - LastTypeNode = 196, + /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ + HashToken = 62, + EqualsToken = 63, + PlusEqualsToken = 64, + MinusEqualsToken = 65, + AsteriskEqualsToken = 66, + AsteriskAsteriskEqualsToken = 67, + SlashEqualsToken = 68, + PercentEqualsToken = 69, + LessThanLessThanEqualsToken = 70, + GreaterThanGreaterThanEqualsToken = 71, + GreaterThanGreaterThanGreaterThanEqualsToken = 72, + AmpersandEqualsToken = 73, + BarEqualsToken = 74, + BarBarEqualsToken = 75, + AmpersandAmpersandEqualsToken = 76, + QuestionQuestionEqualsToken = 77, + CaretEqualsToken = 78, + Identifier = 79, + PrivateIdentifier = 80, + BreakKeyword = 81, + CaseKeyword = 82, + CatchKeyword = 83, + ClassKeyword = 84, + ConstKeyword = 85, + ContinueKeyword = 86, + DebuggerKeyword = 87, + DefaultKeyword = 88, + DeleteKeyword = 89, + DoKeyword = 90, + ElseKeyword = 91, + EnumKeyword = 92, + ExportKeyword = 93, + ExtendsKeyword = 94, + FalseKeyword = 95, + FinallyKeyword = 96, + ForKeyword = 97, + FunctionKeyword = 98, + IfKeyword = 99, + ImportKeyword = 100, + InKeyword = 101, + InstanceOfKeyword = 102, + NewKeyword = 103, + NullKeyword = 104, + ReturnKeyword = 105, + SuperKeyword = 106, + SwitchKeyword = 107, + ThisKeyword = 108, + ThrowKeyword = 109, + TrueKeyword = 110, + TryKeyword = 111, + TypeOfKeyword = 112, + VarKeyword = 113, + VoidKeyword = 114, + WhileKeyword = 115, + WithKeyword = 116, + ImplementsKeyword = 117, + InterfaceKeyword = 118, + LetKeyword = 119, + PackageKeyword = 120, + PrivateKeyword = 121, + ProtectedKeyword = 122, + PublicKeyword = 123, + StaticKeyword = 124, + YieldKeyword = 125, + AbstractKeyword = 126, + AsKeyword = 127, + AssertsKeyword = 128, + AnyKeyword = 129, + AsyncKeyword = 130, + AwaitKeyword = 131, + BooleanKeyword = 132, + ConstructorKeyword = 133, + DeclareKeyword = 134, + GetKeyword = 135, + InferKeyword = 136, + IntrinsicKeyword = 137, + IsKeyword = 138, + KeyOfKeyword = 139, + ModuleKeyword = 140, + NamespaceKeyword = 141, + NeverKeyword = 142, + ReadonlyKeyword = 143, + RequireKeyword = 144, + NumberKeyword = 145, + ObjectKeyword = 146, + SetKeyword = 147, + StringKeyword = 148, + SymbolKeyword = 149, + TypeKeyword = 150, + UndefinedKeyword = 151, + UniqueKeyword = 152, + UnknownKeyword = 153, + FromKeyword = 154, + GlobalKeyword = 155, + BigIntKeyword = 156, + OverrideKeyword = 157, + OfKeyword = 158, + QualifiedName = 159, + ComputedPropertyName = 160, + TypeParameter = 161, + Parameter = 162, + Decorator = 163, + PropertySignature = 164, + PropertyDeclaration = 165, + MethodSignature = 166, + MethodDeclaration = 167, + ClassStaticBlockDeclaration = 168, + Constructor = 169, + GetAccessor = 170, + SetAccessor = 171, + CallSignature = 172, + ConstructSignature = 173, + IndexSignature = 174, + TypePredicate = 175, + TypeReference = 176, + FunctionType = 177, + ConstructorType = 178, + TypeQuery = 179, + TypeLiteral = 180, + ArrayType = 181, + TupleType = 182, + OptionalType = 183, + RestType = 184, + UnionType = 185, + IntersectionType = 186, + ConditionalType = 187, + InferType = 188, + ParenthesizedType = 189, + ThisType = 190, + TypeOperator = 191, + IndexedAccessType = 192, + MappedType = 193, + LiteralType = 194, + NamedTupleMember = 195, + TemplateLiteralType = 196, + TemplateLiteralTypeSpan = 197, + ImportType = 198, + ObjectBindingPattern = 199, + ArrayBindingPattern = 200, + BindingElement = 201, + ArrayLiteralExpression = 202, + ObjectLiteralExpression = 203, + PropertyAccessExpression = 204, + ElementAccessExpression = 205, + CallExpression = 206, + NewExpression = 207, + TaggedTemplateExpression = 208, + TypeAssertionExpression = 209, + ParenthesizedExpression = 210, + FunctionExpression = 211, + ArrowFunction = 212, + DeleteExpression = 213, + TypeOfExpression = 214, + VoidExpression = 215, + AwaitExpression = 216, + PrefixUnaryExpression = 217, + PostfixUnaryExpression = 218, + BinaryExpression = 219, + ConditionalExpression = 220, + TemplateExpression = 221, + YieldExpression = 222, + SpreadElement = 223, + ClassExpression = 224, + OmittedExpression = 225, + ExpressionWithTypeArguments = 226, + AsExpression = 227, + NonNullExpression = 228, + MetaProperty = 229, + SyntheticExpression = 230, + TemplateSpan = 231, + SemicolonClassElement = 232, + Block = 233, + EmptyStatement = 234, + VariableStatement = 235, + ExpressionStatement = 236, + IfStatement = 237, + DoStatement = 238, + WhileStatement = 239, + ForStatement = 240, + ForInStatement = 241, + ForOfStatement = 242, + ContinueStatement = 243, + BreakStatement = 244, + ReturnStatement = 245, + WithStatement = 246, + SwitchStatement = 247, + LabeledStatement = 248, + ThrowStatement = 249, + TryStatement = 250, + DebuggerStatement = 251, + VariableDeclaration = 252, + VariableDeclarationList = 253, + FunctionDeclaration = 254, + ClassDeclaration = 255, + InterfaceDeclaration = 256, + TypeAliasDeclaration = 257, + EnumDeclaration = 258, + ModuleDeclaration = 259, + ModuleBlock = 260, + CaseBlock = 261, + NamespaceExportDeclaration = 262, + ImportEqualsDeclaration = 263, + ImportDeclaration = 264, + ImportClause = 265, + NamespaceImport = 266, + NamedImports = 267, + ImportSpecifier = 268, + ExportAssignment = 269, + ExportDeclaration = 270, + NamedExports = 271, + NamespaceExport = 272, + ExportSpecifier = 273, + MissingDeclaration = 274, + ExternalModuleReference = 275, + JsxElement = 276, + JsxSelfClosingElement = 277, + JsxOpeningElement = 278, + JsxClosingElement = 279, + JsxFragment = 280, + JsxOpeningFragment = 281, + JsxClosingFragment = 282, + JsxAttribute = 283, + JsxAttributes = 284, + JsxSpreadAttribute = 285, + JsxExpression = 286, + CaseClause = 287, + DefaultClause = 288, + HeritageClause = 289, + CatchClause = 290, + PropertyAssignment = 291, + ShorthandPropertyAssignment = 292, + SpreadAssignment = 293, + EnumMember = 294, + UnparsedPrologue = 295, + UnparsedPrepend = 296, + UnparsedText = 297, + UnparsedInternalText = 298, + UnparsedSyntheticReference = 299, + SourceFile = 300, + Bundle = 301, + UnparsedSource = 302, + InputFiles = 303, + JSDocTypeExpression = 304, + JSDocNameReference = 305, + JSDocMemberName = 306, + JSDocAllType = 307, + JSDocUnknownType = 308, + JSDocNullableType = 309, + JSDocNonNullableType = 310, + JSDocOptionalType = 311, + JSDocFunctionType = 312, + JSDocVariadicType = 313, + JSDocNamepathType = 314, + JSDocComment = 315, + JSDocText = 316, + JSDocTypeLiteral = 317, + JSDocSignature = 318, + JSDocLink = 319, + JSDocLinkCode = 320, + JSDocLinkPlain = 321, + JSDocTag = 322, + JSDocAugmentsTag = 323, + JSDocImplementsTag = 324, + JSDocAuthorTag = 325, + JSDocDeprecatedTag = 326, + JSDocClassTag = 327, + JSDocPublicTag = 328, + JSDocPrivateTag = 329, + JSDocProtectedTag = 330, + JSDocReadonlyTag = 331, + JSDocOverrideTag = 332, + JSDocCallbackTag = 333, + JSDocEnumTag = 334, + JSDocParameterTag = 335, + JSDocReturnTag = 336, + JSDocThisTag = 337, + JSDocTypeTag = 338, + JSDocTemplateTag = 339, + JSDocTypedefTag = 340, + JSDocSeeTag = 341, + JSDocPropertyTag = 342, + SyntaxList = 343, + NotEmittedStatement = 344, + PartiallyEmittedExpression = 345, + CommaListExpression = 346, + MergeDeclarationMarker = 347, + EndOfDeclarationMarker = 348, + SyntheticReferenceExpression = 349, + Count = 350, + FirstAssignment = 63, + LastAssignment = 78, + FirstCompoundAssignment = 64, + LastCompoundAssignment = 78, + FirstReservedWord = 81, + LastReservedWord = 116, + FirstKeyword = 81, + LastKeyword = 158, + FirstFutureReservedWord = 117, + LastFutureReservedWord = 125, + FirstTypeNode = 175, + LastTypeNode = 198, FirstPunctuation = 18, - LastPunctuation = 77, + LastPunctuation = 78, FirstToken = 0, - LastToken = 157, + LastToken = 158, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -473,25 +479,25 @@ declare namespace ts { FirstTemplateToken = 14, LastTemplateToken = 17, FirstBinaryOperator = 29, - LastBinaryOperator = 77, - FirstStatement = 233, - LastStatement = 249, - FirstNode = 158, - FirstJSDocNode = 302, - LastJSDocNode = 337, - FirstJSDocTagNode = 317, - LastJSDocTagNode = 337, + LastBinaryOperator = 78, + FirstStatement = 235, + LastStatement = 251, + FirstNode = 159, + FirstJSDocNode = 304, + LastJSDocNode = 342, + FirstJSDocTagNode = 322, + LastJSDocTagNode = 342, } export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail; - export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; + export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind; export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; - export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; + export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.Unknown | KeywordSyntaxKind; export enum NodeFlags { None = 0, Let = 1, @@ -563,13 +569,13 @@ declare namespace ts { } export interface JSDocContainer { } - export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken; + export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ClassStaticBlockDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken; export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement; export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; export interface NodeArray extends ReadonlyArray, ReadonlyTextRange { - hasTrailingComma?: boolean; + readonly hasTrailingComma: boolean; } export interface Token extends Node { readonly kind: TKind; @@ -845,6 +851,11 @@ declare namespace ts { readonly parent: ObjectTypeDeclaration; readonly type: TypeNode; } + export interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer { + readonly kind: SyntaxKind.ClassStaticBlockDeclaration; + readonly parent: ClassDeclaration | ClassExpression; + readonly body: Block; + } export interface TypeNode extends Node { _typeNodeBrand: any; } @@ -1710,7 +1721,13 @@ declare namespace ts { } export interface JSDocNameReference extends Node { readonly kind: SyntaxKind.JSDocNameReference; - readonly name: EntityName; + readonly name: EntityName | JSDocMemberName; + } + /** Class#method reference in JSDoc */ + export interface JSDocMemberName extends Node { + readonly kind: SyntaxKind.JSDocMemberName; + readonly left: EntityName | JSDocMemberName; + readonly right: Identifier; } export interface JSDocType extends TypeNode { _jsDocTypeBrand: any; @@ -1749,18 +1766,29 @@ declare namespace ts { readonly kind: SyntaxKind.JSDocComment; readonly parent: HasJSDoc; readonly tags?: NodeArray; - readonly comment?: string | NodeArray; + readonly comment?: string | NodeArray; } export interface JSDocTag extends Node { readonly parent: JSDoc | JSDocTypeLiteral; readonly tagName: Identifier; - readonly comment?: string | NodeArray; + readonly comment?: string | NodeArray; } export interface JSDocLink extends Node { readonly kind: SyntaxKind.JSDocLink; - readonly name?: EntityName; + readonly name?: EntityName | JSDocMemberName; + text: string; + } + export interface JSDocLinkCode extends Node { + readonly kind: SyntaxKind.JSDocLinkCode; + readonly name?: EntityName | JSDocMemberName; text: string; } + export interface JSDocLinkPlain extends Node { + readonly kind: SyntaxKind.JSDocLinkPlain; + readonly name?: EntityName | JSDocMemberName; + text: string; + } + export type JSDocComment = JSDocText | JSDocLink | JSDocLinkCode | JSDocLinkPlain; export interface JSDocText extends Node { readonly kind: SyntaxKind.JSDocText; text: string; @@ -2170,6 +2198,7 @@ declare namespace ts { getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getPrivateIdentifierPropertyOfType(leftType: Type, name: string, location: Node): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; + getIndexInfosOfType(type: Type): readonly IndexInfo[]; getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; @@ -2186,7 +2215,7 @@ declare namespace ts { typeArguments?: NodeArray; } | undefined; /** Note that the resulting nodes cannot be checked. */ - indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): IndexSignatureDeclaration | undefined; + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): IndexSignatureDeclaration | undefined; /** Note that the resulting nodes cannot be checked. */ symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): EntityName | undefined; /** Note that the resulting nodes cannot be checked. */ @@ -2243,6 +2272,8 @@ declare namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName | ImportTypeNode, propertyName: string): boolean; /** Follow all aliases to get the original symbol. */ getAliasedSymbol(symbol: Symbol): Symbol; + /** Follow a *single* alias to get the immediately aliased symbol. */ + getImmediateAliasedSymbol(symbol: Symbol): Symbol | undefined; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; getJsxIntrinsicTagNamesAt(location: Node): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; @@ -2584,8 +2615,7 @@ declare namespace ts { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; - declaredStringIndexInfo?: IndexInfo; - declaredNumberIndexInfo?: IndexInfo; + declaredIndexInfos: IndexInfo[]; } /** * Type references (ObjectFlags.Reference). When a class or interface has type parameters or @@ -2699,6 +2729,7 @@ declare namespace ts { Number = 1 } export interface IndexInfo { + keyType: Type; type: Type; isReadonly: boolean; declaration?: IndexSignatureDeclaration; @@ -2831,6 +2862,7 @@ declare namespace ts { downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; + exactOptionalPropertyTypes?: boolean; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; importHelpers?: boolean; @@ -2896,6 +2928,7 @@ declare namespace ts { suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; traceResolution?: boolean; + useUnknownInCatchVariables?: boolean; resolveJsonModule?: boolean; types?: string[]; /** Paths used to compute primary types search locations */ @@ -3267,6 +3300,8 @@ declare namespace ts { updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; createTemplateLiteralTypeSpan(type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan; updateTemplateLiteralTypeSpan(node: TemplateLiteralTypeSpan, type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan; + createClassStaticBlockDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; + updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; createKeywordTypeNode(kind: TKind): KeywordTypeNode; createTypePredicateNode(assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; updateTypePredicateNode(node: TypePredicateNode, assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; @@ -3496,60 +3531,66 @@ declare namespace ts { updateJSDocNamepathType(node: JSDocNamepathType, type: TypeNode): JSDocNamepathType; createJSDocTypeExpression(type: TypeNode): JSDocTypeExpression; updateJSDocTypeExpression(node: JSDocTypeExpression, type: TypeNode): JSDocTypeExpression; - createJSDocNameReference(name: EntityName): JSDocNameReference; - updateJSDocNameReference(node: JSDocNameReference, name: EntityName): JSDocNameReference; - createJSDocLink(name: EntityName | undefined, text: string): JSDocLink; - updateJSDocLink(node: JSDocLink, name: EntityName | undefined, text: string): JSDocLink; + createJSDocNameReference(name: EntityName | JSDocMemberName): JSDocNameReference; + updateJSDocNameReference(node: JSDocNameReference, name: EntityName | JSDocMemberName): JSDocNameReference; + createJSDocMemberName(left: EntityName | JSDocMemberName, right: Identifier): JSDocMemberName; + updateJSDocMemberName(node: JSDocMemberName, left: EntityName | JSDocMemberName, right: Identifier): JSDocMemberName; + createJSDocLink(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLink; + updateJSDocLink(node: JSDocLink, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLink; + createJSDocLinkCode(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkCode; + updateJSDocLinkCode(node: JSDocLinkCode, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkCode; + createJSDocLinkPlain(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkPlain; + updateJSDocLinkPlain(node: JSDocLinkPlain, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkPlain; createJSDocTypeLiteral(jsDocPropertyTags?: readonly JSDocPropertyLikeTag[], isArrayType?: boolean): JSDocTypeLiteral; updateJSDocTypeLiteral(node: JSDocTypeLiteral, jsDocPropertyTags: readonly JSDocPropertyLikeTag[] | undefined, isArrayType: boolean | undefined): JSDocTypeLiteral; createJSDocSignature(typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag): JSDocSignature; updateJSDocSignature(node: JSDocSignature, typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type: JSDocReturnTag | undefined): JSDocSignature; - createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray): JSDocTemplateTag; - updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | NodeArray | undefined): JSDocTemplateTag; - createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocTypedefTag; - updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocTypedefTag; - createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocParameterTag; - updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocParameterTag; - createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocPropertyTag; - updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocPropertyTag; - createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocTypeTag; - updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocTypeTag; - createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; - updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; - createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string | NodeArray): JSDocReturnTag; - updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocReturnTag; - createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocThisTag; - updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocThisTag; - createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocEnumTag; - updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocEnumTag; - createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocCallbackTag; - updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocCallbackTag; - createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string | NodeArray): JSDocAugmentsTag; - updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | NodeArray | undefined): JSDocAugmentsTag; - createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string | NodeArray): JSDocImplementsTag; - updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | NodeArray | undefined): JSDocImplementsTag; - createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocAuthorTag; - updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocAuthorTag; - createJSDocClassTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocClassTag; - updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocClassTag; - createJSDocPublicTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPublicTag; - updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPublicTag; - createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPrivateTag; - updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPrivateTag; - createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocProtectedTag; - updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocProtectedTag; - createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocReadonlyTag; - updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocReadonlyTag; - createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray): JSDocUnknownTag; - updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray | undefined): JSDocUnknownTag; - createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; - updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; - createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; - updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray): JSDocTemplateTag; + updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | NodeArray | undefined): JSDocTemplateTag; + createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocTypedefTag; + updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocTypedefTag; + createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocParameterTag; + updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocParameterTag; + createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocPropertyTag; + updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocPropertyTag; + createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocTypeTag; + updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocTypeTag; + createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; + updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; + createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string | NodeArray): JSDocReturnTag; + updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocReturnTag; + createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocThisTag; + updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocThisTag; + createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocEnumTag; + updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocEnumTag; + createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocCallbackTag; + updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocCallbackTag; + createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string | NodeArray): JSDocAugmentsTag; + updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | NodeArray | undefined): JSDocAugmentsTag; + createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string | NodeArray): JSDocImplementsTag; + updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | NodeArray | undefined): JSDocImplementsTag; + createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocAuthorTag; + updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocAuthorTag; + createJSDocClassTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocClassTag; + updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocClassTag; + createJSDocPublicTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPublicTag; + updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPublicTag; + createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPrivateTag; + updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPrivateTag; + createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocProtectedTag; + updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocProtectedTag; + createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocReadonlyTag; + updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocReadonlyTag; + createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray): JSDocUnknownTag; + updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray | undefined): JSDocUnknownTag; + createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; createJSDocText(text: string): JSDocText; updateJSDocText(node: JSDocText, text: string): JSDocText; - createJSDocComment(comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc; - updateJSDocComment(node: JSDoc, comment: string | NodeArray | undefined, tags: readonly JSDocTag[] | undefined): JSDoc; + createJSDocComment(comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc; + updateJSDocComment(node: JSDoc, comment: string | NodeArray | undefined, tags: readonly JSDocTag[] | undefined): JSDoc; createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; @@ -3920,6 +3961,7 @@ declare namespace ts { readonly includeCompletionsWithSnippetText?: boolean; readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; + readonly allowIncompleteCompletions?: boolean; readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative"; /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ readonly importModuleSpecifierEnding?: "auto" | "minimal" | "index" | "js"; @@ -3951,6 +3993,7 @@ declare namespace ts { useCaseSensitiveFileNames: boolean; write(s: string): void; writeOutputIsTTY?(): boolean; + getWidthOfTerminal?(): number; readFile(path: string, encoding?: string): string | undefined; getFileSize?(path: string): number; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; @@ -4018,6 +4061,7 @@ declare namespace ts { reScanJsxAttributeValue(): SyntaxKind; reScanJsxToken(allowMultilineJsxText?: boolean): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; + reScanHashToken(): SyntaxKind; reScanQuestionToken(): SyntaxKind; reScanInvalidIdentifier(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; @@ -4236,7 +4280,7 @@ declare namespace ts { /** Gets all JSDoc tags of a specified kind */ function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; /** Gets the text of a jsdoc comment, flattening links to their text. */ - function getTextOfJSDocComment(comment?: string | NodeArray): string | undefined; + function getTextOfJSDocComment(comment?: string | NodeArray): string | undefined; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. @@ -4311,6 +4355,7 @@ declare namespace ts { function hasOnlyExpressionInitializer(node: Node): node is HasExpressionInitializer; function isObjectLiteralElement(node: Node): node is ObjectLiteralElement; function isStringLiteralLike(node: Node): node is StringLiteralLike; + function isJSDocLinkLike(node: Node): node is JSDocLink | JSDocLinkCode | JSDocLinkPlain; } declare namespace ts { const factory: NodeFactory; @@ -4421,6 +4466,7 @@ declare namespace ts { function isPropertyDeclaration(node: Node): node is PropertyDeclaration; function isMethodSignature(node: Node): node is MethodSignature; function isMethodDeclaration(node: Node): node is MethodDeclaration; + function isClassStaticBlockDeclaration(node: Node): node is ClassStaticBlockDeclaration; function isConstructorDeclaration(node: Node): node is ConstructorDeclaration; function isGetAccessorDeclaration(node: Node): node is GetAccessorDeclaration; function isSetAccessorDeclaration(node: Node): node is SetAccessorDeclaration; @@ -4556,7 +4602,10 @@ declare namespace ts { function isUnparsedSource(node: Node): node is UnparsedSource; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; function isJSDocNameReference(node: Node): node is JSDocNameReference; + function isJSDocMemberName(node: Node): node is JSDocMemberName; function isJSDocLink(node: Node): node is JSDocLink; + function isJSDocLinkCode(node: Node): node is JSDocLinkCode; + function isJSDocLinkPlain(node: Node): node is JSDocLinkPlain; function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; @@ -5205,6 +5254,7 @@ declare namespace ts { * writeFileCallback */ writeFile?(path: string, data: string, writeByteOrderMark?: boolean): void; + getCustomTransformers?: (project: string) => CustomTransformers | undefined; getModifiedTime(fileName: string): Date | undefined; setModifiedTime(fileName: string, date: Date): void; deleteFile(fileName: string): void; @@ -5477,6 +5527,11 @@ declare namespace ts { PartialSemantic = 1, Syntactic = 2 } + interface IncompleteCompletionsCache { + get(): CompletionInfo | undefined; + set(response: CompletionInfo): void; + clear(): void; + } interface LanguageServiceHost extends GetEffectiveTypeRootsHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; @@ -5638,6 +5693,7 @@ declare namespace ts { prepareCallHierarchy(fileName: string, position: number): CallHierarchyItem | CallHierarchyItem[] | undefined; provideCallHierarchyIncomingCalls(fileName: string, position: number): CallHierarchyIncomingCall[]; provideCallHierarchyOutgoingCalls(fileName: string, position: number): CallHierarchyOutgoingCall[]; + provideInlayHints(fileName: string, span: TextSpan, preferences: UserPreferences | undefined): InlayHint[]; getOutliningSpans(fileName: string): OutliningSpan[]; getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]; @@ -5688,17 +5744,35 @@ declare namespace ts { skipDestructiveCodeActions?: boolean; } type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " "; + enum CompletionTriggerKind { + /** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */ + Invoked = 1, + /** Completion was triggered by a trigger character. */ + TriggerCharacter = 2, + /** Completion was re-triggered as the current completion list is incomplete. */ + TriggerForIncompleteCompletions = 3 + } interface GetCompletionsAtPositionOptions extends UserPreferences { /** * If the editor is asking for completions because a certain character was typed * (as opposed to when the user explicitly requested them) this should be set. */ triggerCharacter?: CompletionsTriggerCharacter; + triggerKind?: CompletionTriggerKind; /** @deprecated Use includeCompletionsForModuleExports */ includeExternalModuleExports?: boolean; /** @deprecated Use includeCompletionsWithInsertText */ includeInsertTextCompletions?: boolean; } + interface InlayHintsOptions extends UserPreferences { + readonly includeInlayParameterNameHints?: "none" | "literals" | "all"; + readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean; + readonly includeInlayFunctionParameterTypeHints?: boolean; + readonly includeInlayVariableTypeHints?: boolean; + readonly includeInlayPropertyDeclarationTypeHints?: boolean; + readonly includeInlayFunctionLikeReturnTypeHints?: boolean; + readonly includeInlayEnumMemberValueHints?: boolean; + } type SignatureHelpTriggerCharacter = "," | "(" | "<"; type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; interface SignatureHelpItemsOptions { @@ -5804,6 +5878,18 @@ declare namespace ts { to: CallHierarchyItem; fromSpans: TextSpan[]; } + enum InlayHintKind { + Type = "Type", + Parameter = "Parameter", + Enum = "Enum" + } + interface InlayHint { + text: string; + position: number; + kind: InlayHintKind; + whitespaceBefore?: boolean; + whitespaceAfter?: boolean; + } interface TodoCommentDescriptor { text: string; priority: number; @@ -6367,7 +6453,10 @@ declare namespace ts { * interface Y { foo:number; } */ memberVariableElement = "property", - /** class X { constructor() { } } */ + /** + * class X { constructor() { } } + * class X { static { } } + */ constructorImplementationElement = "constructor", /** interface Y { ():number; } */ callSignatureElement = "call", @@ -6469,6 +6558,14 @@ declare namespace ts { jsxAttributeStringLiteralValue = 24, bigintLiteral = 25 } + interface InlayHintsContext { + file: SourceFile; + program: Program; + cancellationToken: CancellationToken; + host: LanguageServiceHost; + span: TextSpan; + preferences: InlayHintsOptions; + } } declare namespace ts { /** The classifier is used for syntactic highlighting in editors via the TSServer */ @@ -7072,51 +7169,51 @@ declare namespace ts { /** @deprecated Use `factory.createJSDocTypeExpression` or the factory supplied by your transformation context instead. */ const createJSDocTypeExpression: (type: TypeNode) => JSDocTypeExpression; /** @deprecated Use `factory.createJSDocTypeTag` or the factory supplied by your transformation context instead. */ - const createJSDocTypeTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocTypeTag; + const createJSDocTypeTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocTypeTag; /** @deprecated Use `factory.createJSDocReturnTag` or the factory supplied by your transformation context instead. */ - const createJSDocReturnTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | undefined, comment?: string | NodeArray | undefined) => JSDocReturnTag; + const createJSDocReturnTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | undefined, comment?: string | NodeArray | undefined) => JSDocReturnTag; /** @deprecated Use `factory.createJSDocThisTag` or the factory supplied by your transformation context instead. */ - const createJSDocThisTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocThisTag; + const createJSDocThisTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocThisTag; /** @deprecated Use `factory.createJSDocComment` or the factory supplied by your transformation context instead. */ - const createJSDocComment: (comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined) => JSDoc; + const createJSDocComment: (comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined) => JSDoc; /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ - const createJSDocParameterTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocParameterTag; + const createJSDocParameterTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocParameterTag; /** @deprecated Use `factory.createJSDocClassTag` or the factory supplied by your transformation context instead. */ - const createJSDocClassTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocClassTag; + const createJSDocClassTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocClassTag; /** @deprecated Use `factory.createJSDocAugmentsTag` or the factory supplied by your transformation context instead. */ const createJSDocAugmentsTag: (tagName: Identifier | undefined, className: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression; - }, comment?: string | NodeArray | undefined) => JSDocAugmentsTag; + }, comment?: string | NodeArray | undefined) => JSDocAugmentsTag; /** @deprecated Use `factory.createJSDocEnumTag` or the factory supplied by your transformation context instead. */ - const createJSDocEnumTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocEnumTag; + const createJSDocEnumTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocEnumTag; /** @deprecated Use `factory.createJSDocTemplateTag` or the factory supplied by your transformation context instead. */ - const createJSDocTemplateTag: (tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray | undefined) => JSDocTemplateTag; + const createJSDocTemplateTag: (tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray | undefined) => JSDocTemplateTag; /** @deprecated Use `factory.createJSDocTypedefTag` or the factory supplied by your transformation context instead. */ - const createJSDocTypedefTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeLiteral | JSDocTypeExpression | undefined, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocTypedefTag; + const createJSDocTypedefTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeLiteral | JSDocTypeExpression | undefined, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocTypedefTag; /** @deprecated Use `factory.createJSDocCallbackTag` or the factory supplied by your transformation context instead. */ - const createJSDocCallbackTag: (tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocCallbackTag; + const createJSDocCallbackTag: (tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocCallbackTag; /** @deprecated Use `factory.createJSDocSignature` or the factory supplied by your transformation context instead. */ const createJSDocSignature: (typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag | undefined) => JSDocSignature; /** @deprecated Use `factory.createJSDocPropertyTag` or the factory supplied by your transformation context instead. */ - const createJSDocPropertyTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocPropertyTag; + const createJSDocPropertyTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocPropertyTag; /** @deprecated Use `factory.createJSDocTypeLiteral` or the factory supplied by your transformation context instead. */ const createJSDocTypeLiteral: (jsDocPropertyTags?: readonly JSDocPropertyLikeTag[] | undefined, isArrayType?: boolean | undefined) => JSDocTypeLiteral; /** @deprecated Use `factory.createJSDocImplementsTag` or the factory supplied by your transformation context instead. */ const createJSDocImplementsTag: (tagName: Identifier | undefined, className: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression; - }, comment?: string | NodeArray | undefined) => JSDocImplementsTag; + }, comment?: string | NodeArray | undefined) => JSDocImplementsTag; /** @deprecated Use `factory.createJSDocAuthorTag` or the factory supplied by your transformation context instead. */ - const createJSDocAuthorTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocAuthorTag; + const createJSDocAuthorTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocAuthorTag; /** @deprecated Use `factory.createJSDocPublicTag` or the factory supplied by your transformation context instead. */ - const createJSDocPublicTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPublicTag; + const createJSDocPublicTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPublicTag; /** @deprecated Use `factory.createJSDocPrivateTag` or the factory supplied by your transformation context instead. */ - const createJSDocPrivateTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPrivateTag; + const createJSDocPrivateTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPrivateTag; /** @deprecated Use `factory.createJSDocProtectedTag` or the factory supplied by your transformation context instead. */ - const createJSDocProtectedTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocProtectedTag; + const createJSDocProtectedTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocProtectedTag; /** @deprecated Use `factory.createJSDocReadonlyTag` or the factory supplied by your transformation context instead. */ - const createJSDocReadonlyTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocReadonlyTag; + const createJSDocReadonlyTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocReadonlyTag; /** @deprecated Use `factory.createJSDocUnknownTag` or the factory supplied by your transformation context instead. */ - const createJSDocTag: (tagName: Identifier, comment?: string | NodeArray | undefined) => JSDocUnknownTag; + const createJSDocTag: (tagName: Identifier, comment?: string | NodeArray | undefined) => JSDocUnknownTag; /** @deprecated Use `factory.createJsxElement` or the factory supplied by your transformation context instead. */ const createJsxElement: (openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement) => JsxElement; /** @deprecated Use `factory.updateJsxElement` or the factory supplied by your transformation context instead. */ diff --git a/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.js b/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.js index 615ad27f3f7d..ebd4c15a2a6a 100644 --- a/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.js +++ b/packages/schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript.js @@ -14,10 +14,14 @@ and limitations under the License. ***************************************************************************** */ "use strict"; -var __spreadArray = (this && this.__spreadArray) || function (to, from) { - for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) - to[j] = from[i]; - return to; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -286,11 +290,11 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "4.3"; + ts.versionMajorMinor = "4.4"; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "4.3.2"; + ts.version = "4.4.3"; /* @internal */ var Comparison; (function (Comparison) { @@ -975,7 +979,7 @@ var ts; return array1; if (!some(array1)) return array2; - return __spreadArray(__spreadArray([], array1), array2); + return __spreadArray(__spreadArray([], array1, true), array2, true); } ts.concatenate = concatenate; function selectIndex(_, i) { @@ -2133,10 +2137,46 @@ var ts; * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ function removeMinAndVersionNumbers(fileName) { - // Match a "." or "-" followed by a version number or 'min' at the end of the name - var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/; - // The "min" or version may both be present, in either order, so try applying the above twice. - return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, ""); + // We used to use the regex /[.-]((min)|(\d+(\.\d+)*))$/ and would just .replace it twice. + // Unfortunately, that regex has O(n^2) performance because v8 doesn't match from the end of the string. + // Instead, we now essentially scan the filename (backwards) ourselves. + var end = fileName.length; + for (var pos = end - 1; pos > 0; pos--) { + var ch = fileName.charCodeAt(pos); + if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + // Match a \d+ segment + do { + --pos; + ch = fileName.charCodeAt(pos); + } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } + else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + // Looking for "min" or "min" + // Already matched the 'n' + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 105 /* i */ && ch !== 73 /* I */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 109 /* m */ && ch !== 77 /* M */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + } + else { + // This character is not part of either suffix pattern + break; + } + if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + break; + } + end = pos; + } + // end might be fileName.length, in which case this should internally no-op + return end === fileName.length ? fileName : fileName.slice(0, end); } ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers; /** Remove an item from an array, moving everything to its right one space left. */ @@ -2377,6 +2417,33 @@ var ts; return array.slice(0, index); } ts.takeWhile = takeWhile; + /** + * Removes the leading and trailing white space and line terminator characters from a string. + */ + ts.trimString = !!String.prototype.trim ? (function (s) { return s.trim(); }) : function (s) { return ts.trimStringEnd(ts.trimStringStart(s)); }; + /** + * Returns a copy with trailing whitespace removed. + */ + ts.trimStringEnd = !!String.prototype.trimEnd ? (function (s) { return s.trimEnd(); }) : trimEndImpl; + /** + * Returns a copy with leading whitespace removed. + */ + ts.trimStringStart = !!String.prototype.trimStart ? (function (s) { return s.trimStart(); }) : function (s) { return s.replace(/^\s+/g, ""); }; + /** + * https://jsbench.me/gjkoxld4au/1 + * The simple regex for this, /\s+$/g is O(n^2) in v8. + * The native .trimEnd method is by far best, but since that's technically ES2019, + * we provide a (still much faster than the simple regex) fallback. + */ + function trimEndImpl(s) { + var end = s.length - 1; + while (end >= 0) { + if (!ts.isWhiteSpaceLike(s.charCodeAt(end))) + break; + end--; + } + return s.slice(0, end + 1); + } })(ts || (ts = {})); /* @internal */ var ts; @@ -2566,7 +2633,7 @@ var ts; Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { if (shouldAssertFunction(1 /* Normal */, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; @@ -2578,13 +2645,13 @@ var ts; Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; @@ -2773,6 +2840,9 @@ var ts; // An `Array` with extra properties is rendered as `[A, B, prop1: 1, prop2: 2]`. Most of // these aren't immediately useful so we trim off the `prop1: ..., prop2: ...` part from the // formatted string. + // This regex can trigger slow backtracking because of overlapping potential captures. + // We don't care, this is debug code that's only enabled with a debugger attached - + // we're just taking note of it for anyone checking regex performance in the future. defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); return "NodeArray " + defaultValue; } @@ -3221,7 +3291,7 @@ var ts; // range-set ::= range ( logical-or range ) * // range ::= hyphen | simple ( ' ' simple ) * | '' // logical-or ::= ( ' ' ) * '||' ( ' ' ) * - var logicalOrRegExp = /\s*\|\|\s*/g; + var logicalOrRegExp = /\|\|/g; var whitespaceRegExp = /\s+/g; // https://github.com/npm/node-semver#range-grammar // @@ -3244,14 +3314,15 @@ var ts; // primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial // tilde ::= '~' partial // caret ::= '^' partial - var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; + var rangeRegExp = /^(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; function parseRange(text) { var alternatives = []; - for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.trimString(text).split(logicalOrRegExp); _i < _a.length; _i++) { var range = _a[_i]; if (!range) continue; var comparators = []; + range = ts.trimString(range); var match = hyphenRegExp.exec(range); if (match) { if (!parseHyphen(match[1], match[2], comparators)) @@ -3260,7 +3331,7 @@ var ts; else { for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) { var simple = _c[_b]; - var match_1 = rangeRegExp.exec(simple); + var match_1 = rangeRegExp.exec(ts.trimString(simple)); if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators)) return undefined; } @@ -4007,332 +4078,338 @@ var ts; SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; + /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ + SyntaxKind[SyntaxKind["HashToken"] = 62] = "HashToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 74] = "BarBarEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 75] = "AmpersandAmpersandEqualsToken"; - SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 76] = "QuestionQuestionEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 77] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 63] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 64] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 65] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 66] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 67] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 68] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 69] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 70] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 72] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 73] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 74] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 75] = "BarBarEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 76] = "AmpersandAmpersandEqualsToken"; + SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 77] = "QuestionQuestionEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 78] = "CaretEqualsToken"; // Identifiers and PrivateIdentifiers - SyntaxKind[SyntaxKind["Identifier"] = 78] = "Identifier"; - SyntaxKind[SyntaxKind["PrivateIdentifier"] = 79] = "PrivateIdentifier"; + SyntaxKind[SyntaxKind["Identifier"] = 79] = "Identifier"; + SyntaxKind[SyntaxKind["PrivateIdentifier"] = 80] = "PrivateIdentifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 80] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 81] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 82] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 83] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 84] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 85] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 86] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 87] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 88] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 89] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 90] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 91] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 92] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 93] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 94] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 95] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 96] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 97] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 98] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 99] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 100] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 101] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 102] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 103] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 104] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 105] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 106] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 107] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 108] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 109] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 110] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 111] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 112] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 113] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 114] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 115] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 81] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 82] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 83] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 84] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 85] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 86] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 87] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 88] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 89] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 90] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 91] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 92] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 93] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 94] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 95] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 96] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 97] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 98] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 99] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 100] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 101] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 102] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 103] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 104] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 105] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 106] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 107] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 108] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 109] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 110] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 111] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 112] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 113] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 114] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 115] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 116] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 116] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 117] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 118] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 119] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 120] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 121] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 122] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 123] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 124] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 117] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 118] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 119] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 120] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 121] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 122] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 123] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 124] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 125] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 125] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 126] = "AsKeyword"; - SyntaxKind[SyntaxKind["AssertsKeyword"] = 127] = "AssertsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 128] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 129] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 130] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 131] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 132] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 133] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 134] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 135] = "InferKeyword"; - SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 136] = "IntrinsicKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 137] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 138] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 139] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 140] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 141] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 142] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 143] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 144] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 145] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 146] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 147] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 148] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 149] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 150] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 151] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 152] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 153] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 154] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 155] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OverrideKeyword"] = 156] = "OverrideKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 157] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 126] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 127] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 128] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 129] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 130] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 131] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 132] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 133] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 134] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 135] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 136] = "InferKeyword"; + SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 137] = "IntrinsicKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 138] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 139] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 140] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 141] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 142] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 143] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 144] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 145] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 146] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 147] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 148] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 149] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 150] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 151] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 152] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 153] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 154] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 155] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 156] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OverrideKeyword"] = 157] = "OverrideKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 158] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 158] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 159] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 159] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 160] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 160] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 161] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 162] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 161] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 162] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 163] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 163] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 164] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 165] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 166] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 167] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 168] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 169] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 170] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 171] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 172] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 164] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 165] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 166] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 167] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["ClassStaticBlockDeclaration"] = 168] = "ClassStaticBlockDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 169] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 170] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 171] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 172] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 173] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 174] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 173] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 174] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 175] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 176] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 177] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 178] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 179] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 180] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 181] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 182] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 183] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 184] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 185] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 186] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 187] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 188] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 189] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 190] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 191] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 192] = "LiteralType"; - SyntaxKind[SyntaxKind["NamedTupleMember"] = 193] = "NamedTupleMember"; - SyntaxKind[SyntaxKind["TemplateLiteralType"] = 194] = "TemplateLiteralType"; - SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 195] = "TemplateLiteralTypeSpan"; - SyntaxKind[SyntaxKind["ImportType"] = 196] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 175] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 176] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 177] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 178] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 179] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 180] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 181] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 182] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 183] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 184] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 185] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 186] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 187] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 188] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 189] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 190] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 191] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 192] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 193] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 194] = "LiteralType"; + SyntaxKind[SyntaxKind["NamedTupleMember"] = 195] = "NamedTupleMember"; + SyntaxKind[SyntaxKind["TemplateLiteralType"] = 196] = "TemplateLiteralType"; + SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 197] = "TemplateLiteralTypeSpan"; + SyntaxKind[SyntaxKind["ImportType"] = 198] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 197] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 198] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 199] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 199] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 200] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 201] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 200] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 201] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 202] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 203] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 204] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 205] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 206] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 207] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 208] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 209] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 210] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 211] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 212] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 213] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 214] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 215] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 216] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 217] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 218] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 219] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 220] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 221] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 222] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 224] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 225] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 226] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 227] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 228] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 202] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 203] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 204] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 205] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 206] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 207] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 208] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 209] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 210] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 211] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 212] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 213] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 214] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 215] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 216] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 217] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 218] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 219] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 220] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 221] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 222] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 223] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 224] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 225] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 226] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 227] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 228] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 229] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 230] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 229] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 230] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 231] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 232] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 231] = "Block"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 232] = "EmptyStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 233] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 234] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 235] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 236] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 237] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 238] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 239] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 240] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 241] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 242] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 243] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 244] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 245] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 246] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 247] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 248] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 249] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 250] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 251] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 252] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 253] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 254] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 255] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 256] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 257] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 258] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 259] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 260] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 261] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 262] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 263] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 264] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 265] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 266] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 267] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 268] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 269] = "NamedExports"; - SyntaxKind[SyntaxKind["NamespaceExport"] = 270] = "NamespaceExport"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 271] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 272] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 233] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 234] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 235] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 236] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 237] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 238] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 239] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 240] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 241] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 242] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 243] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 244] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 245] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 246] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 247] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 248] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 249] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 250] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 251] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 252] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 253] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 254] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 255] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 256] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 257] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 258] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 259] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 260] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 261] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 262] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 263] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 264] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 265] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 266] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 267] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 268] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 269] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 270] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 271] = "NamedExports"; + SyntaxKind[SyntaxKind["NamespaceExport"] = 272] = "NamespaceExport"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 273] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 274] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 273] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 275] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 274] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 275] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 276] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 277] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 278] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 279] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 280] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 281] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 282] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 283] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 284] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 276] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 277] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 278] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 279] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 280] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 281] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 282] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 283] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 284] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 285] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 286] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 285] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 286] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 287] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 288] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 287] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 288] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 289] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 290] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 289] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 290] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 291] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 291] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 292] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 293] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 292] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 294] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 293] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 294] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 295] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 296] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 297] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 295] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 296] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 297] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 298] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 299] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 298] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 299] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 300] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 301] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 300] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 301] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 302] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 303] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 302] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocNameReference"] = 303] = "JSDocNameReference"; - SyntaxKind[SyntaxKind["JSDocAllType"] = 304] = "JSDocAllType"; - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 305] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 306] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 307] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 308] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 309] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 310] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 311] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 312] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocText"] = 313] = "JSDocText"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 314] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 315] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocLink"] = 316] = "JSDocLink"; - SyntaxKind[SyntaxKind["JSDocTag"] = 317] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 318] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 319] = "JSDocImplementsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 320] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 321] = "JSDocDeprecatedTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 322] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocPublicTag"] = 323] = "JSDocPublicTag"; - SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 324] = "JSDocPrivateTag"; - SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 325] = "JSDocProtectedTag"; - SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 326] = "JSDocReadonlyTag"; - SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 327] = "JSDocOverrideTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 328] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 329] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 330] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 331] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 332] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 333] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 334] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 335] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocSeeTag"] = 336] = "JSDocSeeTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 337] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 304] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocNameReference"] = 305] = "JSDocNameReference"; + SyntaxKind[SyntaxKind["JSDocMemberName"] = 306] = "JSDocMemberName"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 307] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 308] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 309] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 310] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 311] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 312] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 313] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 314] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 315] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocText"] = 316] = "JSDocText"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 317] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 318] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocLink"] = 319] = "JSDocLink"; + SyntaxKind[SyntaxKind["JSDocLinkCode"] = 320] = "JSDocLinkCode"; + SyntaxKind[SyntaxKind["JSDocLinkPlain"] = 321] = "JSDocLinkPlain"; + SyntaxKind[SyntaxKind["JSDocTag"] = 322] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 323] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 324] = "JSDocImplementsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 325] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 326] = "JSDocDeprecatedTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 327] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocPublicTag"] = 328] = "JSDocPublicTag"; + SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 329] = "JSDocPrivateTag"; + SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 330] = "JSDocProtectedTag"; + SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 331] = "JSDocReadonlyTag"; + SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 332] = "JSDocOverrideTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 333] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 334] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 335] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 336] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 337] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 338] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 339] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 340] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocSeeTag"] = 341] = "JSDocSeeTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 342] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 338] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 343] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 339] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 340] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 341] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 342] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 343] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 344] = "SyntheticReferenceExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 344] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 345] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 346] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 347] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 348] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 349] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 345] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 350] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 77] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 77] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 80] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 115] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 80] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 157] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 116] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 124] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 173] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 196] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 63] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 78] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 64] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 78] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 81] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 116] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 81] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 158] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 117] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 125] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 175] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 198] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 77] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 78] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 157] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 158] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -4340,16 +4417,16 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 77] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstStatement"] = 233] = "FirstStatement"; - SyntaxKind[SyntaxKind["LastStatement"] = 249] = "LastStatement"; - SyntaxKind[SyntaxKind["FirstNode"] = 158] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 302] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 337] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 317] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 337] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 125] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 157] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 78] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 235] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 251] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 159] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 304] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 342] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 322] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 342] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 158] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -4888,6 +4965,7 @@ var ts; NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 16777216] = "ClassWithConstructorReference"; NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 33554432] = "ConstructorReferenceInClass"; NodeCheckFlags[NodeCheckFlags["ContainsClassWithPrivateIdentifiers"] = 67108864] = "ContainsClassWithPrivateIdentifiers"; + NodeCheckFlags[NodeCheckFlags["ContainsSuperPropertyInStaticInitializer"] = 134217728] = "ContainsSuperPropertyInStaticInitializer"; })(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); var TypeFlags; (function (TypeFlags) { @@ -4957,7 +5035,7 @@ var ts; /* @internal */ TypeFlags[TypeFlags["Simplifiable"] = 25165824] = "Simplifiable"; /* @internal */ - TypeFlags[TypeFlags["Substructure"] = 469237760] = "Substructure"; + TypeFlags[TypeFlags["Singleton"] = 67358815] = "Singleton"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never TypeFlags[TypeFlags["Narrowable"] = 536624127] = "Narrowable"; @@ -5029,21 +5107,21 @@ var ts; ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists"; // Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; + ObjectFlags[ObjectFlags["IsGenericTypeComputed"] = 4194304] = "IsGenericTypeComputed"; /* @internal */ ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; + ObjectFlags[ObjectFlags["IsGenericIndexType"] = 16777216] = "IsGenericIndexType"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + ObjectFlags[ObjectFlags["IsGenericType"] = 25165824] = "IsGenericType"; // Flags that require TypeFlags.Union /* @internal */ - ObjectFlags[ObjectFlags["ContainsIntersections"] = 67108864] = "ContainsIntersections"; + ObjectFlags[ObjectFlags["ContainsIntersections"] = 33554432] = "ContainsIntersections"; // Flags that require TypeFlags.Intersection /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 67108864] = "IsNeverIntersectionComputed"; + ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 33554432] = "IsNeverIntersectionComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersection"] = 134217728] = "IsNeverIntersection"; + ObjectFlags[ObjectFlags["IsNeverIntersection"] = 67108864] = "IsNeverIntersection"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ var VarianceFlags; @@ -5070,6 +5148,21 @@ var ts; ElementFlags[ElementFlags["NonRest"] = 11] = "NonRest"; })(ElementFlags = ts.ElementFlags || (ts.ElementFlags = {})); /* @internal */ + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["IncludeUndefined"] = 1] = "IncludeUndefined"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 2] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 4] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 8] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 16] = "NoTupleBoundsCheck"; + AccessFlags[AccessFlags["ExpressionPosition"] = 32] = "ExpressionPosition"; + AccessFlags[AccessFlags["ReportDeprecated"] = 64] = "ReportDeprecated"; + AccessFlags[AccessFlags["SuppressNoImplicitAnyError"] = 128] = "SuppressNoImplicitAnyError"; + AccessFlags[AccessFlags["Contextual"] = 256] = "Contextual"; + AccessFlags[AccessFlags["Persistent"] = 1] = "Persistent"; + })(AccessFlags = ts.AccessFlags || (ts.AccessFlags = {})); + /* @internal */ var JsxReferenceKind; (function (JsxReferenceKind) { JsxReferenceKind[JsxReferenceKind["Component"] = 0] = "Component"; @@ -5469,6 +5562,8 @@ var ts; TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport"; TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields"; TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait"; + TransformFlags[TransformFlags["ContainsLexicalSuper"] = 33554432] = "ContainsLexicalSuper"; + TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 67108864] = "ContainsUpdateExpressionForIdentifier"; // Please leave this as 1 << 29. // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. // It is a good reminder of how much room we have left @@ -5494,12 +5589,12 @@ var ts; TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes"; TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes"; TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 557756416] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 557752320] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 540975104] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 536879104] = "PropertyExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 591310848] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591306752] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 574529536] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = 570433536] = "PropertyExcludes"; TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 555888640] = "ModuleExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 589443072] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes"; TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes"; @@ -5507,9 +5602,10 @@ var ts; TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes"; TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 33562624] = "ContainsLexicalThisOrSuper"; // Propagating flags // - Bitmasks for flags that should propagate from a child - TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 8192] = "PropertyNamePropagatingFlags"; + TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 33562624] = "PropertyNamePropagatingFlags"; // Masks // - Additional bitmasks })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); @@ -5547,6 +5643,8 @@ var ts; /*@internal*/ EmitFlags[EmitFlags["TypeScriptClassWrapper"] = 33554432] = "TypeScriptClassWrapper"; /*@internal*/ EmitFlags[EmitFlags["NeverApplyImportHelper"] = 67108864] = "NeverApplyImportHelper"; /*@internal*/ EmitFlags[EmitFlags["IgnoreSourceNewlines"] = 134217728] = "IgnoreSourceNewlines"; + /*@internal*/ EmitFlags[EmitFlags["Immutable"] = 268435456] = "Immutable"; + /*@internal*/ EmitFlags[EmitFlags["IndirectCall"] = 536870912] = "IndirectCall"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); /** * Used by the checker, this enum keeps track of external emit helpers that should be type @@ -6048,7 +6146,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return __spreadArray([root], rest); + return __spreadArray([root], rest, true); } /** * Parse a path into an array containing a root component (at index 0) and zero or more path @@ -6107,6 +6205,11 @@ var ts; * Normalize path separators, converting `\` into `/`. */ function normalizeSlashes(path) { + var index = path.indexOf("\\"); + if (index === -1) { + return path; + } + backslashRegExp.lastIndex = index; // prime regex with known position return path.replace(backslashRegExp, ts.directorySeparator); } ts.normalizeSlashes = normalizeSlashes; @@ -6194,7 +6297,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths)) : normalizeSlashes(path)); + return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path)); } ts.resolvePath = resolvePath; /** @@ -6217,6 +6320,19 @@ var ts; ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; function normalizePath(path) { path = normalizeSlashes(path); + // Most paths don't require normalization + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + // Some paths only require cleanup of `/./` or leading `./` + var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, ""); + if (simplified !== path) { + path = simplified; + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + } + // Other paths require full normalization var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -6285,7 +6401,7 @@ var ts; ts.changeAnyExtension = changeAnyExtension; //// Path Comparisons // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) return 0 /* EqualTo */; @@ -6405,7 +6521,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return __spreadArray(__spreadArray([""], relative), components); + return __spreadArray(__spreadArray([""], relative, true), components, true); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { @@ -7300,6 +7416,7 @@ var ts; } var activeSession; var profilePath = "./profile.cpuprofile"; + var hitSystemWatcherLimit = false; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; @@ -7336,6 +7453,9 @@ var ts; write: function (s) { process.stdout.write(s); }, + getWidthOfTerminal: function () { + return process.stdout.columns; + }, writeOutputIsTTY: function () { return process.stdout.isTTY; }, @@ -7625,6 +7745,10 @@ var ts; options = { persistent: true }; } } + if (hitSystemWatcherLimit) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile"); + return watchPresentFileSystemEntryWithFsWatchFile(); + } try { var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? callbackChangingToMissingFileSystemEntry : @@ -7637,6 +7761,8 @@ var ts; // Catch the exception and use polling instead // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile + hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -7656,7 +7782,6 @@ var ts; * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile() { - ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions); } /** @@ -7775,7 +7900,7 @@ var ts; } } function readDirectory(path, extensions, excludes, includes, depth) { - return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath); + return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath, directoryExists); } function fileSystemEntryExists(path, entryKind) { // Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve @@ -7898,7 +8023,6 @@ var ts; An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), - An_index_signature_parameter_type_must_be_either_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_either_string_or_number_1023", "An index signature parameter type must be either 'string' or 'number'."), readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), An_index_signature_cannot_have_a_trailing_comma: diag(1025, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_trailing_comma_1025", "An index signature cannot have a trailing comma."), Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), @@ -7959,6 +8083,7 @@ var ts; for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1103, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1103", "'for await' loops are only allowed within async functions and at the top levels of modules."), A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + The_left_hand_side_of_a_for_of_statement_may_not_be_async: diag(1106, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_async_1106", "The left-hand side of a 'for...of' statement may not be 'async'."), Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), @@ -8045,7 +8170,7 @@ var ts; Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), _0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module: diag(1208, ts.DiagnosticCategory.Error, "_0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_imp_1208", "'{0}' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module."), - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), + Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode: diag(1210, ts.DiagnosticCategory.Error, "Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of__1210", "Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of '{0}'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode."), A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), @@ -8100,6 +8225,8 @@ var ts; Declarations_with_definite_assignment_assertions_must_also_have_type_annotations: diag(1264, ts.DiagnosticCategory.Error, "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264", "Declarations with definite assignment assertions must also have type annotations."), A_rest_element_cannot_follow_another_rest_element: diag(1265, ts.DiagnosticCategory.Error, "A_rest_element_cannot_follow_another_rest_element_1265", "A rest element cannot follow another rest element."), An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."), + Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."), + An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), @@ -8126,8 +8253,7 @@ var ts; unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), - An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), - An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), + An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337", "An index signature parameter type cannot be a literal type or generic type. Consider using a mapped object type instead."), infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), @@ -8157,7 +8283,6 @@ var ts; Convert_all_re_exported_types_to_type_only_exports: diag(1365, ts.DiagnosticCategory.Message, "Convert_all_re_exported_types_to_type_only_exports_1365", "Convert all re-exported types to type-only exports"), Split_into_two_separate_import_declarations: diag(1366, ts.DiagnosticCategory.Message, "Split_into_two_separate_import_declarations_1366", "Split into two separate import declarations"), Split_all_invalid_type_only_imports: diag(1367, ts.DiagnosticCategory.Message, "Split_all_invalid_type_only_imports_1367", "Split all invalid type-only imports"), - Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(1368, ts.DiagnosticCategory.Message, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_1368", "Specify emit/checking behavior for imports that are only used for types"), Did_you_mean_0: diag(1369, ts.DiagnosticCategory.Message, "Did_you_mean_0_1369", "Did you mean '{0}'?"), This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set_to_error: diag(1371, ts.DiagnosticCategory.Error, "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371", "This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'."), Convert_to_type_only_import: diag(1373, ts.DiagnosticCategory.Message, "Convert_to_type_only_import_1373", "Convert to type-only import"), @@ -8221,6 +8346,16 @@ var ts; for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), + Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."), + Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, ts.DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"), + Decorators_must_precede_the_name_and_all_keywords_of_property_declarations: diag(1436, ts.DiagnosticCategory.Error, "Decorators_must_precede_the_name_and_all_keywords_of_property_declarations_1436", "Decorators must precede the name and all keywords of property declarations."), + Namespace_must_be_given_a_name: diag(1437, ts.DiagnosticCategory.Error, "Namespace_must_be_given_a_name_1437", "Namespace must be given a name."), + Interface_must_be_given_a_name: diag(1438, ts.DiagnosticCategory.Error, "Interface_must_be_given_a_name_1438", "Interface must be given a name."), + Type_alias_must_be_given_a_name: diag(1439, ts.DiagnosticCategory.Error, "Type_alias_must_be_given_a_name_1439", "Type alias must be given a name."), + Variable_declaration_not_allowed_at_this_location: diag(1440, ts.DiagnosticCategory.Error, "Variable_declaration_not_allowed_at_this_location_1440", "Variable declaration not allowed at this location."), + Cannot_start_a_function_call_in_a_type_annotation: diag(1441, ts.DiagnosticCategory.Error, "Cannot_start_a_function_call_in_a_type_annotation_1441", "Cannot start a function call in a type annotation."), + Expected_for_property_initializer: diag(1442, ts.DiagnosticCategory.Error, "Expected_for_property_initializer_1442", "Expected '=' for property initializer."), + Module_declaration_names_may_only_use_or_quoted_strings: diag(1443, ts.DiagnosticCategory.Error, "Module_declaration_names_may_only_use_or_quoted_strings_1443", "Module declaration names may only use ' or \" quoted strings."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -8256,8 +8391,8 @@ var ts; Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), - Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), - Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), + Index_signature_for_type_0_is_missing_in_type_1: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_for_type_0_is_missing_in_type_1_2329", "Index signature for type '{0}' is missing in type '{1}'."), + _0_and_1_index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "_0_and_1_index_signatures_are_incompatible_2330", "'{0}' and '{1}' index signatures are incompatible."), this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), @@ -8301,8 +8436,7 @@ var ts; A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: diag(2371, ts.DiagnosticCategory.Error, "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", "A parameter initializer is only allowed in a function or constructor implementation."), Parameter_0_cannot_reference_itself: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_itself_2372", "Parameter '{0}' cannot reference itself."), Parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Parameter '{0}' cannot reference identifier '{1}' declared after it."), - Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."), - Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."), + Duplicate_index_signature_for_type_0: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_index_signature_for_type_0_2374", "Duplicate index signature for type '{0}'."), A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers."), Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), @@ -8337,9 +8471,8 @@ var ts; Setters_cannot_return_a_value: diag(2408, ts.DiagnosticCategory.Error, "Setters_cannot_return_a_value_2408", "Setters cannot return a value."), Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: diag(2409, ts.DiagnosticCategory.Error, "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", "Return type of constructor signature must be assignable to the instance type of the class."), The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: diag(2410, ts.DiagnosticCategory.Error, "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'."), - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: diag(2411, ts.DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", "Property '{0}' of type '{1}' is not assignable to string index type '{2}'."), - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: diag(2412, ts.DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'."), - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: diag(2413, ts.DiagnosticCategory.Error, "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", "Numeric index type '{0}' is not assignable to string index type '{1}'."), + Property_0_of_type_1_is_not_assignable_to_2_index_type_3: diag(2411, ts.DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_2_index_type_3_2411", "Property '{0}' of type '{1}' is not assignable to '{2}' index type '{3}'."), + _0_index_type_1_is_not_assignable_to_2_index_type_3: diag(2413, ts.DiagnosticCategory.Error, "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413", "'{0}' index type '{1}' is not assignable to '{2}' index type '{3}'."), Class_name_cannot_be_0: diag(2414, ts.DiagnosticCategory.Error, "Class_name_cannot_be_0_2414", "Class name cannot be '{0}'."), Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), @@ -8486,7 +8619,9 @@ var ts; Property_0_is_used_before_being_assigned: diag(2565, ts.DiagnosticCategory.Error, "Property_0_is_used_before_being_assigned_2565", "Property '{0}' is used before being assigned."), A_rest_element_cannot_have_a_property_name: diag(2566, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."), Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, ts.DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."), + Property_0_may_not_exist_on_type_1_Did_you_mean_2: diag(2568, ts.DiagnosticCategory.Error, "Property_0_may_not_exist_on_type_1_Did_you_mean_2_2568", "Property '{0}' may not exist on type '{1}'. Did you mean '{2}'?"), Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), + Could_not_find_name_0_Did_you_mean_1: diag(2570, ts.DiagnosticCategory.Error, "Could_not_find_name_0_Did_you_mean_1_2570", "Could not find name '{0}'. Did you mean '{1}'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."), Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), @@ -8547,6 +8682,7 @@ var ts; Cannot_assign_to_0_because_it_is_a_namespace: diag(2631, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_namespace_2631", "Cannot assign to '{0}' because it is a namespace."), Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."), JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"), + _0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "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: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -8709,6 +8845,13 @@ var ts; Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."), Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), + Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), + Function_with_bodies_can_only_merge_with_classes_that_are_ambient: diag(2814, ts.DiagnosticCategory.Error, "Function_with_bodies_can_only_merge_with_classes_that_are_ambient_2814", "Function with bodies can only merge with classes that are ambient."), + arguments_cannot_be_referenced_in_property_initializers: diag(2815, ts.DiagnosticCategory.Error, "arguments_cannot_be_referenced_in_property_initializers_2815", "'arguments' cannot be referenced in property initializers."), + Cannot_use_this_in_a_static_property_initializer_of_a_decorated_class: diag(2816, ts.DiagnosticCategory.Error, "Cannot_use_this_in_a_static_property_initializer_of_a_decorated_class_2816", "Cannot use 'this' in a static property initializer of a decorated class."), + Property_0_has_no_initializer_and_is_not_definitely_assigned_in_a_class_static_block: diag(2817, ts.DiagnosticCategory.Error, "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_a_class_static_block_2817", "Property '{0}' has no initializer and is not definitely assigned in a class static block."), + Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializers: diag(2818, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializer_2818", "Duplicate identifier '{0}'. Compiler reserves name '{1}' when emitting 'super' references in static initializers."), + Namespace_name_cannot_be_0: diag(2819, ts.DiagnosticCategory.Error, "Namespace_name_cannot_be_0_2819", "Namespace name cannot be '{0}'."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -8808,6 +8951,8 @@ var ts; This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0: diag(4114, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114", "This member must have an 'override' modifier because it overrides a member in the base class '{0}'."), This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0: diag(4115, ts.DiagnosticCategory.Error, "This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0_4115", "This parameter property must have an 'override' modifier because it overrides a member in base class '{0}'."), This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0: diag(4116, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116", "This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class '{0}'."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4117, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you__4117", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'. Did you mean '{1}'?"), + The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized: diag(4118, ts.DiagnosticCategory.Error, "The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized_4118", "The type of this node cannot be serialized because its property '{0}' cannot be serialized."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -8866,7 +9011,7 @@ var ts; Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), - Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: diag(6003, ts.DiagnosticCategory.Message, "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", "Specify the location where debugger should locate map files instead of generated locations."), + Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: diag(6655, ts.DiagnosticCategory.Message, "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6655", "Specify the location where debugger should locate map files instead of generated locations."), Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: diag(6004, ts.DiagnosticCategory.Message, "Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations_6004", "Specify the location where debugger should locate TypeScript files instead of source locations."), Watch_input_files: diag(6005, ts.DiagnosticCategory.Message, "Watch_input_files_6005", "Watch input files."), Redirect_output_structure_to_the_directory: diag(6006, ts.DiagnosticCategory.Message, "Redirect_output_structure_to_the_directory_6006", "Redirect output structure to the directory."), @@ -8878,8 +9023,8 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."), - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'."), - Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'."), + Specify_ECMAScript_target_version: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_6015", "Specify ECMAScript target version."), + Specify_module_code_generation: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_6016", "Specify module code generation."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: diag(6020, ts.DiagnosticCategory.Message, "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'."), @@ -8931,7 +9076,7 @@ var ts; Do_not_report_errors_on_unreachable_code: diag(6077, ts.DiagnosticCategory.Message, "Do_not_report_errors_on_unreachable_code_6077", "Do not report errors on unreachable code."), Disallow_inconsistently_cased_references_to_the_same_file: diag(6078, ts.DiagnosticCategory.Message, "Disallow_inconsistently_cased_references_to_the_same_file_6078", "Disallow inconsistently-cased references to the same file."), Specify_library_files_to_be_included_in_the_compilation: diag(6079, ts.DiagnosticCategory.Message, "Specify_library_files_to_be_included_in_the_compilation_6079", "Specify library files to be included in the compilation."), - Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev: diag(6080, ts.DiagnosticCategory.Message, "Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev_6080", "Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'."), + Specify_JSX_code_generation: diag(6080, ts.DiagnosticCategory.Message, "Specify_JSX_code_generation_6080", "Specify JSX code generation."), File_0_has_an_unsupported_extension_so_skipping_it: diag(6081, ts.DiagnosticCategory.Message, "File_0_has_an_unsupported_extension_so_skipping_it_6081", "File '{0}' has an unsupported extension, so skipping it."), Only_amd_and_system_modules_are_supported_alongside_0: diag(6082, ts.DiagnosticCategory.Error, "Only_amd_and_system_modules_are_supported_alongside_0_6082", "Only 'amd' and 'system' modules are supported alongside --{0}."), Base_directory_to_resolve_non_absolute_module_names: diag(6083, ts.DiagnosticCategory.Message, "Base_directory_to_resolve_non_absolute_module_names_6083", "Base directory to resolve non-absolute module names."), @@ -9013,7 +9158,7 @@ var ts; List_of_folders_to_include_type_definitions_from: diag(6161, ts.DiagnosticCategory.Message, "List_of_folders_to_include_type_definitions_from_6161", "List of folders to include type definitions from."), Disable_size_limitations_on_JavaScript_projects: diag(6162, ts.DiagnosticCategory.Message, "Disable_size_limitations_on_JavaScript_projects_6162", "Disable size limitations on JavaScript projects."), The_character_set_of_the_input_files: diag(6163, ts.DiagnosticCategory.Message, "The_character_set_of_the_input_files_6163", "The character set of the input files."), - Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: diag(6164, ts.DiagnosticCategory.Message, "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6164", "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files."), + Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: diag(6622, ts.DiagnosticCategory.Message, "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6622", "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files."), Do_not_truncate_error_messages: diag(6165, ts.DiagnosticCategory.Message, "Do_not_truncate_error_messages_6165", "Do not truncate error messages."), Output_directory_for_generated_declaration_files: diag(6166, ts.DiagnosticCategory.Message, "Output_directory_for_generated_declaration_files_6166", "Output directory for generated declaration files."), A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl: diag(6167, ts.DiagnosticCategory.Message, "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167", "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'."), @@ -9021,20 +9166,12 @@ var ts; Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."), Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: diag(6170, ts.DiagnosticCategory.Message, "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file"), Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"), - Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"), - Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"), - Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"), - Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"), - Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"), - Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"), - Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"), Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: diag(6179, ts.DiagnosticCategory.Message, "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'."), Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."), List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."), Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"), - Reusing_resolution_of_module_0_to_file_1_from_old_program: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_to_file_1_from_old_program_6183", "Reusing resolution of module '{0}' to file '{1}' from old program."), - Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program: diag(6184, ts.DiagnosticCategory.Message, "Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program_6184", "Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program."), - Disable_strict_checking_of_generic_signatures_in_function_types: diag(6185, ts.DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6185", "Disable strict checking of generic signatures in function types."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_6183", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6184, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package__6184", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."), Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."), Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."), @@ -9076,7 +9213,6 @@ var ts; Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling'."), Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority', 'FixedChunkSize'."), - Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3: diag(6229, ts.DiagnosticCategory.Error, "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229", "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'."), Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), Could_not_resolve_the_path_0_with_the_extensions_Colon_1: diag(6231, ts.DiagnosticCategory.Error, "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231", "Could not resolve the path '{0}' with the extensions: {1}."), @@ -9091,6 +9227,21 @@ var ts; File_0_does_not_exist_according_to_earlier_cached_lookups: diag(6240, ts.DiagnosticCategory.Message, "File_0_does_not_exist_according_to_earlier_cached_lookups_6240", "File '{0}' does not exist according to earlier cached lookups."), Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1: diag(6241, ts.DiagnosticCategory.Message, "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241", "Resolution for type reference directive '{0}' was found in cache from location '{1}'."), Resolving_type_reference_directive_0_containing_file_1: diag(6242, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_6242", "======== Resolving type reference directive '{0}', containing file '{1}'. ========"), + Interpret_optional_property_types_as_written_rather_than_adding_undefined: diag(6243, ts.DiagnosticCategory.Message, "Interpret_optional_property_types_as_written_rather_than_adding_undefined_6243", "Interpret optional property types as written, rather than adding 'undefined'."), + Modules: diag(6244, ts.DiagnosticCategory.Message, "Modules_6244", "Modules"), + File_Management: diag(6245, ts.DiagnosticCategory.Message, "File_Management_6245", "File Management"), + Emit: diag(6246, ts.DiagnosticCategory.Message, "Emit_6246", "Emit"), + JavaScript_Support: diag(6247, ts.DiagnosticCategory.Message, "JavaScript_Support_6247", "JavaScript Support"), + Type_Checking: diag(6248, ts.DiagnosticCategory.Message, "Type_Checking_6248", "Type Checking"), + Editor_Support: diag(6249, ts.DiagnosticCategory.Message, "Editor_Support_6249", "Editor Support"), + Watch_and_Build_Modes: diag(6250, ts.DiagnosticCategory.Message, "Watch_and_Build_Modes_6250", "Watch and Build Modes"), + Compiler_Diagnostics: diag(6251, ts.DiagnosticCategory.Message, "Compiler_Diagnostics_6251", "Compiler Diagnostics"), + Interop_Constraints: diag(6252, ts.DiagnosticCategory.Message, "Interop_Constraints_6252", "Interop Constraints"), + Backwards_Compatibility: diag(6253, ts.DiagnosticCategory.Message, "Backwards_Compatibility_6253", "Backwards Compatibility"), + Language_and_Environment: diag(6254, ts.DiagnosticCategory.Message, "Language_and_Environment_6254", "Language and Environment"), + Projects: diag(6255, ts.DiagnosticCategory.Message, "Projects_6255", "Projects"), + Output_Formatting: diag(6256, ts.DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"), + Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -9116,9 +9267,7 @@ var ts; Project_0_can_t_be_built_because_its_dependency_1_has_errors: diag(6363, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_has_errors_6363", "Project '{0}' can't be built because its dependency '{1}' has errors"), Build_one_or_more_projects_and_their_dependencies_if_out_of_date: diag(6364, ts.DiagnosticCategory.Message, "Build_one_or_more_projects_and_their_dependencies_if_out_of_date_6364", "Build one or more projects and their dependencies, if out of date"), Delete_the_outputs_of_all_projects: diag(6365, ts.DiagnosticCategory.Message, "Delete_the_outputs_of_all_projects_6365", "Delete the outputs of all projects"), - Enable_verbose_logging: diag(6366, ts.DiagnosticCategory.Message, "Enable_verbose_logging_6366", "Enable verbose logging"), Show_what_would_be_built_or_deleted_if_specified_with_clean: diag(6367, ts.DiagnosticCategory.Message, "Show_what_would_be_built_or_deleted_if_specified_with_clean_6367", "Show what would be built (or deleted, if specified with '--clean')"), - Build_all_projects_including_those_that_appear_to_be_up_to_date: diag(6368, ts.DiagnosticCategory.Message, "Build_all_projects_including_those_that_appear_to_be_up_to_date_6368", "Build all projects, including those that appear to be up to date"), Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Updating_unchanged_output_timestamps_of_project_0: diag(6371, ts.DiagnosticCategory.Message, "Updating_unchanged_output_timestamps_of_project_0_6371", "Updating unchanged output timestamps of project '{0}'..."), @@ -9139,15 +9288,167 @@ var ts; Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found: diag(6386, ts.DiagnosticCategory.Message, "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386", "Performance timings for '--diagnostics' or '--extendedDiagnostics' are not available in this session. A native implementation of the Web Performance API could not be found."), The_signature_0_of_1_is_deprecated: diag(6387, ts.DiagnosticCategory.Suggestion, "The_signature_0_of_1_is_deprecated_6387", "The signature '{0}' of '{1}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), Project_0_is_being_forcibly_rebuilt: diag(6388, ts.DiagnosticCategory.Message, "Project_0_is_being_forcibly_rebuilt_6388", "Project '{0}' is being forcibly rebuilt"), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved: diag(6389, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved_6389", "Reusing resolution of module '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6390, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6390", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6391, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6391", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved: diag(6392, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved_6392", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6393, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6393", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6394, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6394", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6395, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved_6395", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6396, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6397, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, ts.DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"), Print_names_of_files_and_the_reason_they_are_part_of_the_compilation: diag(6505, ts.DiagnosticCategory.Message, "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505", "Print names of files and the reason they are part of the compilation."), - Include_undefined_in_index_signature_results: diag(6800, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6800", "Include 'undefined' in index signature results"), - Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier: diag(6801, ts.DiagnosticCategory.Message, "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6801", "Ensure overriding members in derived classes are marked with an 'override' modifier."), - Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6802, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6802", "Require undeclared properties from index signatures to use element accesses."), + Consider_adding_a_declare_modifier_to_this_class: diag(6506, ts.DiagnosticCategory.Message, "Consider_adding_a_declare_modifier_to_this_class_6506", "Consider adding a 'declare' modifier to this class."), + Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files: diag(6600, ts.DiagnosticCategory.Message, "Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these__6600", "Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files."), + Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export: diag(6601, ts.DiagnosticCategory.Message, "Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export_6601", "Allow 'import x from y' when a module doesn't have a default export."), + Allow_accessing_UMD_globals_from_modules: diag(6602, ts.DiagnosticCategory.Message, "Allow_accessing_UMD_globals_from_modules_6602", "Allow accessing UMD globals from modules."), + Disable_error_reporting_for_unreachable_code: diag(6603, ts.DiagnosticCategory.Message, "Disable_error_reporting_for_unreachable_code_6603", "Disable error reporting for unreachable code."), + Disable_error_reporting_for_unused_labels: diag(6604, ts.DiagnosticCategory.Message, "Disable_error_reporting_for_unused_labels_6604", "Disable error reporting for unused labels."), + Ensure_use_strict_is_always_emitted: diag(6605, ts.DiagnosticCategory.Message, "Ensure_use_strict_is_always_emitted_6605", "Ensure 'use strict' is always emitted."), + Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6606, ts.DiagnosticCategory.Message, "Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_wi_6606", "Have recompiles in projects that use `incremental` and `watch` mode assume that changes within a file will only affect files directly depending on it."), + Specify_the_base_directory_to_resolve_non_relative_module_names: diag(6607, ts.DiagnosticCategory.Message, "Specify_the_base_directory_to_resolve_non_relative_module_names_6607", "Specify the base directory to resolve non-relative module names."), + No_longer_supported_In_early_versions_manually_set_the_text_encoding_for_reading_files: diag(6608, ts.DiagnosticCategory.Message, "No_longer_supported_In_early_versions_manually_set_the_text_encoding_for_reading_files_6608", "No longer supported. In early versions, manually set the text encoding for reading files."), + Enable_error_reporting_in_type_checked_JavaScript_files: diag(6609, ts.DiagnosticCategory.Message, "Enable_error_reporting_in_type_checked_JavaScript_files_6609", "Enable error reporting in type-checked JavaScript files."), + Enable_constraints_that_allow_a_TypeScript_project_to_be_used_with_project_references: diag(6611, ts.DiagnosticCategory.Message, "Enable_constraints_that_allow_a_TypeScript_project_to_be_used_with_project_references_6611", "Enable constraints that allow a TypeScript project to be used with project references."), + Generate_d_ts_files_from_TypeScript_and_JavaScript_files_in_your_project: diag(6612, ts.DiagnosticCategory.Message, "Generate_d_ts_files_from_TypeScript_and_JavaScript_files_in_your_project_6612", "Generate .d.ts files from TypeScript and JavaScript files in your project."), + Specify_the_output_directory_for_generated_declaration_files: diag(6613, ts.DiagnosticCategory.Message, "Specify_the_output_directory_for_generated_declaration_files_6613", "Specify the output directory for generated declaration files."), + Create_sourcemaps_for_d_ts_files: diag(6614, ts.DiagnosticCategory.Message, "Create_sourcemaps_for_d_ts_files_6614", "Create sourcemaps for d.ts files."), + Output_compiler_performance_information_after_building: diag(6615, ts.DiagnosticCategory.Message, "Output_compiler_performance_information_after_building_6615", "Output compiler performance information after building."), + Disables_inference_for_type_acquisition_by_looking_at_filenames_in_a_project: diag(6616, ts.DiagnosticCategory.Message, "Disables_inference_for_type_acquisition_by_looking_at_filenames_in_a_project_6616", "Disables inference for type acquisition by looking at filenames in a project."), + Reduce_the_number_of_projects_loaded_automatically_by_TypeScript: diag(6617, ts.DiagnosticCategory.Message, "Reduce_the_number_of_projects_loaded_automatically_by_TypeScript_6617", "Reduce the number of projects loaded automatically by TypeScript."), + Remove_the_20mb_cap_on_total_source_code_size_for_JavaScript_files_in_the_TypeScript_language_server: diag(6618, ts.DiagnosticCategory.Message, "Remove_the_20mb_cap_on_total_source_code_size_for_JavaScript_files_in_the_TypeScript_language_server_6618", "Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server."), + Opt_a_project_out_of_multi_project_reference_checking_when_editing: diag(6619, ts.DiagnosticCategory.Message, "Opt_a_project_out_of_multi_project_reference_checking_when_editing_6619", "Opt a project out of multi-project reference checking when editing."), + Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects: diag(6620, ts.DiagnosticCategory.Message, "Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects_6620", "Disable preferring source files instead of declaration files when referencing composite projects"), + Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration: diag(6621, ts.DiagnosticCategory.Message, "Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration_6621", "Emit more compliant, but verbose and less performant JavaScript for iteration."), + Only_output_d_ts_files_and_not_JavaScript_files: diag(6623, ts.DiagnosticCategory.Message, "Only_output_d_ts_files_and_not_JavaScript_files_6623", "Only output d.ts files and not JavaScript files."), + Emit_design_type_metadata_for_decorated_declarations_in_source_files: diag(6624, ts.DiagnosticCategory.Message, "Emit_design_type_metadata_for_decorated_declarations_in_source_files_6624", "Emit design-type metadata for decorated declarations in source files."), + Disable_the_type_acquisition_for_JavaScript_projects: diag(6625, ts.DiagnosticCategory.Message, "Disable_the_type_acquisition_for_JavaScript_projects_6625", "Disable the type acquisition for JavaScript projects"), + Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility: diag(6626, ts.DiagnosticCategory.Message, "Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheti_6626", "Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility."), + Filters_results_from_the_include_option: diag(6627, ts.DiagnosticCategory.Message, "Filters_results_from_the_include_option_6627", "Filters results from the `include` option."), + Remove_a_list_of_directories_from_the_watch_process: diag(6628, ts.DiagnosticCategory.Message, "Remove_a_list_of_directories_from_the_watch_process_6628", "Remove a list of directories from the watch process."), + Remove_a_list_of_files_from_the_watch_mode_s_processing: diag(6629, ts.DiagnosticCategory.Message, "Remove_a_list_of_files_from_the_watch_mode_s_processing_6629", "Remove a list of files from the watch mode's processing."), + Enable_experimental_support_for_TC39_stage_2_draft_decorators: diag(6630, ts.DiagnosticCategory.Message, "Enable_experimental_support_for_TC39_stage_2_draft_decorators_6630", "Enable experimental support for TC39 stage 2 draft decorators."), + Print_files_read_during_the_compilation_including_why_it_was_included: diag(6631, ts.DiagnosticCategory.Message, "Print_files_read_during_the_compilation_including_why_it_was_included_6631", "Print files read during the compilation including why it was included."), + Output_more_detailed_compiler_performance_information_after_building: diag(6632, ts.DiagnosticCategory.Message, "Output_more_detailed_compiler_performance_information_after_building_6632", "Output more detailed compiler performance information after building."), + Specify_one_or_more_path_or_node_module_references_to_base_configuration_files_from_which_settings_are_inherited: diag(6633, ts.DiagnosticCategory.Message, "Specify_one_or_more_path_or_node_module_references_to_base_configuration_files_from_which_settings_a_6633", "Specify one or more path or node module references to base configuration files from which settings are inherited."), + Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers: diag(6634, ts.DiagnosticCategory.Message, "Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers_6634", "Specify what approach the watcher should use if the system runs out of native file watchers."), + Include_a_list_of_files_This_does_not_support_glob_patterns_as_opposed_to_include: diag(6635, ts.DiagnosticCategory.Message, "Include_a_list_of_files_This_does_not_support_glob_patterns_as_opposed_to_include_6635", "Include a list of files. This does not support glob patterns, as opposed to `include`."), + Build_all_projects_including_those_that_appear_to_be_up_to_date: diag(6636, ts.DiagnosticCategory.Message, "Build_all_projects_including_those_that_appear_to_be_up_to_date_6636", "Build all projects, including those that appear to be up to date"), + Ensure_that_casing_is_correct_in_imports: diag(6637, ts.DiagnosticCategory.Message, "Ensure_that_casing_is_correct_in_imports_6637", "Ensure that casing is correct in imports."), + Emit_a_v8_CPU_profile_of_the_compiler_run_for_debugging: diag(6638, ts.DiagnosticCategory.Message, "Emit_a_v8_CPU_profile_of_the_compiler_run_for_debugging_6638", "Emit a v8 CPU profile of the compiler run for debugging."), + Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file: diag(6639, ts.DiagnosticCategory.Message, "Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file_6639", "Allow importing helper functions from tslib once per project, instead of including them per-file."), + Specify_a_list_of_glob_patterns_that_match_files_to_be_included_in_compilation: diag(6641, ts.DiagnosticCategory.Message, "Specify_a_list_of_glob_patterns_that_match_files_to_be_included_in_compilation_6641", "Specify a list of glob patterns that match files to be included in compilation."), + Save_tsbuildinfo_files_to_allow_for_incremental_compilation_of_projects: diag(6642, ts.DiagnosticCategory.Message, "Save_tsbuildinfo_files_to_allow_for_incremental_compilation_of_projects_6642", "Save .tsbuildinfo files to allow for incremental compilation of projects."), + Include_sourcemap_files_inside_the_emitted_JavaScript: diag(6643, ts.DiagnosticCategory.Message, "Include_sourcemap_files_inside_the_emitted_JavaScript_6643", "Include sourcemap files inside the emitted JavaScript."), + Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript: diag(6644, ts.DiagnosticCategory.Message, "Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript_6644", "Include source code in the sourcemaps inside the emitted JavaScript."), + Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports: diag(6645, ts.DiagnosticCategory.Message, "Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports_6645", "Ensure that each file can be safely transpiled without relying on other imports."), + Specify_what_JSX_code_is_generated: diag(6646, ts.DiagnosticCategory.Message, "Specify_what_JSX_code_is_generated_6646", "Specify what JSX code is generated."), + Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h: diag(6647, ts.DiagnosticCategory.Message, "Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h_6647", "Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'"), + Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragment_or_Fragment: diag(6648, ts.DiagnosticCategory.Message, "Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragme_6648", "Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'."), + Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk: diag(6649, ts.DiagnosticCategory.Message, "Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Ast_6649", "Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.`"), + Make_keyof_only_return_strings_instead_of_string_numbers_or_symbols_Legacy_option: diag(6650, ts.DiagnosticCategory.Message, "Make_keyof_only_return_strings_instead_of_string_numbers_or_symbols_Legacy_option_6650", "Make keyof only return strings instead of string, numbers or symbols. Legacy option."), + Specify_a_set_of_bundled_library_declaration_files_that_describe_the_target_runtime_environment: diag(6651, ts.DiagnosticCategory.Message, "Specify_a_set_of_bundled_library_declaration_files_that_describe_the_target_runtime_environment_6651", "Specify a set of bundled library declaration files that describe the target runtime environment."), + Print_the_names_of_emitted_files_after_a_compilation: diag(6652, ts.DiagnosticCategory.Message, "Print_the_names_of_emitted_files_after_a_compilation_6652", "Print the names of emitted files after a compilation."), + Print_all_of_the_files_read_during_the_compilation: diag(6653, ts.DiagnosticCategory.Message, "Print_all_of_the_files_read_during_the_compilation_6653", "Print all of the files read during the compilation."), + Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit: diag(6654, ts.DiagnosticCategory.Message, "Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit_6654", "Set the language of the messaging from TypeScript. This does not affect emit."), + Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicable_with_allowJs: diag(6656, ts.DiagnosticCategory.Message, "Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicabl_6656", "Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`."), + Specify_what_module_code_is_generated: diag(6657, ts.DiagnosticCategory.Message, "Specify_what_module_code_is_generated_6657", "Specify what module code is generated."), + Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier: diag(6658, ts.DiagnosticCategory.Message, "Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier_6658", "Specify how TypeScript looks up a file from a given module specifier."), + Set_the_newline_character_for_emitting_files: diag(6659, ts.DiagnosticCategory.Message, "Set_the_newline_character_for_emitting_files_6659", "Set the newline character for emitting files."), + Disable_emitting_files_from_a_compilation: diag(6660, ts.DiagnosticCategory.Message, "Disable_emitting_files_from_a_compilation_6660", "Disable emitting files from a compilation."), + Disable_generating_custom_helper_functions_like_extends_in_compiled_output: diag(6661, ts.DiagnosticCategory.Message, "Disable_generating_custom_helper_functions_like_extends_in_compiled_output_6661", "Disable generating custom helper functions like `__extends` in compiled output."), + Disable_emitting_files_if_any_type_checking_errors_are_reported: diag(6662, ts.DiagnosticCategory.Message, "Disable_emitting_files_if_any_type_checking_errors_are_reported_6662", "Disable emitting files if any type checking errors are reported."), + Disable_truncating_types_in_error_messages: diag(6663, ts.DiagnosticCategory.Message, "Disable_truncating_types_in_error_messages_6663", "Disable truncating types in error messages."), + Enable_error_reporting_for_fallthrough_cases_in_switch_statements: diag(6664, ts.DiagnosticCategory.Message, "Enable_error_reporting_for_fallthrough_cases_in_switch_statements_6664", "Enable error reporting for fallthrough cases in switch statements."), + Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type: diag(6665, ts.DiagnosticCategory.Message, "Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type_6665", "Enable error reporting for expressions and declarations with an implied `any` type.."), + Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier: diag(6666, ts.DiagnosticCategory.Message, "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6666", "Ensure overriding members in derived classes are marked with an override modifier."), + Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function: diag(6667, ts.DiagnosticCategory.Message, "Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function_6667", "Enable error reporting for codepaths that do not explicitly return in a function."), + Enable_error_reporting_when_this_is_given_the_type_any: diag(6668, ts.DiagnosticCategory.Message, "Enable_error_reporting_when_this_is_given_the_type_any_6668", "Enable error reporting when `this` is given the type `any`."), + Disable_adding_use_strict_directives_in_emitted_JavaScript_files: diag(6669, ts.DiagnosticCategory.Message, "Disable_adding_use_strict_directives_in_emitted_JavaScript_files_6669", "Disable adding 'use strict' directives in emitted JavaScript files."), + Disable_including_any_library_files_including_the_default_lib_d_ts: diag(6670, ts.DiagnosticCategory.Message, "Disable_including_any_library_files_including_the_default_lib_d_ts_6670", "Disable including any library files, including the default lib.d.ts."), + Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type: diag(6671, ts.DiagnosticCategory.Message, "Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type_6671", "Enforces using indexed accessors for keys declared using an indexed type"), + Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add_to_a_project: diag(6672, ts.DiagnosticCategory.Message, "Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add__6672", "Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project."), + Disable_strict_checking_of_generic_signatures_in_function_types: diag(6673, ts.DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6673", "Disable strict checking of generic signatures in function types."), + Add_undefined_to_a_type_when_accessed_using_an_index: diag(6674, ts.DiagnosticCategory.Message, "Add_undefined_to_a_type_when_accessed_using_an_index_6674", "Add `undefined` to a type when accessed using an index."), + Enable_error_reporting_when_a_local_variables_aren_t_read: diag(6675, ts.DiagnosticCategory.Message, "Enable_error_reporting_when_a_local_variables_aren_t_read_6675", "Enable error reporting when a local variables aren't read."), + Raise_an_error_when_a_function_parameter_isn_t_read: diag(6676, ts.DiagnosticCategory.Message, "Raise_an_error_when_a_function_parameter_isn_t_read_6676", "Raise an error when a function parameter isn't read"), + Deprecated_setting_Use_outFile_instead: diag(6677, ts.DiagnosticCategory.Message, "Deprecated_setting_Use_outFile_instead_6677", "Deprecated setting. Use `outFile` instead."), + Specify_an_output_folder_for_all_emitted_files: diag(6678, ts.DiagnosticCategory.Message, "Specify_an_output_folder_for_all_emitted_files_6678", "Specify an output folder for all emitted files."), + Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output: diag(6679, ts.DiagnosticCategory.Message, "Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designa_6679", "Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output."), + Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations: diag(6680, ts.DiagnosticCategory.Message, "Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations_6680", "Specify a set of entries that re-map imports to additional lookup locations."), + Specify_a_list_of_language_service_plugins_to_include: diag(6681, ts.DiagnosticCategory.Message, "Specify_a_list_of_language_service_plugins_to_include_6681", "Specify a list of language service plugins to include."), + Disable_erasing_const_enum_declarations_in_generated_code: diag(6682, ts.DiagnosticCategory.Message, "Disable_erasing_const_enum_declarations_in_generated_code_6682", "Disable erasing `const enum` declarations in generated code."), + Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node: diag(6683, ts.DiagnosticCategory.Message, "Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node_6683", "Disable resolving symlinks to their realpath. This correlates to the same flag in node."), + Disable_wiping_the_console_in_watch_mode: diag(6684, ts.DiagnosticCategory.Message, "Disable_wiping_the_console_in_watch_mode_6684", "Disable wiping the console in watch mode"), + Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read: diag(6685, ts.DiagnosticCategory.Message, "Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read_6685", "Enable color and formatting in TypeScript's output to make compiler errors easier to read"), + Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit: diag(6686, ts.DiagnosticCategory.Message, "Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit_6686", "Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit."), + Specify_an_array_of_objects_that_specify_paths_for_projects_Used_in_project_references: diag(6687, ts.DiagnosticCategory.Message, "Specify_an_array_of_objects_that_specify_paths_for_projects_Used_in_project_references_6687", "Specify an array of objects that specify paths for projects. Used in project references."), + Disable_emitting_comments: diag(6688, ts.DiagnosticCategory.Message, "Disable_emitting_comments_6688", "Disable emitting comments."), + Enable_importing_json_files: diag(6689, ts.DiagnosticCategory.Message, "Enable_importing_json_files_6689", "Enable importing .json files"), + Specify_the_root_folder_within_your_source_files: diag(6690, ts.DiagnosticCategory.Message, "Specify_the_root_folder_within_your_source_files_6690", "Specify the root folder within your source files."), + Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules: diag(6691, ts.DiagnosticCategory.Message, "Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules_6691", "Allow multiple folders to be treated as one when resolving modules."), + Skip_type_checking_d_ts_files_that_are_included_with_TypeScript: diag(6692, ts.DiagnosticCategory.Message, "Skip_type_checking_d_ts_files_that_are_included_with_TypeScript_6692", "Skip type checking .d.ts files that are included with TypeScript."), + Skip_type_checking_all_d_ts_files: diag(6693, ts.DiagnosticCategory.Message, "Skip_type_checking_all_d_ts_files_6693", "Skip type checking all .d.ts files."), + Create_source_map_files_for_emitted_JavaScript_files: diag(6694, ts.DiagnosticCategory.Message, "Create_source_map_files_for_emitted_JavaScript_files_6694", "Create source map files for emitted JavaScript files."), + Specify_the_root_path_for_debuggers_to_find_the_reference_source_code: diag(6695, ts.DiagnosticCategory.Message, "Specify_the_root_path_for_debuggers_to_find_the_reference_source_code_6695", "Specify the root path for debuggers to find the reference source code."), + Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function: diag(6697, ts.DiagnosticCategory.Message, "Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function_6697", "Check that the arguments for `bind`, `call`, and `apply` methods match the original function."), + When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible: diag(6698, ts.DiagnosticCategory.Message, "When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible_6698", "When assigning functions, check to ensure parameters and the return values are subtype-compatible."), + When_type_checking_take_into_account_null_and_undefined: diag(6699, ts.DiagnosticCategory.Message, "When_type_checking_take_into_account_null_and_undefined_6699", "When type checking, take into account `null` and `undefined`."), + Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor: diag(6700, ts.DiagnosticCategory.Message, "Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor_6700", "Check for class properties that are declared but not set in the constructor."), + Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments: diag(6701, ts.DiagnosticCategory.Message, "Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments_6701", "Disable emitting declarations that have `@internal` in their JSDoc comments."), + Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals: diag(6702, ts.DiagnosticCategory.Message, "Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals_6702", "Disable reporting of excess property errors during the creation of object literals."), + Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures: diag(6703, ts.DiagnosticCategory.Message, "Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures_6703", "Suppress `noImplicitAny` errors when indexing objects that lack index signatures."), + Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6704, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6704", "Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively."), + Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations: diag(6705, ts.DiagnosticCategory.Message, "Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declaratio_6705", "Set the JavaScript language version for emitted JavaScript and include compatible library declarations."), + Log_paths_used_during_the_moduleResolution_process: diag(6706, ts.DiagnosticCategory.Message, "Log_paths_used_during_the_moduleResolution_process_6706", "Log paths used during the `moduleResolution` process."), + Specify_the_folder_for_tsbuildinfo_incremental_compilation_files: diag(6707, ts.DiagnosticCategory.Message, "Specify_the_folder_for_tsbuildinfo_incremental_compilation_files_6707", "Specify the folder for .tsbuildinfo incremental compilation files."), + Specify_options_for_automatic_acquisition_of_declaration_files: diag(6709, ts.DiagnosticCategory.Message, "Specify_options_for_automatic_acquisition_of_declaration_files_6709", "Specify options for automatic acquisition of declaration files."), + Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types: diag(6710, ts.DiagnosticCategory.Message, "Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types_6710", "Specify multiple folders that act like `./node_modules/@types`."), + Specify_type_package_names_to_be_included_without_being_referenced_in_a_source_file: diag(6711, ts.DiagnosticCategory.Message, "Specify_type_package_names_to_be_included_without_being_referenced_in_a_source_file_6711", "Specify type package names to be included without being referenced in a source file."), + Emit_ECMAScript_standard_compliant_class_fields: diag(6712, ts.DiagnosticCategory.Message, "Emit_ECMAScript_standard_compliant_class_fields_6712", "Emit ECMAScript-standard-compliant class fields."), + Enable_verbose_logging: diag(6713, ts.DiagnosticCategory.Message, "Enable_verbose_logging_6713", "Enable verbose logging"), + Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality: diag(6714, ts.DiagnosticCategory.Message, "Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality_6714", "Specify how directories are watched on systems that lack recursive file-watching functionality."), + Specify_how_the_TypeScript_watch_mode_works: diag(6715, ts.DiagnosticCategory.Message, "Specify_how_the_TypeScript_watch_mode_works_6715", "Specify how the TypeScript watch mode works."), + Include_undefined_in_index_signature_results: diag(6716, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6716", "Include 'undefined' in index signature results"), + Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6717, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6717", "Require undeclared properties from index signatures to use element accesses."), + Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, ts.DiagnosticCategory.Message, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types"), + Type_catch_clause_variables_as_unknown_instead_of_any: diag(6803, ts.DiagnosticCategory.Message, "Type_catch_clause_variables_as_unknown_instead_of_any_6803", "Type catch clause variables as 'unknown' instead of 'any'."), + one_of_Colon: diag(6900, ts.DiagnosticCategory.Message, "one_of_Colon_6900", "one of:"), + one_or_more_Colon: diag(6901, ts.DiagnosticCategory.Message, "one_or_more_Colon_6901", "one or more:"), + type_Colon: diag(6902, ts.DiagnosticCategory.Message, "type_Colon_6902", "type:"), + default_Colon: diag(6903, ts.DiagnosticCategory.Message, "default_Colon_6903", "default:"), + module_system_or_esModuleInterop: diag(6904, ts.DiagnosticCategory.Message, "module_system_or_esModuleInterop_6904", "module === \"system\" or esModuleInterop"), + false_unless_strict_is_set: diag(6905, ts.DiagnosticCategory.Message, "false_unless_strict_is_set_6905", "`false`, unless `strict` is set"), + false_unless_composite_is_set: diag(6906, ts.DiagnosticCategory.Message, "false_unless_composite_is_set_6906", "`false`, unless `composite` is set"), + node_modules_bower_components_jspm_packages_plus_the_value_of_outDir_if_one_is_specified: diag(6907, ts.DiagnosticCategory.Message, "node_modules_bower_components_jspm_packages_plus_the_value_of_outDir_if_one_is_specified_6907", "`[\"node_modules\", \"bower_components\", \"jspm_packages\"]`, plus the value of `outDir` if one is specified."), + if_files_is_specified_otherwise_Asterisk_Asterisk_Slash_Asterisk: diag(6908, ts.DiagnosticCategory.Message, "if_files_is_specified_otherwise_Asterisk_Asterisk_Slash_Asterisk_6908", "`[]` if `files` is specified, otherwise `[\"**/*\"]`"), + true_if_composite_false_otherwise: diag(6909, ts.DiagnosticCategory.Message, "true_if_composite_false_otherwise_6909", "`true` if `composite`, `false` otherwise"), + module_AMD_or_UMD_or_System_or_ES6_then_Classic_Otherwise_Node: diag(69010, ts.DiagnosticCategory.Message, "module_AMD_or_UMD_or_System_or_ES6_then_Classic_Otherwise_Node_69010", "module === `AMD` or `UMD` or `System` or `ES6`, then `Classic`, Otherwise `Node`"), + Computed_from_the_list_of_input_files: diag(6911, ts.DiagnosticCategory.Message, "Computed_from_the_list_of_input_files_6911", "Computed from the list of input files"), + Platform_specific: diag(6912, ts.DiagnosticCategory.Message, "Platform_specific_6912", "Platform specific"), + You_can_learn_about_all_of_the_compiler_options_at_0: diag(6913, ts.DiagnosticCategory.Message, "You_can_learn_about_all_of_the_compiler_options_at_0_6913", "You can learn about all of the compiler options at {0}"), + Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_config_watch_mode_with_Colon: diag(6914, ts.DiagnosticCategory.Message, "Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_conf_6914", "Including --watch, -w will start watching the current project for the file changes. Once set, you can config watch mode with:"), + Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0: diag(6915, ts.DiagnosticCategory.Message, "Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_tr_6915", "Using --build, -b will make tsc behave more like a build orchestrator than a compiler. This is used to trigger building composite projects which you can learn more about at {0}"), + COMMON_COMMANDS: diag(6916, ts.DiagnosticCategory.Message, "COMMON_COMMANDS_6916", "COMMON COMMANDS"), + ALL_COMPILER_OPTIONS: diag(6917, ts.DiagnosticCategory.Message, "ALL_COMPILER_OPTIONS_6917", "ALL COMPILER OPTIONS"), + WATCH_OPTIONS: diag(6918, ts.DiagnosticCategory.Message, "WATCH_OPTIONS_6918", "WATCH OPTIONS"), + BUILD_OPTIONS: diag(6919, ts.DiagnosticCategory.Message, "BUILD_OPTIONS_6919", "BUILD OPTIONS"), + COMMON_COMPILER_OPTIONS: diag(6920, ts.DiagnosticCategory.Message, "COMMON_COMPILER_OPTIONS_6920", "COMMON COMPILER OPTIONS"), + COMMAND_LINE_FLAGS: diag(6921, ts.DiagnosticCategory.Message, "COMMAND_LINE_FLAGS_6921", "COMMAND LINE FLAGS"), + tsc_Colon_The_TypeScript_Compiler: diag(6922, ts.DiagnosticCategory.Message, "tsc_Colon_The_TypeScript_Compiler_6922", "tsc: The TypeScript Compiler"), + Compiles_the_current_project_tsconfig_json_in_the_working_directory: diag(6923, ts.DiagnosticCategory.Message, "Compiles_the_current_project_tsconfig_json_in_the_working_directory_6923", "Compiles the current project (tsconfig.json in the working directory.)"), + Ignoring_tsconfig_json_compiles_the_specified_files_with_default_compiler_options: diag(6924, ts.DiagnosticCategory.Message, "Ignoring_tsconfig_json_compiles_the_specified_files_with_default_compiler_options_6924", "Ignoring tsconfig.json, compiles the specified files with default compiler options."), + Build_a_composite_project_in_the_working_directory: diag(6925, ts.DiagnosticCategory.Message, "Build_a_composite_project_in_the_working_directory_6925", "Build a composite project in the working directory."), + Creates_a_tsconfig_json_with_the_recommended_settings_in_the_working_directory: diag(6926, ts.DiagnosticCategory.Message, "Creates_a_tsconfig_json_with_the_recommended_settings_in_the_working_directory_6926", "Creates a tsconfig.json with the recommended settings in the working directory."), + Compiles_the_TypeScript_project_located_at_the_specified_path: diag(6927, ts.DiagnosticCategory.Message, "Compiles_the_TypeScript_project_located_at_the_specified_path_6927", "Compiles the TypeScript project located at the specified path."), + An_expanded_version_of_this_information_showing_all_possible_compiler_options: diag(6928, ts.DiagnosticCategory.Message, "An_expanded_version_of_this_information_showing_all_possible_compiler_options_6928", "An expanded version of this information, showing all possible compiler options"), + Compiles_the_current_project_with_additional_settings: diag(6929, ts.DiagnosticCategory.Message, "Compiles_the_current_project_with_additional_settings_6929", "Compiles the current project, with additional settings."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -9381,7 +9682,6 @@ var ts; Add_names_to_all_parameters_without_names: diag(95073, ts.DiagnosticCategory.Message, "Add_names_to_all_parameters_without_names_95073", "Add names to all parameters without names"), Enable_the_experimentalDecorators_option_in_your_configuration_file: diag(95074, ts.DiagnosticCategory.Message, "Enable_the_experimentalDecorators_option_in_your_configuration_file_95074", "Enable the 'experimentalDecorators' option in your configuration file"), Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"), - Allow_accessing_UMD_globals_from_modules: diag(95076, ts.DiagnosticCategory.Message, "Allow_accessing_UMD_globals_from_modules_95076", "Allow accessing UMD globals from modules."), Extract_type: diag(95077, ts.DiagnosticCategory.Message, "Extract_type_95077", "Extract type"), Extract_to_type_alias: diag(95078, ts.DiagnosticCategory.Message, "Extract_to_type_alias_95078", "Extract to type alias"), Extract_to_typedef: diag(95079, ts.DiagnosticCategory.Message, "Extract_to_typedef_95079", "Extract to typedef"), @@ -9469,6 +9769,11 @@ var ts; Remove_override_modifier: diag(95161, ts.DiagnosticCategory.Message, "Remove_override_modifier_95161", "Remove 'override' modifier"), Add_all_missing_override_modifiers: diag(95162, ts.DiagnosticCategory.Message, "Add_all_missing_override_modifiers_95162", "Add all missing 'override' modifiers"), Remove_all_unnecessary_override_modifiers: diag(95163, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_override_modifiers_95163", "Remove all unnecessary 'override' modifiers"), + Can_only_convert_named_export: diag(95164, ts.DiagnosticCategory.Message, "Can_only_convert_named_export_95164", "Can only convert named export"), + Add_missing_properties: diag(95165, ts.DiagnosticCategory.Message, "Add_missing_properties_95165", "Add missing properties"), + Add_all_missing_properties: diag(95166, ts.DiagnosticCategory.Message, "Add_all_missing_properties_95166", "Add all missing properties"), + Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"), + Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -9495,6 +9800,10 @@ var ts; Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment: diag(18034, ts.DiagnosticCategory.Message, "Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compi_18034", "Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'."), Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(18035, ts.DiagnosticCategory.Error, "Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name_18035", "Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name."), Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator: diag(18036, ts.DiagnosticCategory.Error, "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036", "Class decorators can't be used with static private identifier. Consider removing the experimental decorator."), + Await_expression_cannot_be_used_inside_a_class_static_block: diag(18037, ts.DiagnosticCategory.Error, "Await_expression_cannot_be_used_inside_a_class_static_block_18037", "Await expression cannot be used inside a class static block."), + For_await_loops_cannot_be_used_inside_a_class_static_block: diag(18038, ts.DiagnosticCategory.Error, "For_await_loops_cannot_be_used_inside_a_class_static_block_18038", "'For await' loops cannot be used inside a class static block."), + Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block: diag(18039, ts.DiagnosticCategory.Error, "Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block_18039", "Invalid use of '{0}'. It cannot be used inside a class static block."), + A_return_statement_cannot_be_used_inside_a_class_static_block: diag(18041, ts.DiagnosticCategory.Error, "A_return_statement_cannot_be_used_inside_a_class_static_block_18041", "A 'return' statement cannot be used inside a class static block."), }; })(ts || (ts = {})); var ts; @@ -9502,7 +9811,7 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 78 /* Identifier */; + return token >= 79 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ @@ -9510,89 +9819,90 @@ var ts; return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; - var textToKeywordObj = (_a = { - abstract: 125 /* AbstractKeyword */, - any: 128 /* AnyKeyword */, - as: 126 /* AsKeyword */, - asserts: 127 /* AssertsKeyword */, - bigint: 155 /* BigIntKeyword */, - boolean: 131 /* BooleanKeyword */, - break: 80 /* BreakKeyword */, - case: 81 /* CaseKeyword */, - catch: 82 /* CatchKeyword */, - class: 83 /* ClassKeyword */, - continue: 85 /* ContinueKeyword */, - const: 84 /* ConstKeyword */ + /** @internal */ + ts.textToKeywordObj = (_a = { + abstract: 126 /* AbstractKeyword */, + any: 129 /* AnyKeyword */, + as: 127 /* AsKeyword */, + asserts: 128 /* AssertsKeyword */, + bigint: 156 /* BigIntKeyword */, + boolean: 132 /* BooleanKeyword */, + break: 81 /* BreakKeyword */, + case: 82 /* CaseKeyword */, + catch: 83 /* CatchKeyword */, + class: 84 /* ClassKeyword */, + continue: 86 /* ContinueKeyword */, + const: 85 /* ConstKeyword */ }, - _a["" + "constructor"] = 132 /* ConstructorKeyword */, - _a.debugger = 86 /* DebuggerKeyword */, - _a.declare = 133 /* DeclareKeyword */, - _a.default = 87 /* DefaultKeyword */, - _a.delete = 88 /* DeleteKeyword */, - _a.do = 89 /* DoKeyword */, - _a.else = 90 /* ElseKeyword */, - _a.enum = 91 /* EnumKeyword */, - _a.export = 92 /* ExportKeyword */, - _a.extends = 93 /* ExtendsKeyword */, - _a.false = 94 /* FalseKeyword */, - _a.finally = 95 /* FinallyKeyword */, - _a.for = 96 /* ForKeyword */, - _a.from = 153 /* FromKeyword */, - _a.function = 97 /* FunctionKeyword */, - _a.get = 134 /* GetKeyword */, - _a.if = 98 /* IfKeyword */, - _a.implements = 116 /* ImplementsKeyword */, - _a.import = 99 /* ImportKeyword */, - _a.in = 100 /* InKeyword */, - _a.infer = 135 /* InferKeyword */, - _a.instanceof = 101 /* InstanceOfKeyword */, - _a.interface = 117 /* InterfaceKeyword */, - _a.intrinsic = 136 /* IntrinsicKeyword */, - _a.is = 137 /* IsKeyword */, - _a.keyof = 138 /* KeyOfKeyword */, - _a.let = 118 /* LetKeyword */, - _a.module = 139 /* ModuleKeyword */, - _a.namespace = 140 /* NamespaceKeyword */, - _a.never = 141 /* NeverKeyword */, - _a.new = 102 /* NewKeyword */, - _a.null = 103 /* NullKeyword */, - _a.number = 144 /* NumberKeyword */, - _a.object = 145 /* ObjectKeyword */, - _a.package = 119 /* PackageKeyword */, - _a.private = 120 /* PrivateKeyword */, - _a.protected = 121 /* ProtectedKeyword */, - _a.public = 122 /* PublicKeyword */, - _a.override = 156 /* OverrideKeyword */, - _a.readonly = 142 /* ReadonlyKeyword */, - _a.require = 143 /* RequireKeyword */, - _a.global = 154 /* GlobalKeyword */, - _a.return = 104 /* ReturnKeyword */, - _a.set = 146 /* SetKeyword */, - _a.static = 123 /* StaticKeyword */, - _a.string = 147 /* StringKeyword */, - _a.super = 105 /* SuperKeyword */, - _a.switch = 106 /* SwitchKeyword */, - _a.symbol = 148 /* SymbolKeyword */, - _a.this = 107 /* ThisKeyword */, - _a.throw = 108 /* ThrowKeyword */, - _a.true = 109 /* TrueKeyword */, - _a.try = 110 /* TryKeyword */, - _a.type = 149 /* TypeKeyword */, - _a.typeof = 111 /* TypeOfKeyword */, - _a.undefined = 150 /* UndefinedKeyword */, - _a.unique = 151 /* UniqueKeyword */, - _a.unknown = 152 /* UnknownKeyword */, - _a.var = 112 /* VarKeyword */, - _a.void = 113 /* VoidKeyword */, - _a.while = 114 /* WhileKeyword */, - _a.with = 115 /* WithKeyword */, - _a.yield = 124 /* YieldKeyword */, - _a.async = 129 /* AsyncKeyword */, - _a.await = 130 /* AwaitKeyword */, - _a.of = 157 /* OfKeyword */, + _a["" + "constructor"] = 133 /* ConstructorKeyword */, + _a.debugger = 87 /* DebuggerKeyword */, + _a.declare = 134 /* DeclareKeyword */, + _a.default = 88 /* DefaultKeyword */, + _a.delete = 89 /* DeleteKeyword */, + _a.do = 90 /* DoKeyword */, + _a.else = 91 /* ElseKeyword */, + _a.enum = 92 /* EnumKeyword */, + _a.export = 93 /* ExportKeyword */, + _a.extends = 94 /* ExtendsKeyword */, + _a.false = 95 /* FalseKeyword */, + _a.finally = 96 /* FinallyKeyword */, + _a.for = 97 /* ForKeyword */, + _a.from = 154 /* FromKeyword */, + _a.function = 98 /* FunctionKeyword */, + _a.get = 135 /* GetKeyword */, + _a.if = 99 /* IfKeyword */, + _a.implements = 117 /* ImplementsKeyword */, + _a.import = 100 /* ImportKeyword */, + _a.in = 101 /* InKeyword */, + _a.infer = 136 /* InferKeyword */, + _a.instanceof = 102 /* InstanceOfKeyword */, + _a.interface = 118 /* InterfaceKeyword */, + _a.intrinsic = 137 /* IntrinsicKeyword */, + _a.is = 138 /* IsKeyword */, + _a.keyof = 139 /* KeyOfKeyword */, + _a.let = 119 /* LetKeyword */, + _a.module = 140 /* ModuleKeyword */, + _a.namespace = 141 /* NamespaceKeyword */, + _a.never = 142 /* NeverKeyword */, + _a.new = 103 /* NewKeyword */, + _a.null = 104 /* NullKeyword */, + _a.number = 145 /* NumberKeyword */, + _a.object = 146 /* ObjectKeyword */, + _a.package = 120 /* PackageKeyword */, + _a.private = 121 /* PrivateKeyword */, + _a.protected = 122 /* ProtectedKeyword */, + _a.public = 123 /* PublicKeyword */, + _a.override = 157 /* OverrideKeyword */, + _a.readonly = 143 /* ReadonlyKeyword */, + _a.require = 144 /* RequireKeyword */, + _a.global = 155 /* GlobalKeyword */, + _a.return = 105 /* ReturnKeyword */, + _a.set = 147 /* SetKeyword */, + _a.static = 124 /* StaticKeyword */, + _a.string = 148 /* StringKeyword */, + _a.super = 106 /* SuperKeyword */, + _a.switch = 107 /* SwitchKeyword */, + _a.symbol = 149 /* SymbolKeyword */, + _a.this = 108 /* ThisKeyword */, + _a.throw = 109 /* ThrowKeyword */, + _a.true = 110 /* TrueKeyword */, + _a.try = 111 /* TryKeyword */, + _a.type = 150 /* TypeKeyword */, + _a.typeof = 112 /* TypeOfKeyword */, + _a.undefined = 151 /* UndefinedKeyword */, + _a.unique = 152 /* UniqueKeyword */, + _a.unknown = 153 /* UnknownKeyword */, + _a.var = 113 /* VarKeyword */, + _a.void = 114 /* VoidKeyword */, + _a.while = 115 /* WhileKeyword */, + _a.with = 116 /* WithKeyword */, + _a.yield = 125 /* YieldKeyword */, + _a.async = 130 /* AsyncKeyword */, + _a.await = 131 /* AwaitKeyword */, + _a.of = 158 /* OfKeyword */, _a); - var textToKeyword = new ts.Map(ts.getEntries(textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 77 /* CaretEqualsToken */, "||=": 74 /* BarBarEqualsToken */, "&&=": 75 /* AmpersandAmpersandEqualsToken */, "??=": 76 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ }))); + var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -9648,13 +9958,13 @@ var ts; var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; /** - * Test for whether a single line comment's text contains a directive. + * Test for whether a single line comment with leading whitespace trimmed's text contains a directive. */ - var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExSingleLine = /^\/\/\/?\s*@(ts-expect-error|ts-ignore)/; /** - * Test for whether a multi-line comment's last line contains a directive. + * Test for whether a multi-line comment with leading whitespace trimmed's last line contains a directive. */ - var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExMultiLine = /^(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -10268,8 +10578,8 @@ var ts; hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; }, - isIdentifier: function () { return token === 78 /* Identifier */ || token > 115 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */; }, + isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, @@ -10284,6 +10594,7 @@ var ts; reScanJsxAttributeValue: reScanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanHashToken: reScanHashToken, reScanQuestionToken: reScanQuestionToken, reScanInvalidIdentifier: reScanInvalidIdentifier, scanJsxToken: scanJsxToken, @@ -10794,7 +11105,7 @@ var ts; } } } - return token = 78 /* Identifier */; + return token = 79 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -10943,19 +11254,19 @@ var ts; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* PercentEqualsToken */; + return pos += 2, token = 69 /* PercentEqualsToken */; } pos++; return token = 44 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 75 /* AmpersandAmpersandEqualsToken */; + return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; } return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* AmpersandEqualsToken */; + return pos += 2, token = 73 /* AmpersandEqualsToken */; } pos++; return token = 50 /* AmpersandToken */; @@ -10967,11 +11278,11 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* AsteriskEqualsToken */; + return pos += 2, token = 66 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; } return pos += 2, token = 42 /* AsteriskAsteriskToken */; } @@ -10987,7 +11298,7 @@ var ts; return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* PlusEqualsToken */; + return pos += 2, token = 64 /* PlusEqualsToken */; } pos++; return token = 39 /* PlusToken */; @@ -10999,7 +11310,7 @@ var ts; return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* MinusEqualsToken */; + return pos += 2, token = 65 /* MinusEqualsToken */; } pos++; return token = 40 /* MinusToken */; @@ -11067,7 +11378,7 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* SlashEqualsToken */; + return pos += 2, token = 68 /* SlashEqualsToken */; } pos++; return token = 43 /* SlashToken */; @@ -11144,7 +11455,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; } return pos += 2, token = 47 /* LessThanLessThanToken */; } @@ -11178,7 +11489,7 @@ var ts; return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -11197,7 +11508,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 63 /* question */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* QuestionQuestionEqualsToken */; + return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; } return pos += 2, token = 60 /* QuestionQuestionToken */; } @@ -11211,7 +11522,7 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 77 /* CaretEqualsToken */; + return pos += 2, token = 78 /* CaretEqualsToken */; } pos++; return token = 52 /* CaretToken */; @@ -11230,12 +11541,12 @@ var ts; } if (text.charCodeAt(pos + 1) === 124 /* bar */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 74 /* BarBarEqualsToken */; + return pos += 3, token = 75 /* BarBarEqualsToken */; } return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* BarEqualsToken */; + return pos += 2, token = 74 /* BarEqualsToken */; } pos++; return token = 51 /* BarToken */; @@ -11272,21 +11583,15 @@ var ts; pos++; return token = 0 /* Unknown */; } - pos++; - if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) { + if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } + scanIdentifier(codePointAt(text, pos), languageVersion); } else { - tokenValue = "#"; - error(ts.Diagnostics.Invalid_character); + tokenValue = String.fromCharCode(codePointAt(text, pos)); + error(ts.Diagnostics.Invalid_character, pos++, charSize(ch)); } - return token = 79 /* PrivateIdentifier */; + return token = 80 /* PrivateIdentifier */; default: var identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { @@ -11301,8 +11606,9 @@ var ts; pos += charSize(ch); continue; } - error(ts.Diagnostics.Invalid_character); - pos += charSize(ch); + var size = charSize(ch); + error(ts.Diagnostics.Invalid_character, pos, size); + pos += size; return token = 0 /* Unknown */; } } @@ -11337,12 +11643,12 @@ 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 = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; } pos++; return token = 48 /* GreaterThanGreaterThanToken */; @@ -11355,12 +11661,12 @@ var ts; return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 65 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11410,7 +11716,7 @@ var ts; return token; } function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) { - var type = getDirectiveFromComment(text, commentDirectiveRegEx); + var type = getDirectiveFromComment(ts.trimStringStart(text), commentDirectiveRegEx); if (type === undefined) { return commentDirectives; } @@ -11456,6 +11762,13 @@ var ts; } return token; } + function reScanHashToken() { + if (token === 80 /* PrivateIdentifier */) { + pos = tokenPos + 1; + return token = 62 /* HashToken */; + } + return token; + } function reScanQuestionToken() { ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; @@ -11544,7 +11857,7 @@ var ts; tokenValue += ":"; pos++; namespaceSeparator = true; - token = 78 /* Identifier */; // swap from keyword kind to identifier kind + token = 79 /* Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -11619,13 +11932,15 @@ var ts; case 62 /* greaterThan */: return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; case 44 /* comma */: return token = 27 /* CommaToken */; case 46 /* dot */: return token = 24 /* DotToken */; case 96 /* backtick */: return token = 61 /* BacktickToken */; + case 35 /* hash */: + return token = 62 /* HashToken */; case 92 /* backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -12021,9 +12336,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 160 /* TypeParameter */) { + if (d && d.kind === 161 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 254 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 256 /* InterfaceDeclaration */) { return current; } } @@ -12031,7 +12346,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 167 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 169 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12061,14 +12376,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 250 /* VariableDeclaration */) { + if (node.kind === 252 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 251 /* VariableDeclarationList */) { + if (node && node.kind === 253 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 233 /* VariableStatement */) { + if (node && node.kind === 235 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12241,30 +12556,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 217 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + if (expr.kind === 219 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: return expr.name; - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 208 /* ParenthesizedExpression */: { + case 210 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 246 /* LabeledStatement */: { + case 248 /* LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12299,18 +12614,18 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return declaration; - case 337 /* JSDocPropertyTag */: - case 330 /* JSDocParameterTag */: { + case 342 /* JSDocPropertyTag */: + case 335 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 158 /* QualifiedName */) { + if (name.kind === 159 /* QualifiedName */) { return name.right; } break; } - case 204 /* CallExpression */: - case 217 /* BinaryExpression */: { + case 206 /* CallExpression */: + case 219 /* BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: @@ -12326,15 +12641,15 @@ var ts; return undefined; } } - case 335 /* JSDocTypedefTag */: + case 340 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 329 /* JSDocEnumTag */: + case 334 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 267 /* ExportAssignment */: { + case 269 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -12628,7 +12943,8 @@ var ts; function getTextOfJSDocComment(comment) { return typeof comment === "string" ? comment : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { - return c.kind === 313 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}"; + // TODO: Other kinds here + return c.kind === 316 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}"; }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; @@ -12641,7 +12957,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 312 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 315 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12668,12 +12984,12 @@ var ts; ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region function isMemberName(node) { - return node.kind === 78 /* Identifier */ || node.kind === 79 /* PrivateIdentifier */; + return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; } ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 169 /* SetAccessor */ || node.kind === 168 /* GetAccessor */; + return node.kind === 171 /* SetAccessor */ || node.kind === 170 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { @@ -12691,10 +13007,10 @@ var ts; function isOptionalChain(node) { var kind = node.kind; return !!(node.flags & 32 /* OptionalChain */) && - (kind === 202 /* PropertyAccessExpression */ - || kind === 203 /* ElementAccessExpression */ - || kind === 204 /* CallExpression */ - || kind === 226 /* NonNullExpression */); + (kind === 204 /* PropertyAccessExpression */ + || kind === 205 /* ElementAccessExpression */ + || kind === 206 /* CallExpression */ + || kind === 228 /* NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -12729,7 +13045,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 217 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 219 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -12746,17 +13062,17 @@ var ts; } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 242 /* BreakStatement */ || node.kind === 241 /* ContinueStatement */; + return node.kind === 244 /* BreakStatement */ || node.kind === 243 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 270 /* NamespaceExport */ || node.kind === 269 /* NamedExports */; + return node.kind === 272 /* NamespaceExport */ || node.kind === 271 /* NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 295 /* UnparsedText */: - case 296 /* UnparsedInternalText */: + case 297 /* UnparsedText */: + case 298 /* UnparsedInternalText */: return true; default: return false; @@ -12765,12 +13081,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 293 /* UnparsedPrologue */ || - node.kind === 297 /* UnparsedSyntheticReference */; + node.kind === 295 /* UnparsedPrologue */ || + node.kind === 299 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 337 /* JSDocPropertyTag */ || node.kind === 330 /* JSDocParameterTag */; + return node.kind === 342 /* JSDocPropertyTag */ || node.kind === 335 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -12786,7 +13102,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 158 /* FirstNode */; + return kind >= 159 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -12795,7 +13111,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 157 /* LastToken */; + return kind >= 0 /* FirstToken */ && kind <= 158 /* LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -12845,13 +13161,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 266 /* ImportSpecifier */: - case 271 /* ExportSpecifier */: + case 268 /* ImportSpecifier */: + case 273 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: return node.parent.isTypeOnly; - case 263 /* ImportClause */: - case 261 /* ImportEqualsDeclaration */: + case 265 /* ImportClause */: + case 263 /* ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -12883,18 +13199,18 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 87 /* DefaultKeyword */: - case 92 /* ExportKeyword */: - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 123 /* StaticKeyword */: - case 156 /* OverrideKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 88 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 124 /* StaticKeyword */: + case 157 /* OverrideKeyword */: return true; } return false; @@ -12907,7 +13223,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 123 /* StaticKeyword */ || idToken === 156 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 157 /* OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -12916,24 +13232,24 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 158 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 79 /* PrivateIdentifier */ + return kind === 79 /* Identifier */ + || kind === 80 /* PrivateIdentifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 159 /* ComputedPropertyName */; + || kind === 160 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 197 /* ObjectBindingPattern */ - || kind === 198 /* ArrayBindingPattern */; + return kind === 79 /* Identifier */ + || kind === 199 /* ObjectBindingPattern */ + || kind === 200 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -12942,19 +13258,29 @@ var ts; } ts.isFunctionLike = isFunctionLike; /* @internal */ + function isFunctionLikeOrClassStaticBlockDeclaration(node) { + return !!node && (isFunctionLikeKind(node.kind) || ts.isClassStaticBlockDeclaration(node)); + } + ts.isFunctionLikeOrClassStaticBlockDeclaration = isFunctionLikeOrClassStaticBlockDeclaration; + /* @internal */ function isFunctionLikeDeclaration(node) { return node && isFunctionLikeDeclarationKind(node.kind); } ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; + /* @internal */ + function isBooleanLiteral(node) { + return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */; + } + ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 252 /* FunctionDeclaration */: - case 166 /* MethodDeclaration */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 254 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: return true; default: return false; @@ -12963,14 +13289,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 165 /* MethodSignature */: - case 170 /* CallSignature */: - case 315 /* JSDocSignature */: - case 171 /* ConstructSignature */: - case 172 /* IndexSignature */: - case 175 /* FunctionType */: - case 309 /* JSDocFunctionType */: - case 176 /* ConstructorType */: + case 166 /* MethodSignature */: + case 172 /* CallSignature */: + case 318 /* JSDocSignature */: + case 173 /* ConstructSignature */: + case 174 /* IndexSignature */: + case 177 /* FunctionType */: + case 312 /* JSDocFunctionType */: + case 178 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -12985,29 +13311,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 167 /* Constructor */ - || kind === 164 /* PropertyDeclaration */ - || kind === 166 /* MethodDeclaration */ - || kind === 168 /* GetAccessor */ - || kind === 169 /* SetAccessor */ - || kind === 172 /* IndexSignature */ - || kind === 230 /* SemicolonClassElement */; + return kind === 169 /* Constructor */ + || kind === 165 /* PropertyDeclaration */ + || kind === 167 /* MethodDeclaration */ + || kind === 170 /* GetAccessor */ + || kind === 171 /* SetAccessor */ + || kind === 174 /* IndexSignature */ + || kind === 168 /* ClassStaticBlockDeclaration */ + || kind === 232 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 253 /* ClassDeclaration */ || node.kind === 222 /* ClassExpression */); + return node && (node.kind === 255 /* ClassDeclaration */ || node.kind === 224 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 168 /* GetAccessor */ || node.kind === 169 /* SetAccessor */); + return node && (node.kind === 170 /* GetAccessor */ || node.kind === 171 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return true; default: return false; @@ -13017,11 +13344,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 171 /* ConstructSignature */ - || kind === 170 /* CallSignature */ - || kind === 163 /* PropertySignature */ - || kind === 165 /* MethodSignature */ - || kind === 172 /* IndexSignature */; + return kind === 173 /* ConstructSignature */ + || kind === 172 /* CallSignature */ + || kind === 164 /* PropertySignature */ + || kind === 166 /* MethodSignature */ + || kind === 174 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13030,12 +13357,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 289 /* PropertyAssignment */ - || kind === 290 /* ShorthandPropertyAssignment */ - || kind === 291 /* SpreadAssignment */ - || kind === 166 /* MethodDeclaration */ - || kind === 168 /* GetAccessor */ - || kind === 169 /* SetAccessor */; + return kind === 291 /* PropertyAssignment */ + || kind === 292 /* ShorthandPropertyAssignment */ + || kind === 293 /* SpreadAssignment */ + || kind === 167 /* MethodDeclaration */ + || kind === 170 /* GetAccessor */ + || kind === 171 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13050,8 +13377,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 175 /* FunctionType */: - case 176 /* ConstructorType */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: return true; } return false; @@ -13062,8 +13389,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 198 /* ArrayBindingPattern */ - || kind === 197 /* ObjectBindingPattern */; + return kind === 200 /* ArrayBindingPattern */ + || kind === 199 /* ObjectBindingPattern */; } return false; } @@ -13071,15 +13398,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 200 /* ArrayLiteralExpression */ - || kind === 201 /* ObjectLiteralExpression */; + return kind === 202 /* ArrayLiteralExpression */ + || kind === 203 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 199 /* BindingElement */ - || kind === 223 /* OmittedExpression */; + return kind === 201 /* BindingElement */ + || kind === 225 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13088,9 +13415,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 250 /* VariableDeclaration */: - case 161 /* Parameter */: - case 199 /* BindingElement */: + case 252 /* VariableDeclaration */: + case 162 /* Parameter */: + case 201 /* BindingElement */: return true; } return false; @@ -13111,21 +13438,33 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 197 /* ObjectBindingPattern */: - case 201 /* ObjectLiteralExpression */: + case 199 /* ObjectBindingPattern */: + case 203 /* ObjectLiteralExpression */: return true; } return false; } ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; + /* @internal */ + function isObjectBindingOrAssignmentElement(node) { + switch (node.kind) { + case 201 /* BindingElement */: + case 291 /* PropertyAssignment */: // AssignmentProperty + case 292 /* ShorthandPropertyAssignment */: // AssignmentProperty + case 293 /* SpreadAssignment */: // AssignmentRestProperty + return true; + } + return false; + } + ts.isObjectBindingOrAssignmentElement = isObjectBindingOrAssignmentElement; /** * Determines whether a node is an ArrayBindingOrAssignmentPattern */ /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 198 /* ArrayBindingPattern */: - case 200 /* ArrayLiteralExpression */: + case 200 /* ArrayBindingPattern */: + case 202 /* ArrayLiteralExpression */: return true; } return false; @@ -13134,26 +13473,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 202 /* PropertyAccessExpression */ - || kind === 158 /* QualifiedName */ - || kind === 196 /* ImportType */; + return kind === 204 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */ + || kind === 198 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 202 /* PropertyAccessExpression */ - || kind === 158 /* QualifiedName */; + return kind === 204 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 276 /* JsxOpeningElement */: - case 275 /* JsxSelfClosingElement */: - case 204 /* CallExpression */: - case 205 /* NewExpression */: - case 206 /* TaggedTemplateExpression */: - case 162 /* Decorator */: + case 278 /* JsxOpeningElement */: + case 277 /* JsxSelfClosingElement */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: + case 208 /* TaggedTemplateExpression */: + case 163 /* Decorator */: return true; default: return false; @@ -13161,12 +13500,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 204 /* CallExpression */ || node.kind === 205 /* NewExpression */; + return node.kind === 206 /* CallExpression */ || node.kind === 207 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 219 /* TemplateExpression */ + return kind === 221 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -13177,34 +13516,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: - case 205 /* NewExpression */: - case 204 /* CallExpression */: - case 274 /* JsxElement */: - case 275 /* JsxSelfClosingElement */: - case 278 /* JsxFragment */: - case 206 /* TaggedTemplateExpression */: - case 200 /* ArrayLiteralExpression */: - case 208 /* ParenthesizedExpression */: - case 201 /* ObjectLiteralExpression */: - case 222 /* ClassExpression */: - case 209 /* FunctionExpression */: - case 78 /* Identifier */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: + case 207 /* NewExpression */: + case 206 /* CallExpression */: + case 276 /* JsxElement */: + case 277 /* JsxSelfClosingElement */: + case 280 /* JsxFragment */: + case 208 /* TaggedTemplateExpression */: + case 202 /* ArrayLiteralExpression */: + case 210 /* ParenthesizedExpression */: + case 203 /* ObjectLiteralExpression */: + case 224 /* ClassExpression */: + case 211 /* FunctionExpression */: + case 79 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 219 /* TemplateExpression */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 109 /* TrueKeyword */: - case 105 /* SuperKeyword */: - case 226 /* NonNullExpression */: - case 227 /* MetaProperty */: - case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 221 /* TemplateExpression */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 110 /* TrueKeyword */: + case 106 /* SuperKeyword */: + case 228 /* NonNullExpression */: + case 229 /* MetaProperty */: + case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13217,13 +13556,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 215 /* PrefixUnaryExpression */: - case 216 /* PostfixUnaryExpression */: - case 211 /* DeleteExpression */: - case 212 /* TypeOfExpression */: - case 213 /* VoidExpression */: - case 214 /* AwaitExpression */: - case 207 /* TypeAssertionExpression */: + case 217 /* PrefixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: + case 213 /* DeleteExpression */: + case 214 /* TypeOfExpression */: + case 215 /* VoidExpression */: + case 216 /* AwaitExpression */: + case 209 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13232,9 +13571,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 216 /* PostfixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: return true; - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: return expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; default: @@ -13253,15 +13592,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 218 /* ConditionalExpression */: - case 220 /* YieldExpression */: - case 210 /* ArrowFunction */: - case 217 /* BinaryExpression */: - case 221 /* SpreadElement */: - case 225 /* AsExpression */: - case 223 /* OmittedExpression */: - case 341 /* CommaListExpression */: - case 340 /* PartiallyEmittedExpression */: + case 220 /* ConditionalExpression */: + case 222 /* YieldExpression */: + case 212 /* ArrowFunction */: + case 219 /* BinaryExpression */: + case 223 /* SpreadElement */: + case 227 /* AsExpression */: + case 225 /* OmittedExpression */: + case 346 /* CommaListExpression */: + case 345 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13269,8 +13608,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 207 /* TypeAssertionExpression */ - || kind === 225 /* AsExpression */; + return kind === 209 /* TypeAssertionExpression */ + || kind === 227 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13281,13 +13620,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 236 /* DoStatement */: - case 237 /* WhileStatement */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: return true; - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13316,7 +13655,7 @@ var ts; ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 239 /* ForInStatement */ || node.kind === 240 /* ForOfStatement */; + return node.kind === 241 /* ForInStatement */ || node.kind === 242 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13340,114 +13679,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 258 /* ModuleBlock */ - || kind === 257 /* ModuleDeclaration */ - || kind === 78 /* Identifier */; + return kind === 260 /* ModuleBlock */ + || kind === 259 /* ModuleDeclaration */ + || kind === 79 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 258 /* ModuleBlock */ - || kind === 257 /* ModuleDeclaration */; + return kind === 260 /* ModuleBlock */ + || kind === 259 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 257 /* ModuleDeclaration */; + return kind === 79 /* Identifier */ + || kind === 259 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 265 /* NamedImports */ - || kind === 264 /* NamespaceImport */; + return kind === 267 /* NamedImports */ + || kind === 266 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 257 /* ModuleDeclaration */ || node.kind === 256 /* EnumDeclaration */; + return node.kind === 259 /* ModuleDeclaration */ || node.kind === 258 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 210 /* ArrowFunction */ - || kind === 199 /* BindingElement */ - || kind === 253 /* ClassDeclaration */ - || kind === 222 /* ClassExpression */ - || kind === 167 /* Constructor */ - || kind === 256 /* EnumDeclaration */ - || kind === 292 /* EnumMember */ - || kind === 271 /* ExportSpecifier */ - || kind === 252 /* FunctionDeclaration */ - || kind === 209 /* FunctionExpression */ - || kind === 168 /* GetAccessor */ - || kind === 263 /* ImportClause */ - || kind === 261 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportSpecifier */ - || kind === 254 /* InterfaceDeclaration */ - || kind === 281 /* JsxAttribute */ - || kind === 166 /* MethodDeclaration */ - || kind === 165 /* MethodSignature */ - || kind === 257 /* ModuleDeclaration */ - || kind === 260 /* NamespaceExportDeclaration */ - || kind === 264 /* NamespaceImport */ - || kind === 270 /* NamespaceExport */ - || kind === 161 /* Parameter */ - || kind === 289 /* PropertyAssignment */ - || kind === 164 /* PropertyDeclaration */ - || kind === 163 /* PropertySignature */ - || kind === 169 /* SetAccessor */ - || kind === 290 /* ShorthandPropertyAssignment */ - || kind === 255 /* TypeAliasDeclaration */ - || kind === 160 /* TypeParameter */ - || kind === 250 /* VariableDeclaration */ - || kind === 335 /* JSDocTypedefTag */ - || kind === 328 /* JSDocCallbackTag */ - || kind === 337 /* JSDocPropertyTag */; + return kind === 212 /* ArrowFunction */ + || kind === 201 /* BindingElement */ + || kind === 255 /* ClassDeclaration */ + || kind === 224 /* ClassExpression */ + || kind === 168 /* ClassStaticBlockDeclaration */ + || kind === 169 /* Constructor */ + || kind === 258 /* EnumDeclaration */ + || kind === 294 /* EnumMember */ + || kind === 273 /* ExportSpecifier */ + || kind === 254 /* FunctionDeclaration */ + || kind === 211 /* FunctionExpression */ + || kind === 170 /* GetAccessor */ + || kind === 265 /* ImportClause */ + || kind === 263 /* ImportEqualsDeclaration */ + || kind === 268 /* ImportSpecifier */ + || kind === 256 /* InterfaceDeclaration */ + || kind === 283 /* JsxAttribute */ + || kind === 167 /* MethodDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 259 /* ModuleDeclaration */ + || kind === 262 /* NamespaceExportDeclaration */ + || kind === 266 /* NamespaceImport */ + || kind === 272 /* NamespaceExport */ + || kind === 162 /* Parameter */ + || kind === 291 /* PropertyAssignment */ + || kind === 165 /* PropertyDeclaration */ + || kind === 164 /* PropertySignature */ + || kind === 171 /* SetAccessor */ + || kind === 292 /* ShorthandPropertyAssignment */ + || kind === 257 /* TypeAliasDeclaration */ + || kind === 161 /* TypeParameter */ + || kind === 252 /* VariableDeclaration */ + || kind === 340 /* JSDocTypedefTag */ + || kind === 333 /* JSDocCallbackTag */ + || kind === 342 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 252 /* FunctionDeclaration */ - || kind === 272 /* MissingDeclaration */ - || kind === 253 /* ClassDeclaration */ - || kind === 254 /* InterfaceDeclaration */ - || kind === 255 /* TypeAliasDeclaration */ - || kind === 256 /* EnumDeclaration */ - || kind === 257 /* ModuleDeclaration */ - || kind === 262 /* ImportDeclaration */ - || kind === 261 /* ImportEqualsDeclaration */ - || kind === 268 /* ExportDeclaration */ - || kind === 267 /* ExportAssignment */ - || kind === 260 /* NamespaceExportDeclaration */; + return kind === 254 /* FunctionDeclaration */ + || kind === 274 /* MissingDeclaration */ + || kind === 255 /* ClassDeclaration */ + || kind === 256 /* InterfaceDeclaration */ + || kind === 257 /* TypeAliasDeclaration */ + || kind === 258 /* EnumDeclaration */ + || kind === 259 /* ModuleDeclaration */ + || kind === 264 /* ImportDeclaration */ + || kind === 263 /* ImportEqualsDeclaration */ + || kind === 270 /* ExportDeclaration */ + || kind === 269 /* ExportAssignment */ + || kind === 262 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 242 /* BreakStatement */ - || kind === 241 /* ContinueStatement */ - || kind === 249 /* DebuggerStatement */ - || kind === 236 /* DoStatement */ - || kind === 234 /* ExpressionStatement */ - || kind === 232 /* EmptyStatement */ - || kind === 239 /* ForInStatement */ - || kind === 240 /* ForOfStatement */ - || kind === 238 /* ForStatement */ - || kind === 235 /* IfStatement */ - || kind === 246 /* LabeledStatement */ - || kind === 243 /* ReturnStatement */ - || kind === 245 /* SwitchStatement */ - || kind === 247 /* ThrowStatement */ - || kind === 248 /* TryStatement */ - || kind === 233 /* VariableStatement */ - || kind === 237 /* WhileStatement */ - || kind === 244 /* WithStatement */ - || kind === 339 /* NotEmittedStatement */ - || kind === 343 /* EndOfDeclarationMarker */ - || kind === 342 /* MergeDeclarationMarker */; + return kind === 244 /* BreakStatement */ + || kind === 243 /* ContinueStatement */ + || kind === 251 /* DebuggerStatement */ + || kind === 238 /* DoStatement */ + || kind === 236 /* ExpressionStatement */ + || kind === 234 /* EmptyStatement */ + || kind === 241 /* ForInStatement */ + || kind === 242 /* ForOfStatement */ + || kind === 240 /* ForStatement */ + || kind === 237 /* IfStatement */ + || kind === 248 /* LabeledStatement */ + || kind === 245 /* ReturnStatement */ + || kind === 247 /* SwitchStatement */ + || kind === 249 /* ThrowStatement */ + || kind === 250 /* TryStatement */ + || kind === 235 /* VariableStatement */ + || kind === 239 /* WhileStatement */ + || kind === 246 /* WithStatement */ + || kind === 344 /* NotEmittedStatement */ + || kind === 348 /* EndOfDeclarationMarker */ + || kind === 347 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 160 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 334 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 161 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 339 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -13474,10 +13814,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 231 /* Block */) + if (node.kind !== 233 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 248 /* TryStatement */ || node.parent.kind === 288 /* CatchClause */) { + if (node.parent.kind === 250 /* TryStatement */ || node.parent.kind === 290 /* CatchClause */) { return false; } } @@ -13491,77 +13831,77 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 231 /* Block */; + || kind === 233 /* Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 273 /* ExternalModuleReference */ - || kind === 158 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 275 /* ExternalModuleReference */ + || kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 107 /* ThisKeyword */ - || kind === 78 /* Identifier */ - || kind === 202 /* PropertyAccessExpression */; + return kind === 108 /* ThisKeyword */ + || kind === 79 /* Identifier */ + || kind === 204 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 274 /* JsxElement */ - || kind === 284 /* JsxExpression */ - || kind === 275 /* JsxSelfClosingElement */ + return kind === 276 /* JsxElement */ + || kind === 286 /* JsxExpression */ + || kind === 277 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 278 /* JsxFragment */; + || kind === 280 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 281 /* JsxAttribute */ - || kind === 283 /* JsxSpreadAttribute */; + return kind === 283 /* JsxAttribute */ + || kind === 285 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 284 /* JsxExpression */; + || kind === 286 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 276 /* JsxOpeningElement */ - || kind === 275 /* JsxSelfClosingElement */; + return kind === 278 /* JsxOpeningElement */ + || kind === 277 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 285 /* CaseClause */ - || kind === 286 /* DefaultClause */; + return kind === 287 /* CaseClause */ + || kind === 288 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 302 /* FirstJSDocNode */ && node.kind <= 337 /* LastJSDocNode */; + return node.kind >= 304 /* FirstJSDocNode */ && node.kind <= 342 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 312 /* JSDocComment */ - || node.kind === 311 /* JSDocNamepathType */ - || node.kind === 313 /* JSDocText */ - || node.kind === 316 /* JSDocLink */ + return node.kind === 315 /* JSDocComment */ + || node.kind === 314 /* JSDocNamepathType */ + || node.kind === 316 /* JSDocText */ + || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); @@ -13570,15 +13910,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 317 /* FirstJSDocTagNode */ && node.kind <= 337 /* LastJSDocTagNode */; + return node.kind >= 322 /* FirstJSDocTagNode */ && node.kind <= 342 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 169 /* SetAccessor */; + return node.kind === 171 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 168 /* GetAccessor */; + return node.kind === 170 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -13604,13 +13944,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 250 /* VariableDeclaration */: - case 161 /* Parameter */: - case 199 /* BindingElement */: - case 163 /* PropertySignature */: - case 164 /* PropertyDeclaration */: - case 289 /* PropertyAssignment */: - case 292 /* EnumMember */: + case 252 /* VariableDeclaration */: + case 162 /* Parameter */: + case 201 /* BindingElement */: + case 164 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 291 /* PropertyAssignment */: + case 294 /* EnumMember */: return true; default: return false; @@ -13618,12 +13958,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 281 /* JsxAttribute */ || node.kind === 283 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 283 /* JsxAttribute */ || node.kind === 285 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 174 /* TypeReference */ || node.kind === 224 /* ExpressionWithTypeArguments */; + return node.kind === 176 /* TypeReference */ || node.kind === 226 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13655,6 +13995,10 @@ var ts; return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; + function isJSDocLinkLike(node) { + return node.kind === 319 /* JSDocLink */ || node.kind === 320 /* JSDocLinkCode */ || node.kind === 321 /* JSDocLinkPlain */; + } + ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion })(ts || (ts = {})); /* @internal */ @@ -13739,7 +14083,7 @@ var ts; increaseIndent: ts.noop, decreaseIndent: ts.noop, clear: function () { return str = ""; }, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -13751,11 +14095,19 @@ var ts; } ts.changesAffectModuleResolution = changesAffectModuleResolution; function optionsHaveModuleResolutionChanges(oldOptions, newOptions) { - return ts.moduleResolutionOptionDeclarations.some(function (o) { + return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations); + } + ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + function changesAffectingProgramStructure(oldOptions, newOptions) { + return optionsHaveChanges(oldOptions, newOptions, ts.optionsAffectingProgramStructure); + } + ts.changesAffectingProgramStructure = changesAffectingProgramStructure; + function optionsHaveChanges(oldOptions, newOptions, optionDeclarations) { + return oldOptions !== newOptions && optionDeclarations.some(function (o) { return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o)); }); } - ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + ts.optionsHaveChanges = optionsHaveChanges; function forEachAncestor(node, callback) { while (true) { var res = callback(node); @@ -13906,19 +14258,23 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 298 /* SourceFile */) { + while (node && node.kind !== 300 /* SourceFile */) { node = node.parent; } return node; } ts.getSourceFileOfNode = getSourceFileOfNode; + function getSourceFileOfModule(module) { + return getSourceFileOfNode(module.valueDeclaration || getNonAugmentationDeclaration(module)); + } + ts.getSourceFileOfModule = getSourceFileOfModule; function isStatementWithLocals(node) { switch (node.kind) { - case 231 /* Block */: - case 259 /* CaseBlock */: - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: + case 233 /* Block */: + case 261 /* CaseBlock */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: return true; } return false; @@ -14003,7 +14359,7 @@ var ts; break; } } - to.splice.apply(to, __spreadArray([statementIndex, 0], from)); + to.splice.apply(to, __spreadArray([statementIndex, 0], from, false)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -14056,10 +14412,10 @@ var ts; commentPos + 2 < commentEnd && text.charCodeAt(commentPos + 2) === 47 /* slash */) { var textSubStr = text.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || - textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || - textSubStr.match(defaultLibReferenceRegEx) ? + return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || + ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || + fullTripleSlashReferenceTypeReferenceDirectiveRegEx.test(textSubStr) || + defaultLibReferenceRegEx.test(textSubStr) ? true : false; } return false; @@ -14114,7 +14470,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 338 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 343 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -14149,7 +14505,7 @@ var ts; var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end); if (isJSDocTypeExpressionOrChild(node)) { // strip space + asterisk at line start - text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1"); + text = text.split(/\r\n|\n|\r/).map(function (line) { return ts.trimStringStart(line.replace(/^\s*\*/, "")); }).join("\n"); } return text; } @@ -14257,6 +14613,7 @@ var ts; GetLiteralTextFlags[GetLiteralTextFlags["AllowNumericSeparator"] = 8] = "AllowNumericSeparator"; })(GetLiteralTextFlags = ts.GetLiteralTextFlags || (ts.GetLiteralTextFlags = {})); function getLiteralText(node, sourceFile, flags) { + var _a; // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. if (canUseOriginalText(node, flags)) { @@ -14284,7 +14641,7 @@ var ts; // had to include a backslash: `not \${a} substitution`. var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; - var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); switch (node.kind) { case 14 /* NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; @@ -14335,7 +14692,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 250 /* VariableDeclaration */ && node.parent.kind === 288 /* CatchClause */; + return node.kind === 252 /* VariableDeclaration */ && node.parent.kind === 290 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -14367,12 +14724,12 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return !!node && node.kind === 257 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 259 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 298 /* SourceFile */ || - node.kind === 257 /* ModuleDeclaration */ || - ts.isFunctionLike(node); + return node.kind === 300 /* SourceFile */ || + node.kind === 259 /* ModuleDeclaration */ || + ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { @@ -14388,9 +14745,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 298 /* SourceFile */: + case 300 /* SourceFile */: return ts.isExternalModule(node.parent); - case 258 /* ModuleBlock */: + case 260 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -14444,34 +14801,36 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 298 /* SourceFile */: - case 259 /* CaseBlock */: - case 288 /* CatchClause */: - case 257 /* ModuleDeclaration */: - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 167 /* Constructor */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 300 /* SourceFile */: + case 261 /* CaseBlock */: + case 290 /* CatchClause */: + case 259 /* ModuleDeclaration */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 169 /* Constructor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 165 /* PropertyDeclaration */: + case 168 /* ClassStaticBlockDeclaration */: return true; - case 231 /* Block */: + case 233 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block - return !ts.isFunctionLike(parentNode); + return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); } return false; } ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 328 /* JSDocCallbackTag */: - case 335 /* JSDocTypedefTag */: - case 315 /* JSDocSignature */: + case 333 /* JSDocCallbackTag */: + case 340 /* JSDocTypedefTag */: + case 318 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -14481,25 +14840,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 165 /* MethodSignature */: - case 172 /* IndexSignature */: - case 175 /* FunctionType */: - case 176 /* ConstructorType */: - case 309 /* JSDocFunctionType */: - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 334 /* JSDocTemplateTag */: - case 252 /* FunctionDeclaration */: - case 166 /* MethodDeclaration */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 174 /* IndexSignature */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: + case 312 /* JSDocFunctionType */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 339 /* JSDocTemplateTag */: + case 254 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -14509,8 +14868,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 262 /* ImportDeclaration */: - case 261 /* ImportEqualsDeclaration */: + case 264 /* ImportDeclaration */: + case 263 /* ImportEqualsDeclaration */: return true; default: return false; @@ -14519,15 +14878,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 262 /* ImportDeclaration */: - case 261 /* ImportEqualsDeclaration */: - case 233 /* VariableStatement */: - case 253 /* ClassDeclaration */: - case 252 /* FunctionDeclaration */: - case 257 /* ModuleDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 254 /* InterfaceDeclaration */: - case 256 /* EnumDeclaration */: + case 264 /* ImportDeclaration */: + case 263 /* ImportEqualsDeclaration */: + case 235 /* VariableStatement */: + case 255 /* ClassDeclaration */: + case 254 /* FunctionDeclaration */: + case 259 /* ModuleDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 256 /* InterfaceDeclaration */: + case 258 /* EnumDeclaration */: return true; default: return false; @@ -14548,6 +14907,14 @@ var ts; return ts.findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); }); } ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; + function forEachEnclosingBlockScopeContainer(node, cb) { + var container = getEnclosingBlockScopeContainer(node); + while (container) { + cb(container); + container = getEnclosingBlockScopeContainer(container); + } + } + ts.forEachEnclosingBlockScopeContainer = forEachEnclosingBlockScopeContainer; // Return display name of an identifier // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. @@ -14560,19 +14927,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 159 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 160 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function getTextOfPropertyName(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -14583,20 +14950,22 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return "this"; - case 79 /* PrivateIdentifier */: - case 78 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 79 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } + case 306 /* JSDocMemberName */: + return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); } @@ -14676,7 +15045,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 231 /* Block */) { + if (node.body && node.body.kind === 233 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -14690,7 +15059,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 298 /* SourceFile */: + case 300 /* 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 @@ -14699,28 +15068,29 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 250 /* VariableDeclaration */: - case 199 /* BindingElement */: - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: - case 257 /* ModuleDeclaration */: - case 256 /* EnumDeclaration */: - case 292 /* EnumMember */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 255 /* TypeAliasDeclaration */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: + case 252 /* VariableDeclaration */: + case 201 /* BindingElement */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: + case 259 /* ModuleDeclaration */: + case 258 /* EnumDeclaration */: + case 294 /* EnumMember */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 257 /* TypeAliasDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 266 /* NamespaceImport */: errorNode = node.name; break; - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 285 /* CaseClause */: - case 286 /* DefaultClause */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -14772,16 +15142,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 204 /* CallExpression */ && n.expression.kind === 105 /* SuperKeyword */; + return n.kind === 206 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 204 /* CallExpression */ && n.expression.kind === 99 /* ImportKeyword */; + return n.kind === 206 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 99 /* ImportKeyword */ + && n.keywordToken === 100 /* ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -14790,7 +15160,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 234 /* ExpressionStatement */ + return node.kind === 236 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -14818,12 +15188,12 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 161 /* Parameter */ || - node.kind === 160 /* TypeParameter */ || - node.kind === 209 /* FunctionExpression */ || - node.kind === 210 /* ArrowFunction */ || - node.kind === 208 /* ParenthesizedExpression */ || - node.kind === 250 /* VariableDeclaration */) ? + var commentRanges = (node.kind === 162 /* Parameter */ || + node.kind === 161 /* TypeParameter */ || + node.kind === 211 /* FunctionExpression */ || + node.kind === 212 /* ArrowFunction */ || + node.kind === 210 /* ParenthesizedExpression */ || + node.kind === 252 /* VariableDeclaration */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' @@ -14834,53 +15204,53 @@ var ts; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - var defaultLibReferenceRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (173 /* FirstTypeNode */ <= node.kind && node.kind <= 196 /* LastTypeNode */) { + if (175 /* FirstTypeNode */ <= node.kind && node.kind <= 198 /* LastTypeNode */) { return true; } switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return true; - case 113 /* VoidKeyword */: - return node.parent.kind !== 213 /* VoidExpression */; - case 224 /* ExpressionWithTypeArguments */: + case 114 /* VoidKeyword */: + return node.parent.kind !== 215 /* VoidExpression */; + case 226 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 160 /* TypeParameter */: - return node.parent.kind === 191 /* MappedType */ || node.parent.kind === 186 /* InferType */; + case 161 /* TypeParameter */: + return node.parent.kind === 193 /* MappedType */ || node.parent.kind === 188 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 78 /* Identifier */: + case 79 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 158 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 202 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 204 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 78 /* Identifier */ || node.kind === 158 /* QualifiedName */ || node.kind === 202 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */ || node.kind === 204 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 158 /* QualifiedName */: - case 202 /* PropertyAccessExpression */: - case 107 /* ThisKeyword */: { + case 159 /* QualifiedName */: + case 204 /* PropertyAccessExpression */: + case 108 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 177 /* TypeQuery */) { + if (parent.kind === 179 /* TypeQuery */) { return false; } - if (parent.kind === 196 /* ImportType */) { + if (parent.kind === 198 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -14889,40 +15259,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (173 /* FirstTypeNode */ <= parent.kind && parent.kind <= 196 /* LastTypeNode */) { + if (175 /* FirstTypeNode */ <= parent.kind && parent.kind <= 198 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 160 /* TypeParameter */: + case 161 /* TypeParameter */: return node === parent.constraint; - case 334 /* JSDocTemplateTag */: + case 339 /* JSDocTemplateTag */: return node === parent.constraint; - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 161 /* Parameter */: - case 250 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 162 /* Parameter */: + case 252 /* VariableDeclaration */: return node === parent.type; - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 167 /* Constructor */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 169 /* Constructor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return node === parent.type; - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 172 /* IndexSignature */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 174 /* IndexSignature */: return node === parent.type; - case 207 /* TypeAssertionExpression */: + case 209 /* TypeAssertionExpression */: return node === parent.type; - case 204 /* CallExpression */: - case 205 /* NewExpression */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -14947,23 +15317,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 243 /* ReturnStatement */: + case 245 /* ReturnStatement */: return visitor(node); - case 259 /* CaseBlock */: - case 231 /* Block */: - case 235 /* IfStatement */: - case 236 /* DoStatement */: - case 237 /* WhileStatement */: - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 244 /* WithStatement */: - case 245 /* SwitchStatement */: - case 285 /* CaseClause */: - case 286 /* DefaultClause */: - case 246 /* LabeledStatement */: - case 248 /* TryStatement */: - case 288 /* CatchClause */: + case 261 /* CaseBlock */: + case 233 /* Block */: + case 237 /* IfStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 246 /* WithStatement */: + case 247 /* SwitchStatement */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: + case 248 /* LabeledStatement */: + case 250 /* TryStatement */: + case 290 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -14973,23 +15343,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 220 /* YieldExpression */: + case 222 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 256 /* EnumDeclaration */: - case 254 /* InterfaceDeclaration */: - case 257 /* ModuleDeclaration */: - case 255 /* TypeAliasDeclaration */: + case 258 /* EnumDeclaration */: + case 256 /* InterfaceDeclaration */: + case 259 /* ModuleDeclaration */: + case 257 /* TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 159 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* 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(node.name.expression); @@ -15012,10 +15382,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 179 /* ArrayType */) { + if (node && node.kind === 181 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 174 /* TypeReference */) { + else if (node && node.kind === 176 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15025,12 +15395,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 254 /* InterfaceDeclaration */: - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 178 /* TypeLiteral */: + case 256 /* InterfaceDeclaration */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 180 /* TypeLiteral */: return node.members; - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return node.properties; } } @@ -15038,14 +15408,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 199 /* BindingElement */: - case 292 /* EnumMember */: - case 161 /* Parameter */: - case 289 /* PropertyAssignment */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 290 /* ShorthandPropertyAssignment */: - case 250 /* VariableDeclaration */: + case 201 /* BindingElement */: + case 294 /* EnumMember */: + case 162 /* Parameter */: + case 291 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 292 /* ShorthandPropertyAssignment */: + case 252 /* VariableDeclaration */: return true; } } @@ -15057,8 +15427,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 251 /* VariableDeclarationList */ - && node.parent.parent.kind === 233 /* VariableStatement */; + return node.parent.kind === 253 /* VariableDeclarationList */ + && node.parent.parent.kind === 235 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -15069,13 +15439,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: return true; } return false; @@ -15086,7 +15456,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 246 /* LabeledStatement */) { + if (node.statement.kind !== 248 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -15094,17 +15464,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 231 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 233 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 166 /* MethodDeclaration */ && node.parent.kind === 201 /* ObjectLiteralExpression */; + return node && node.kind === 167 /* MethodDeclaration */ && node.parent.kind === 203 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 166 /* MethodDeclaration */ && - (node.parent.kind === 201 /* ObjectLiteralExpression */ || - node.parent.kind === 222 /* ClassExpression */); + return node.kind === 167 /* MethodDeclaration */ && + (node.parent.kind === 203 /* ObjectLiteralExpression */ || + node.parent.kind === 224 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -15117,7 +15487,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 289 /* PropertyAssignment */) { + if (property.kind === 291 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15165,15 +15535,28 @@ var ts; return ts.findAncestor(node.parent, ts.isClassLike); } ts.getContainingClass = getContainingClass; + function getContainingClassStaticBlock(node) { + return ts.findAncestor(node.parent, function (n) { + if (ts.isClassLike(n) || ts.isFunctionLike(n)) { + return "quit"; + } + return ts.isClassStaticBlockDeclaration(n); + }); + } + ts.getContainingClassStaticBlock = getContainingClassStaticBlock; + function getContainingFunctionOrClassStaticBlock(node) { + return ts.findAncestor(node.parent, ts.isFunctionLikeOrClassStaticBlockDeclaration); + } + ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 298 /* SourceFile */); + ts.Debug.assert(node.kind !== 300 /* SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 159 /* ComputedPropertyName */: + case 160 /* 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 @@ -15188,9 +15571,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 162 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 161 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* Parameter */ && ts.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; @@ -15201,26 +15584,27 @@ var ts; node = node.parent; } break; - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 257 /* ModuleDeclaration */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 172 /* IndexSignature */: - case 256 /* EnumDeclaration */: - case 298 /* SourceFile */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 259 /* ModuleDeclaration */: + case 168 /* ClassStaticBlockDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 174 /* IndexSignature */: + case 258 /* EnumDeclaration */: + case 300 /* SourceFile */: return node; } } @@ -15239,9 +15623,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 167 /* Constructor */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: + case 169 /* Constructor */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: return container; } } @@ -15263,27 +15647,28 @@ var ts; return node; } switch (node.kind) { - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: node = node.parent; break; - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 168 /* ClassStaticBlockDeclaration */: return node; - case 162 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 161 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* Parameter */ && ts.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; @@ -15299,21 +15684,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 209 /* FunctionExpression */ || func.kind === 210 /* ArrowFunction */) { + if (func.kind === 211 /* FunctionExpression */ || func.kind === 212 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 208 /* ParenthesizedExpression */) { + while (parent.kind === 210 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 204 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 206 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 105 /* SuperKeyword */ + return node.kind === 106 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -15322,8 +15707,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 202 /* PropertyAccessExpression */ || kind === 203 /* ElementAccessExpression */) - && node.expression.kind === 105 /* SuperKeyword */; + return (kind === 204 /* PropertyAccessExpression */ || kind === 205 /* ElementAccessExpression */) + && node.expression.kind === 106 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -15331,34 +15716,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 202 /* PropertyAccessExpression */ || kind === 203 /* ElementAccessExpression */) - && node.expression.kind === 107 /* ThisKeyword */; + return (kind === 204 /* PropertyAccessExpression */ || kind === 205 /* ElementAccessExpression */) + && node.expression.kind === 108 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 107 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function isThisInitializedObjectBindingExpression(node) { return !!node && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) && ts.isBinaryExpression(node.parent.parent) - && node.parent.parent.operatorToken.kind === 62 /* EqualsToken */ - && node.parent.parent.right.kind === 107 /* ThisKeyword */; + && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.parent.right.kind === 108 /* ThisKeyword */; } ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 174 /* TypeReference */: + case 176 /* TypeReference */: return node.typeName; - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 78 /* Identifier */: - case 158 /* QualifiedName */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: return node; } return undefined; @@ -15366,10 +15751,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: return node.tag; - case 276 /* JsxOpeningElement */: - case 275 /* JsxSelfClosingElement */: + case 278 /* JsxOpeningElement */: + case 277 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -15382,25 +15767,25 @@ var ts; return false; } switch (node.kind) { - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: // classes are valid targets return true; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 253 /* ClassDeclaration */; - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 166 /* MethodDeclaration */: + return parent.kind === 255 /* ClassDeclaration */; + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 167 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 253 /* ClassDeclaration */; - case 161 /* Parameter */: + && parent.kind === 255 /* ClassDeclaration */; + case 162 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 167 /* Constructor */ - || parent.kind === 166 /* MethodDeclaration */ - || parent.kind === 169 /* SetAccessor */) - && grandparent.kind === 253 /* ClassDeclaration */; + && (parent.kind === 169 /* Constructor */ + || parent.kind === 167 /* MethodDeclaration */ + || parent.kind === 171 /* SetAccessor */) + && grandparent.kind === 255 /* ClassDeclaration */; } return false; } @@ -15416,21 +15801,29 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 166 /* MethodDeclaration */: - case 169 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 171 /* SetAccessor */: + case 169 /* Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; } } ts.childIsDecorated = childIsDecorated; + function classOrConstructorParameterIsDecorated(node) { + if (nodeIsDecorated(node)) + return true; + var constructor = getFirstConstructorWithBody(node); + return !!constructor && childIsDecorated(constructor, node); + } + ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 276 /* JsxOpeningElement */ || - parent.kind === 275 /* JsxSelfClosingElement */ || - parent.kind === 277 /* JsxClosingElement */) { + if (parent.kind === 278 /* JsxOpeningElement */ || + parent.kind === 277 /* JsxSelfClosingElement */ || + parent.kind === 279 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -15438,49 +15831,54 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 200 /* ArrayLiteralExpression */: - case 201 /* ObjectLiteralExpression */: - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: - case 204 /* CallExpression */: - case 205 /* NewExpression */: - case 206 /* TaggedTemplateExpression */: - case 225 /* AsExpression */: - case 207 /* TypeAssertionExpression */: - case 226 /* NonNullExpression */: - case 208 /* ParenthesizedExpression */: - case 209 /* FunctionExpression */: - case 222 /* ClassExpression */: - case 210 /* ArrowFunction */: - case 213 /* VoidExpression */: - case 211 /* DeleteExpression */: - case 212 /* TypeOfExpression */: - case 215 /* PrefixUnaryExpression */: - case 216 /* PostfixUnaryExpression */: - case 217 /* BinaryExpression */: - case 218 /* ConditionalExpression */: - case 221 /* SpreadElement */: - case 219 /* TemplateExpression */: - case 223 /* OmittedExpression */: - case 274 /* JsxElement */: - case 275 /* JsxSelfClosingElement */: - case 278 /* JsxFragment */: - case 220 /* YieldExpression */: - case 214 /* AwaitExpression */: - case 227 /* MetaProperty */: + case 202 /* ArrayLiteralExpression */: + case 203 /* ObjectLiteralExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: + case 208 /* TaggedTemplateExpression */: + case 227 /* AsExpression */: + case 209 /* TypeAssertionExpression */: + case 228 /* NonNullExpression */: + case 210 /* ParenthesizedExpression */: + case 211 /* FunctionExpression */: + case 224 /* ClassExpression */: + case 212 /* ArrowFunction */: + case 215 /* VoidExpression */: + case 213 /* DeleteExpression */: + case 214 /* TypeOfExpression */: + case 217 /* PrefixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: + case 219 /* BinaryExpression */: + case 220 /* ConditionalExpression */: + case 223 /* SpreadElement */: + case 221 /* TemplateExpression */: + case 225 /* OmittedExpression */: + case 276 /* JsxElement */: + case 277 /* JsxSelfClosingElement */: + case 280 /* JsxFragment */: + case 222 /* YieldExpression */: + case 216 /* AwaitExpression */: + case 229 /* MetaProperty */: return true; - case 158 /* QualifiedName */: - while (node.parent.kind === 158 /* QualifiedName */) { + case 159 /* QualifiedName */: + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 177 /* TypeQuery */ || isJSXTagName(node); - case 78 /* Identifier */: - if (node.parent.kind === 177 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 179 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 306 /* JSDocMemberName */: + while (ts.isJSDocMemberName(node.parent)) { + node = node.parent; + } + return node.parent.kind === 179 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 79 /* Identifier */: + if (node.parent.kind === 179 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through @@ -15488,7 +15886,7 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -15498,49 +15896,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 250 /* VariableDeclaration */: - case 161 /* Parameter */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 292 /* EnumMember */: - case 289 /* PropertyAssignment */: - case 199 /* BindingElement */: + case 252 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 294 /* EnumMember */: + case 291 /* PropertyAssignment */: + case 201 /* BindingElement */: return parent.initializer === node; - case 234 /* ExpressionStatement */: - case 235 /* IfStatement */: - case 236 /* DoStatement */: - case 237 /* WhileStatement */: - case 243 /* ReturnStatement */: - case 244 /* WithStatement */: - case 245 /* SwitchStatement */: - case 285 /* CaseClause */: - case 247 /* ThrowStatement */: + case 236 /* ExpressionStatement */: + case 237 /* IfStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: + case 245 /* ReturnStatement */: + case 246 /* WithStatement */: + case 247 /* SwitchStatement */: + case 287 /* CaseClause */: + case 249 /* ThrowStatement */: return parent.expression === node; - case 238 /* ForStatement */: + case 240 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 251 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 253 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 251 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 253 /* VariableDeclarationList */) || forInStatement.expression === node; - case 207 /* TypeAssertionExpression */: - case 225 /* AsExpression */: + case 209 /* TypeAssertionExpression */: + case 227 /* AsExpression */: return node === parent.expression; - case 229 /* TemplateSpan */: + case 231 /* TemplateSpan */: return node === parent.expression; - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return node === parent.expression; - case 162 /* Decorator */: - case 284 /* JsxExpression */: - case 283 /* JsxSpreadAttribute */: - case 291 /* SpreadAssignment */: + case 163 /* Decorator */: + case 286 /* JsxExpression */: + case 285 /* JsxSpreadAttribute */: + case 293 /* SpreadAssignment */: return true; - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -15548,10 +15946,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 158 /* QualifiedName */ || node.kind === 78 /* Identifier */) { + while (node.kind === 159 /* QualifiedName */ || node.kind === 79 /* Identifier */) { node = node.parent; } - return node.kind === 177 /* TypeQuery */; + return node.kind === 179 /* TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -15559,7 +15957,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 261 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 273 /* ExternalModuleReference */; + return node.kind === 263 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 275 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -15572,7 +15970,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 261 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 273 /* ExternalModuleReference */; + return node.kind === 263 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 275 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -15604,15 +16002,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 147 /* StringKeyword */ || node.typeArguments[0].kind === 144 /* NumberKeyword */); + (node.typeArguments[0].kind === 148 /* StringKeyword */ || node.typeArguments[0].kind === 145 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 204 /* CallExpression */) { + if (callExpression.kind !== 206 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 78 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -15627,7 +16025,7 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isRequireVariableDeclaration(node) { - if (node.kind === 199 /* BindingElement */) { + if (node.kind === 201 /* BindingElement */) { node = node.parent.parent; } return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); @@ -15682,7 +16080,7 @@ var ts; * We treat the right hand side of assignments with container-like initializers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -15708,11 +16106,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 209 /* FunctionExpression */ || e.kind === 210 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 211 /* FunctionExpression */ || e.kind === 212 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 209 /* FunctionExpression */ || - initializer.kind === 222 /* ClassExpression */ || - initializer.kind === 210 /* ArrowFunction */) { + if (initializer.kind === 211 /* FunctionExpression */ || + initializer.kind === 224 /* ClassExpression */ || + initializer.kind === 212 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -15738,7 +16136,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -15747,7 +16145,7 @@ var ts; function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -15770,7 +16168,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 107 /* ThisKeyword */ || + (initializer.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -15838,14 +16236,14 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 107 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; /** Any series of property and element accesses, ending in a literal element access */ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 107 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -15875,7 +16273,7 @@ var ts; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { return 0 /* None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { @@ -15917,7 +16315,7 @@ var ts; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 107 /* ThisKeyword */) { + if (lhs.expression.kind === 108 /* ThisKeyword */) { return 4 /* ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { @@ -15962,7 +16360,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 234 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 236 /* ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -15983,17 +16381,17 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 252 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 254 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { var _a, _b, _c; switch (node.kind) { - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return node.initializer.arguments[0].text; - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; default: ts.Debug.assertNever(node); @@ -16006,14 +16404,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 262 /* ImportDeclaration */: - case 268 /* ExportDeclaration */: + case 264 /* ImportDeclaration */: + case 270 /* ExportDeclaration */: return node.parent; - case 273 /* ExternalModuleReference */: + case 275 /* ExternalModuleReference */: return node.parent.parent; - case 204 /* CallExpression */: + case 206 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 192 /* LiteralType */: + case 194 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16023,16 +16421,16 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 262 /* ImportDeclaration */: - case 268 /* ExportDeclaration */: + case 264 /* ImportDeclaration */: + case 270 /* ExportDeclaration */: return node.moduleSpecifier; - case 261 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 273 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 196 /* ImportType */: + case 263 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 275 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 198 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 204 /* CallExpression */: + case 206 /* CallExpression */: return node.arguments[0]; - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); @@ -16041,11 +16439,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return node; - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16053,7 +16451,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 262 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 264 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16074,13 +16472,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 161 /* Parameter */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 290 /* ShorthandPropertyAssignment */: - case 289 /* PropertyAssignment */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: + case 162 /* Parameter */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 292 /* ShorthandPropertyAssignment */: + case 291 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -16094,7 +16492,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 335 /* JSDocTypedefTag */ || node.kind === 328 /* JSDocCallbackTag */ || node.kind === 329 /* JSDocEnumTag */; + return node.kind === 340 /* JSDocTypedefTag */ || node.kind === 333 /* JSDocCallbackTag */ || node.kind === 334 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16104,7 +16502,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 62 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } @@ -16119,12 +16517,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer; - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: return node.initializer; } } @@ -16136,7 +16534,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 257 /* ModuleDeclaration */ + node.body.kind === 259 /* ModuleDeclaration */ ? node.body : undefined; } @@ -16151,11 +16549,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 161 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 160 /* TypeParameter */) { + if (node.kind === 161 /* TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -16166,13 +16564,13 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 289 /* PropertyAssignment */ || - parent.kind === 267 /* ExportAssignment */ || - parent.kind === 164 /* PropertyDeclaration */ || - parent.kind === 234 /* ExpressionStatement */ && node.kind === 202 /* PropertyAccessExpression */ || - parent.kind === 243 /* ReturnStatement */ || + if (parent.kind === 291 /* PropertyAssignment */ || + parent.kind === 269 /* ExportAssignment */ || + parent.kind === 165 /* PropertyDeclaration */ || + parent.kind === 236 /* ExpressionStatement */ && node.kind === 204 /* PropertyAccessExpression */ || + parent.kind === 245 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -16183,7 +16581,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -16207,7 +16605,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 78 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -16257,7 +16655,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 310 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 313 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -16274,34 +16672,34 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 215 /* PrefixUnaryExpression */: - case 216 /* PostfixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 208 /* ParenthesizedExpression */: - case 200 /* ArrayLiteralExpression */: - case 221 /* SpreadElement */: - case 226 /* NonNullExpression */: + case 210 /* ParenthesizedExpression */: + case 202 /* ArrayLiteralExpression */: + case 223 /* SpreadElement */: + case 228 /* NonNullExpression */: node = parent; break; - case 291 /* SpreadAssignment */: + case 293 /* SpreadAssignment */: node = parent.parent; break; - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -16328,22 +16726,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 231 /* Block */: - case 233 /* VariableStatement */: - case 244 /* WithStatement */: - case 235 /* IfStatement */: - case 245 /* SwitchStatement */: - case 259 /* CaseBlock */: - case 285 /* CaseClause */: - case 286 /* DefaultClause */: - case 246 /* LabeledStatement */: - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 236 /* DoStatement */: - case 237 /* WhileStatement */: - case 248 /* TryStatement */: - case 288 /* CatchClause */: + case 233 /* Block */: + case 235 /* VariableStatement */: + case 246 /* WithStatement */: + case 237 /* IfStatement */: + case 247 /* SwitchStatement */: + case 261 /* CaseBlock */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: + case 248 /* LabeledStatement */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: + case 250 /* TryStatement */: + case 290 /* CatchClause */: return true; } return false; @@ -16360,11 +16758,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 187 /* ParenthesizedType */); + return walkUp(node, 189 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 208 /* ParenthesizedExpression */); + return walkUp(node, 210 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -16374,7 +16772,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 187 /* ParenthesizedType */) { + while (node && node.kind === 189 /* ParenthesizedType */) { child = node; node = node.parent; } @@ -16385,19 +16783,13 @@ var ts; return ts.skipOuterExpressions(node, 1 /* Parentheses */); } ts.skipParentheses = skipParentheses; - function skipParenthesesUp(node) { - while (node.kind === 208 /* ParenthesizedExpression */) { - node = node.parent; - } - return node; - } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 202 /* PropertyAccessExpression */ && node.kind !== 203 /* ElementAccessExpression */) { + if (node.kind !== 204 /* PropertyAccessExpression */ && node.kind !== 205 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 211 /* DeleteExpression */; + return node && node.kind === 213 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -16424,7 +16816,7 @@ var ts; if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -16441,7 +16833,7 @@ var ts; ? binExp : undefined; } - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -16450,7 +16842,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 159 /* ComputedPropertyName */ && + node.parent.kind === 160 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -16458,26 +16850,26 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 292 /* EnumMember */: - case 289 /* PropertyAssignment */: - case 202 /* PropertyAccessExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 294 /* EnumMember */: + case 291 /* PropertyAssignment */: + case 204 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 199 /* BindingElement */: - case 266 /* ImportSpecifier */: + case 201 /* BindingElement */: + case 268 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 271 /* ExportSpecifier */: - case 281 /* JsxAttribute */: + case 273 /* ExportSpecifier */: + case 283 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -16497,33 +16889,33 @@ var ts; // {} // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 261 /* ImportEqualsDeclaration */ || - node.kind === 260 /* NamespaceExportDeclaration */ || - node.kind === 263 /* ImportClause */ && !!node.name || - node.kind === 264 /* NamespaceImport */ || - node.kind === 270 /* NamespaceExport */ || - node.kind === 266 /* ImportSpecifier */ || - node.kind === 271 /* ExportSpecifier */ || - node.kind === 267 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 263 /* ImportEqualsDeclaration */ || + node.kind === 262 /* NamespaceExportDeclaration */ || + node.kind === 265 /* ImportClause */ && !!node.name || + node.kind === 266 /* NamespaceImport */ || + node.kind === 272 /* NamespaceExport */ || + node.kind === 268 /* ImportSpecifier */ || + node.kind === 273 /* ExportSpecifier */ || + node.kind === 269 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 290 /* ShorthandPropertyAssignment */ || - node.kind === 289 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 292 /* ShorthandPropertyAssignment */ || + node.kind === 291 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 263 /* ImportClause */: - case 266 /* ImportSpecifier */: - case 264 /* NamespaceImport */: - case 271 /* ExportSpecifier */: - case 267 /* ExportAssignment */: - case 261 /* ImportEqualsDeclaration */: + case 265 /* ImportClause */: + case 268 /* ImportSpecifier */: + case 266 /* NamespaceImport */: + case 273 /* ExportSpecifier */: + case 269 /* ExportAssignment */: + case 263 /* ImportEqualsDeclaration */: return node.parent; - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 158 /* QualifiedName */); + } while (node.parent.kind === 159 /* QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -16542,7 +16934,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 290 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 289 /* PropertyAssignment */ ? node.initializer : + return node.kind === 292 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 291 /* PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -16559,7 +16951,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -16568,7 +16960,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 116 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -16581,7 +16973,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -16608,11 +17000,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 80 /* FirstKeyword */ <= token && token <= 157 /* LastKeyword */; + return 81 /* FirstKeyword */ <= token && token <= 158 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 125 /* FirstContextualKeyword */ <= token && token <= 157 /* LastContextualKeyword */; + return 126 /* FirstContextualKeyword */ <= token && token <= 158 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -16620,7 +17012,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 116 /* FirstFutureReservedWord */ <= token && token <= 124 /* LastFutureReservedWord */; + return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -16656,14 +17048,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 166 /* MethodDeclaration */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 167 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: if (hasSyntacticModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -16677,10 +17069,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 166 /* MethodDeclaration */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 167 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasSyntacticModifier(node, 256 /* Async */); @@ -16710,7 +17102,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 159 /* ComputedPropertyName */ || name.kind === 203 /* ElementAccessExpression */)) { + if (!(name.kind === 160 /* ComputedPropertyName */ || name.kind === 205 /* ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -16720,13 +17112,13 @@ var ts; ts.isDynamicName = isDynamicName; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); @@ -16745,7 +17137,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -16775,11 +17167,15 @@ var ts; return ts.startsWith(symbol.escapedName, "__@"); } ts.isKnownSymbol = isKnownSymbol; + function isPrivateIdentifierSymbol(symbol) { + return ts.startsWith(symbol.escapedName, "__#"); + } + ts.isPrivateIdentifierSymbol = isPrivateIdentifierSymbol; /** * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -16788,11 +17184,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 161 /* Parameter */; + return root.kind === 162 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 199 /* BindingElement */) { + while (node.kind === 201 /* BindingElement */) { node = node.parent.parent; } return node; @@ -16800,15 +17196,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 167 /* Constructor */ - || kind === 209 /* FunctionExpression */ - || kind === 252 /* FunctionDeclaration */ - || kind === 210 /* ArrowFunction */ - || kind === 166 /* MethodDeclaration */ - || kind === 168 /* GetAccessor */ - || kind === 169 /* SetAccessor */ - || kind === 257 /* ModuleDeclaration */ - || kind === 298 /* SourceFile */; + return kind === 169 /* Constructor */ + || kind === 211 /* FunctionExpression */ + || kind === 254 /* FunctionDeclaration */ + || kind === 212 /* ArrowFunction */ + || kind === 167 /* MethodDeclaration */ + || kind === 170 /* GetAccessor */ + || kind === 171 /* SetAccessor */ + || kind === 259 /* ModuleDeclaration */ + || kind === 300 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -16827,41 +17223,41 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 205 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 207 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 205 /* NewExpression */: + case 207 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 215 /* PrefixUnaryExpression */: - case 212 /* TypeOfExpression */: - case 213 /* VoidExpression */: - case 211 /* DeleteExpression */: - case 214 /* AwaitExpression */: - case 218 /* ConditionalExpression */: - case 220 /* YieldExpression */: + case 217 /* PrefixUnaryExpression */: + case 214 /* TypeOfExpression */: + case 215 /* VoidExpression */: + case 213 /* DeleteExpression */: + case 216 /* AwaitExpression */: + case 220 /* ConditionalExpression */: + case 222 /* YieldExpression */: return 1 /* Right */; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: switch (operator) { case 42 /* AsteriskAsteriskToken */: - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 64 /* PlusEqualsToken */: + case 65 /* MinusEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: + case 68 /* SlashEqualsToken */: + case 69 /* PercentEqualsToken */: + case 70 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* AmpersandEqualsToken */: + case 78 /* CaretEqualsToken */: + case 74 /* BarEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return 1 /* Right */; } } @@ -16870,15 +17266,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 205 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 207 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 217 /* BinaryExpression */) { + if (expression.kind === 219 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 215 /* PrefixUnaryExpression */ || expression.kind === 216 /* PostfixUnaryExpression */) { + else if (expression.kind === 217 /* PrefixUnaryExpression */ || expression.kind === 218 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -17057,82 +17453,82 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 341 /* CommaListExpression */: + case 346 /* CommaListExpression */: return 0 /* Comma */; - case 221 /* SpreadElement */: + case 223 /* SpreadElement */: return 1 /* Spread */; - case 220 /* YieldExpression */: + case 222 /* YieldExpression */: return 2 /* Yield */; - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: return 4 /* Conditional */; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0 /* Comma */; - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 64 /* PlusEqualsToken */: + case 65 /* MinusEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: + case 68 /* SlashEqualsToken */: + case 69 /* PercentEqualsToken */: + case 70 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* AmpersandEqualsToken */: + case 78 /* CaretEqualsToken */: + case 74 /* BarEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return 3 /* Assignment */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 207 /* TypeAssertionExpression */: - case 226 /* NonNullExpression */: - case 215 /* PrefixUnaryExpression */: - case 212 /* TypeOfExpression */: - case 213 /* VoidExpression */: - case 211 /* DeleteExpression */: - case 214 /* AwaitExpression */: + case 209 /* TypeAssertionExpression */: + case 228 /* NonNullExpression */: + case 217 /* PrefixUnaryExpression */: + case 214 /* TypeOfExpression */: + case 215 /* VoidExpression */: + case 213 /* DeleteExpression */: + case 216 /* AwaitExpression */: return 16 /* Unary */; - case 216 /* PostfixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: return 17 /* Update */; - case 204 /* CallExpression */: + case 206 /* CallExpression */: return 18 /* LeftHandSide */; - case 205 /* NewExpression */: + case 207 /* NewExpression */: return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 206 /* TaggedTemplateExpression */: - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: - case 227 /* MetaProperty */: + case 208 /* TaggedTemplateExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: + case 229 /* MetaProperty */: return 19 /* Member */; - case 225 /* AsExpression */: + case 227 /* AsExpression */: return 11 /* Relational */; - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 78 /* Identifier */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 79 /* Identifier */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 200 /* ArrayLiteralExpression */: - case 201 /* ObjectLiteralExpression */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 222 /* ClassExpression */: + case 202 /* ArrayLiteralExpression */: + case 203 /* ObjectLiteralExpression */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 224 /* ClassExpression */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 219 /* TemplateExpression */: - case 208 /* ParenthesizedExpression */: - case 223 /* OmittedExpression */: - case 274 /* JsxElement */: - case 275 /* JsxSelfClosingElement */: - case 278 /* JsxFragment */: + case 221 /* TemplateExpression */: + case 210 /* ParenthesizedExpression */: + case 225 /* OmittedExpression */: + case 276 /* JsxElement */: + case 277 /* JsxSelfClosingElement */: + case 280 /* JsxFragment */: return 20 /* Primary */; default: return -1 /* Invalid */; @@ -17162,9 +17558,9 @@ var ts; case 31 /* GreaterThanToken */: case 32 /* LessThanEqualsToken */: case 33 /* GreaterThanEqualsToken */: - case 101 /* InstanceOfKeyword */: - case 100 /* InKeyword */: - case 126 /* AsKeyword */: + case 102 /* InstanceOfKeyword */: + case 101 /* InKeyword */: + case 127 /* AsKeyword */: return 11 /* Relational */; case 47 /* LessThanLessThanToken */: case 48 /* GreaterThanGreaterThanToken */: @@ -17188,7 +17584,7 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 284 /* JsxExpression */: + case 286 /* JsxExpression */: return !!i.expression; case 11 /* JsxText */: return !i.containsOnlyTriviaWhiteSpaces; @@ -17281,8 +17677,8 @@ var ts; // There is no reason for this other than that JSON.stringify does not handle it either. var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - // Template strings should be preserved as much as possible - var backtickQuoteEscapedCharsRegExp = /[\\`]/g; + // Template strings preserve simple LF newlines, still encode CRLF (or CR) + var backtickQuoteEscapedCharsRegExp = /\r\n|[\\\`\u0000-\u001f\t\v\f\b\r\u2028\u2029\u0085]/g; var escapedCharsMap = new ts.Map(ts.getEntries({ "\t": "\\t", "\v": "\\v", @@ -17296,7 +17692,8 @@ var ts; "\`": "\\\`", "\u2028": "\\u2028", "\u2029": "\\u2029", - "\u0085": "\\u0085" // nextLine + "\u0085": "\\u0085", + "\r\n": "\\r\\n", // special case for CRLFs in backticks })); function encodeUtf16EscapeSequence(charCode) { var hexCharCode = charCode.toString(16).toUpperCase(); @@ -17490,7 +17887,7 @@ var ts; reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, writeKeyword: write, writeOperator: write, writeParameter: write, @@ -17515,56 +17912,43 @@ var ts; } return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; - }, - writeLiteral: function (s) { + }, writeLiteral: function (s) { commitPendingTrailingSemicolon(); writer.writeLiteral(s); - }, - writeStringLiteral: function (s) { + }, writeStringLiteral: function (s) { commitPendingTrailingSemicolon(); writer.writeStringLiteral(s); - }, - writeSymbol: function (s, sym) { + }, writeSymbol: function (s, sym) { commitPendingTrailingSemicolon(); writer.writeSymbol(s, sym); - }, - writePunctuation: function (s) { + }, writePunctuation: function (s) { commitPendingTrailingSemicolon(); writer.writePunctuation(s); - }, - writeKeyword: function (s) { + }, writeKeyword: function (s) { commitPendingTrailingSemicolon(); writer.writeKeyword(s); - }, - writeOperator: function (s) { + }, writeOperator: function (s) { commitPendingTrailingSemicolon(); writer.writeOperator(s); - }, - writeParameter: function (s) { + }, writeParameter: function (s) { commitPendingTrailingSemicolon(); writer.writeParameter(s); - }, - writeSpace: function (s) { + }, writeSpace: function (s) { commitPendingTrailingSemicolon(); writer.writeSpace(s); - }, - writeProperty: function (s) { + }, writeProperty: function (s) { commitPendingTrailingSemicolon(); writer.writeProperty(s); - }, - writeComment: function (s) { + }, writeComment: function (s) { commitPendingTrailingSemicolon(); writer.writeComment(s); - }, - writeLine: function () { + }, writeLine: function () { commitPendingTrailingSemicolon(); writer.writeLine(); - }, - increaseIndent: function () { + }, increaseIndent: function () { commitPendingTrailingSemicolon(); writer.increaseIndent(); - }, - decreaseIndent: function () { + }, decreaseIndent: function () { commitPendingTrailingSemicolon(); writer.decreaseIndent(); } }); @@ -17760,11 +18144,21 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 78 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; + function isThisInTypeQuery(node) { + if (!isThisIdentifier(node)) { + return false; + } + while (ts.isQualifiedName(node.parent) && node.parent.left === node) { + node = node.parent; + } + return node.parent.kind === 179 /* TypeQuery */; + } + ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 107 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -17775,10 +18169,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 168 /* GetAccessor */) { + if (accessor.kind === 170 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 169 /* SetAccessor */) { + else if (accessor.kind === 171 /* SetAccessor */) { setAccessor = accessor; } else { @@ -17788,7 +18182,7 @@ var ts; else { ts.forEach(declarations, function (member) { if (ts.isAccessor(member) - && hasSyntacticModifier(member, 32 /* Static */) === hasSyntacticModifier(accessor, 32 /* Static */)) { + && isStatic(member) === isStatic(accessor)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -17798,10 +18192,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 168 /* GetAccessor */ && !getAccessor) { + if (member.kind === 170 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 169 /* SetAccessor */ && !setAccessor) { + if (member.kind === 171 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -17850,7 +18244,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 312 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 315 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18026,7 +18420,7 @@ var ts; ts.writeCommentRange = writeCommentRange; function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + var currentLineText = ts.trimString(text.substring(pos, end)); if (currentLineText) { // trimmed forward and ending spaces text writer.writeComment(currentLineText); @@ -18069,6 +18463,11 @@ var ts; return !!getSelectedSyntacticModifierFlags(node, flags); } ts.hasSyntacticModifier = hasSyntacticModifier; + function isStatic(node) { + // https://tc39.es/ecma262/#sec-static-semantics-isstatic + return ts.isClassElement(node) && hasStaticModifier(node) || ts.isClassStaticBlockDeclaration(node); + } + ts.isStatic = isStatic; function hasStaticModifier(node) { return hasSyntacticModifier(node, 32 /* Static */); } @@ -18098,7 +18497,7 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 157 /* LastToken */) { + if (node.kind >= 0 /* FirstToken */ && node.kind <= 158 /* LastToken */) { return 0 /* None */; } if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { @@ -18167,7 +18566,7 @@ var ts; */ function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 78 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -18186,18 +18585,18 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 123 /* StaticKeyword */: return 32 /* Static */; - case 122 /* PublicKeyword */: return 4 /* Public */; - case 121 /* ProtectedKeyword */: return 16 /* Protected */; - case 120 /* PrivateKeyword */: return 8 /* Private */; - case 125 /* AbstractKeyword */: return 128 /* Abstract */; - case 92 /* ExportKeyword */: return 1 /* Export */; - case 133 /* DeclareKeyword */: return 2 /* Ambient */; - case 84 /* ConstKeyword */: return 2048 /* Const */; - case 87 /* DefaultKeyword */: return 512 /* Default */; - case 129 /* AsyncKeyword */: return 256 /* Async */; - case 142 /* ReadonlyKeyword */: return 64 /* Readonly */; - case 156 /* OverrideKeyword */: return 16384 /* Override */; + case 124 /* StaticKeyword */: return 32 /* Static */; + case 123 /* PublicKeyword */: return 4 /* Public */; + case 122 /* ProtectedKeyword */: return 16 /* Protected */; + case 121 /* PrivateKeyword */: return 8 /* Private */; + case 126 /* AbstractKeyword */: return 128 /* Abstract */; + case 93 /* ExportKeyword */: return 1 /* Export */; + case 134 /* DeclareKeyword */: return 2 /* Ambient */; + case 85 /* ConstKeyword */: return 2048 /* Const */; + case 88 /* DefaultKeyword */: return 512 /* Default */; + case 130 /* AsyncKeyword */: return 256 /* Async */; + case 143 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 157 /* OverrideKeyword */: return 16384 /* Override */; } return 0 /* None */; } @@ -18213,9 +18612,9 @@ var ts; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 74 /* BarBarEqualsToken */ - || token === 75 /* AmpersandAmpersandEqualsToken */ - || token === 76 /* QuestionQuestionEqualsToken */; + return token === 75 /* BarBarEqualsToken */ + || token === 76 /* AmpersandAmpersandEqualsToken */ + || token === 77 /* QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -18223,7 +18622,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 62 /* FirstAssignment */ && token <= 77 /* LastAssignment */; + return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -18236,14 +18635,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 116 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 62 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -18255,8 +18654,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 201 /* ObjectLiteralExpression */ - || kind === 200 /* ArrayLiteralExpression */; + return kind === 203 /* ObjectLiteralExpression */ + || kind === 202 /* ArrayLiteralExpression */; } return false; } @@ -18266,33 +18665,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 78 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 78 /* Identifier */ - || node.kind === 107 /* ThisKeyword */ - || node.kind === 105 /* SuperKeyword */ - || node.kind === 227 /* MetaProperty */ - || node.kind === 202 /* PropertyAccessExpression */ && isDottedName(node.expression) - || node.kind === 208 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* Identifier */ + || node.kind === 108 /* ThisKeyword */ + || node.kind === 106 /* SuperKeyword */ + || node.kind === 229 /* MetaProperty */ + || node.kind === 204 /* PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 210 /* ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -18323,17 +18722,23 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 158 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 202 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 204 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { + return ts.isQualifiedName(node.parent) && node.parent.right === node + || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isJSDocMemberName(node.parent) && node.parent.right === node; + } + ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 201 /* ObjectLiteralExpression */ && + return expression.kind === 203 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 200 /* ArrayLiteralExpression */ && + return expression.kind === 202 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -18665,8 +19070,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 256 /* EnumDeclaration */: - case 257 /* ModuleDeclaration */: + case 258 /* EnumDeclaration */: + case 259 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -18696,7 +19101,7 @@ var ts; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 169 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 171 /* SetAccessor */; })) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; } @@ -18745,35 +19150,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return accessKind(parent); - case 216 /* PostfixUnaryExpression */: - case 215 /* PrefixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 289 /* PropertyAssignment */: { + case 291 /* PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && skipParenthesesUp(parent.parent).kind === 234 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 236 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -18917,37 +19322,37 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 173 /* FirstTypeNode */ && kind <= 196 /* LastTypeNode */) - || kind === 128 /* AnyKeyword */ - || kind === 152 /* UnknownKeyword */ - || kind === 144 /* NumberKeyword */ - || kind === 155 /* BigIntKeyword */ - || kind === 145 /* ObjectKeyword */ - || kind === 131 /* BooleanKeyword */ - || kind === 147 /* StringKeyword */ - || kind === 148 /* SymbolKeyword */ - || kind === 113 /* VoidKeyword */ - || kind === 150 /* UndefinedKeyword */ - || kind === 141 /* NeverKeyword */ - || kind === 224 /* ExpressionWithTypeArguments */ - || kind === 304 /* JSDocAllType */ - || kind === 305 /* JSDocUnknownType */ - || kind === 306 /* JSDocNullableType */ - || kind === 307 /* JSDocNonNullableType */ - || kind === 308 /* JSDocOptionalType */ - || kind === 309 /* JSDocFunctionType */ - || kind === 310 /* JSDocVariadicType */; + return (kind >= 175 /* FirstTypeNode */ && kind <= 198 /* LastTypeNode */) + || kind === 129 /* AnyKeyword */ + || kind === 153 /* UnknownKeyword */ + || kind === 145 /* NumberKeyword */ + || kind === 156 /* BigIntKeyword */ + || kind === 146 /* ObjectKeyword */ + || kind === 132 /* BooleanKeyword */ + || kind === 148 /* StringKeyword */ + || kind === 149 /* SymbolKeyword */ + || kind === 114 /* VoidKeyword */ + || kind === 151 /* UndefinedKeyword */ + || kind === 142 /* NeverKeyword */ + || kind === 226 /* ExpressionWithTypeArguments */ + || kind === 307 /* JSDocAllType */ + || kind === 308 /* JSDocUnknownType */ + || kind === 309 /* JSDocNullableType */ + || kind === 310 /* JSDocNonNullableType */ + || kind === 311 /* JSDocOptionalType */ + || kind === 312 /* JSDocFunctionType */ + || kind === 313 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 202 /* PropertyAccessExpression */ || node.kind === 203 /* ElementAccessExpression */; + return node.kind === 204 /* PropertyAccessExpression */ || node.kind === 205 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 202 /* PropertyAccessExpression */) { + if (node.kind === 204 /* PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 203 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 205 /* ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; @@ -18962,7 +19367,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 265 /* NamedImports */ || node.kind === 269 /* NamedExports */; + return node.kind === 267 /* NamedImports */ || node.kind === 271 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -18975,28 +19380,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 216 /* PostfixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: node = node.operand; continue; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: node = node.left; continue; - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: node = node.condition; continue; - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: node = node.tag; continue; - case 204 /* CallExpression */: + case 206 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 225 /* AsExpression */: - case 203 /* ElementAccessExpression */: - case 202 /* PropertyAccessExpression */: - case 226 /* NonNullExpression */: - case 340 /* PartiallyEmittedExpression */: + case 227 /* AsExpression */: + case 205 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: + case 228 /* NonNullExpression */: + case 345 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -19380,13 +19785,11 @@ var ts; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.semanticDiagnosticsOptionDeclarations); } ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations); } ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; function getCompilerOptionValue(options, option) { @@ -19433,6 +19836,7 @@ var ts; var symlinkedDirectories; var symlinkedDirectoriesByRealpath; var symlinkedFiles; + var hasProcessedResolutions = false; return { getSymlinkedFiles: function () { return symlinkedFiles; }, getSymlinkedDirectories: function () { return symlinkedDirectories; }, @@ -19461,30 +19865,31 @@ var ts; }); } }, + setSymlinksFromResolutions: function (files, typeReferenceDirectives) { + var _this = this; + var _a; + ts.Debug.assert(!hasProcessedResolutions); + hasProcessedResolutions = true; + for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { + var file = files_1[_i]; + (_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution); }); + } + typeReferenceDirectives === null || typeReferenceDirectives === void 0 ? void 0 : typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution); }); + }, + hasProcessedResolutions: function () { return hasProcessedResolutions; }, }; - } - ts.createSymlinkCache = createSymlinkCache; - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var cache = createSymlinkCache(cwd, getCanonicalFileName); - var symlinks = ts.flatMap(files, function (sf) { - var pairs = sf.resolvedModules && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedModules.values(), function (res) { - return (res === null || res === void 0 ? void 0 : res.originalPath) ? [res.resolvedFileName, res.originalPath] : undefined; - })); - return ts.concatenate(pairs, sf.resolvedTypeReferenceDirectiveNames && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedTypeReferenceDirectiveNames.values(), function (res) { - return (res === null || res === void 0 ? void 0 : res.originalPath) && res.resolvedFileName ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - }); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - cache.setSymlinkedFile(ts.toPath(originalPath, cwd, getCanonicalFileName), resolvedPath); - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _b[0], commonOriginal = _b[1]; + function processResolution(cache, resolution) { + if (!resolution || !resolution.originalPath || !resolution.resolvedFileName) + return; + var resolvedFileName = resolution.resolvedFileName, originalPath = resolution.originalPath; + cache.setSymlinkedFile(ts.toPath(originalPath, cwd, getCanonicalFileName), resolvedFileName); + var _a = guessDirectorySymlink(resolvedFileName, originalPath, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1]; if (commonResolved && commonOriginal) { cache.setSymlinkedDirectory(commonOriginal, { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); } } - return cache; } - ts.discoverProbableSymlinks = discoverProbableSymlinks; + ts.createSymlinkCache = createSymlinkCache; function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd)); var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd)); @@ -19680,7 +20085,7 @@ var ts; } ts.getRegexFromPattern = getRegexFromPattern; /** @param path directory of the tsconfig.json */ - function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath) { + function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath, directoryExists) { path = ts.normalizePath(path); currentDirectory = ts.normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); @@ -19694,7 +20099,9 @@ var ts; var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; - visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth); + if (directoryExists(basePath)) { + visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth); + } } return ts.flatten(results); function visitDirectory(path, absolutePath, depth) { @@ -19822,14 +20229,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; ts.supportedJSAndJsonExtensions = [".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; - var allSupportedExtensions = __spreadArray(__spreadArray([], ts.supportedTSExtensions), ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray(__spreadArray([], ts.supportedTSExtensions), ts.supportedJSExtensions), [".json" /* Json */]); + var allSupportedExtensions = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), ts.supportedJSExtensions, true); + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray(__spreadArray([], ts.supportedTSExtensions, true), ts.supportedJSExtensions, true), [".json" /* Json */], false); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = __spreadArray(__spreadArray([], needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArray(__spreadArray([], needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; }), true); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -19843,7 +20250,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return __spreadArray(__spreadArray([], supportedExtensions), [".json" /* Json */]); + return __spreadArray(__spreadArray([], supportedExtensions, true), [".json" /* Json */], false); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -19953,16 +20360,27 @@ var ts; return ts.changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); } ts.changeExtension = changeExtension; + /** + * Returns the input if there are no stars, a pattern if there is exactly one, + * and undefined if there are more. + */ function tryParsePattern(pattern) { - // This should be verified outside of here and a proper error thrown. - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; + if (indexOfStar === -1) { + return pattern; + } + return pattern.indexOf("*", indexOfStar + 1) !== -1 + ? undefined + : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; } ts.tryParsePattern = tryParsePattern; + function tryParsePatterns(paths) { + return ts.mapDefined(ts.getOwnKeys(paths), function (path) { return tryParsePattern(path); }); + } + ts.tryParsePatterns = tryParsePatterns; function positionIsSynthesized(pos) { // This is a fast way of testing the following conditions: // pos === undefined || pos === null || isNaN(pos) || pos < 0; @@ -20004,23 +20422,19 @@ var ts; directories: ts.emptyArray }; /** - * patternStrings contains both pattern strings (containing "*") and regular strings. + * patternOrStrings contains both patterns (containing "*") and regular strings. * Return an exact match if possible, or a pattern match, or undefined. * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ - function matchPatternOrExact(patternStrings, candidate) { + function matchPatternOrExact(patternOrStrings, candidate) { var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - if (!hasZeroOrOneAsteriskCharacter(patternString)) - continue; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); + for (var _i = 0, patternOrStrings_1 = patternOrStrings; _i < patternOrStrings_1.length; _i++) { + var patternOrString = patternOrStrings_1[_i]; + if (patternOrString === candidate) { + return candidate; } - else if (patternString === candidate) { - // pattern was matched as is - no need to search further - return patternString; + if (!ts.isString(patternOrString)) { + patterns.push(patternOrString); } } return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate); @@ -20171,42 +20585,45 @@ var ts; || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) - || !isExpressionNode(useSite); + || !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite)); } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { - return typeOnlyDeclaration.kind === 271 /* ExportSpecifier */; + return typeOnlyDeclaration.kind === 273 /* ExportSpecifier */; } ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; + function isShorthandPropertyNameUseSite(useSite) { + return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite; + } function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 78 /* Identifier */ || node.kind === 202 /* PropertyAccessExpression */) { + while (node.kind === 79 /* Identifier */ || node.kind === 204 /* PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 159 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 254 /* InterfaceDeclaration */ || containerKind === 178 /* TypeLiteral */; + return containerKind === 256 /* InterfaceDeclaration */ || containerKind === 180 /* TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 78 /* Identifier */) + if (node.kind !== 79 /* Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 287 /* HeritageClause */: + case 289 /* HeritageClause */: return true; - case 202 /* PropertyAccessExpression */: - case 224 /* ExpressionWithTypeArguments */: + case 204 /* PropertyAccessExpression */: + case 226 /* ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 254 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 256 /* InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -20367,18 +20784,18 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 160 /* TypeParameter */: + case 161 /* TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 186 /* InferType */ ? undefined : parent_1.typeParameters; - case 161 /* Parameter */: + return parent_1.kind === 188 /* InferType */ ? undefined : parent_1.typeParameters; + case 162 /* Parameter */: return node.parent.parameters; - case 195 /* TemplateLiteralTypeSpan */: + case 197 /* TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 229 /* TemplateSpan */: + case 231 /* TemplateSpan */: return node.parent.templateSpans; - case 162 /* Decorator */: + case 163 /* Decorator */: return node.parent.decorators; - case 287 /* HeritageClause */: + case 289 /* HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -20386,49 +20803,73 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 178 /* TypeLiteral */: - case 254 /* InterfaceDeclaration */: + case 180 /* TypeLiteral */: + case 256 /* InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 183 /* UnionType */: - case 184 /* IntersectionType */: + case 185 /* UnionType */: + case 186 /* IntersectionType */: return parent.types; - case 180 /* TupleType */: - case 200 /* ArrayLiteralExpression */: - case 341 /* CommaListExpression */: - case 265 /* NamedImports */: - case 269 /* NamedExports */: + case 182 /* TupleType */: + case 202 /* ArrayLiteralExpression */: + case 346 /* CommaListExpression */: + case 267 /* NamedImports */: + case 271 /* NamedExports */: return parent.elements; - case 201 /* ObjectLiteralExpression */: - case 282 /* JsxAttributes */: + case 203 /* ObjectLiteralExpression */: + case 284 /* JsxAttributes */: return parent.properties; - case 204 /* CallExpression */: - case 205 /* NewExpression */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 274 /* JsxElement */: - case 278 /* JsxFragment */: + case 276 /* JsxElement */: + case 280 /* JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 276 /* JsxOpeningElement */: - case 275 /* JsxSelfClosingElement */: + case 278 /* JsxOpeningElement */: + case 277 /* JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 231 /* Block */: - case 285 /* CaseClause */: - case 286 /* DefaultClause */: - case 258 /* ModuleBlock */: + case 233 /* Block */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: + case 260 /* ModuleBlock */: return parent.statements; - case 259 /* CaseBlock */: + case 261 /* CaseBlock */: return parent.clauses; - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 298 /* SourceFile */: + case 300 /* SourceFile */: return parent.statements; } } ts.getContainingNodeArray = getContainingNodeArray; + function hasContextSensitiveParameters(node) { + // Functions with type parameters are not context sensitive. + if (!node.typeParameters) { + // Functions with any parameters that lack type annotations are context sensitive. + if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { + return true; + } + if (node.kind !== 212 /* ArrowFunction */) { + // If the first parameter is not an explicit 'this' parameter, then the function has + // an implicit 'this' parameter which is subject to contextual typing. + var parameter = ts.firstOrUndefined(node.parameters); + if (!(parameter && parameterIsThisKeyword(parameter))) { + return true; + } + } + } + return false; + } + ts.hasContextSensitiveParameters = hasContextSensitiveParameters; + /* @internal */ + function isInfinityOrNaNString(name) { + return name === "Infinity" || name === "-Infinity" || name === "NaN"; + } + ts.isInfinityOrNaNString = isInfinityOrNaNString; })(ts || (ts = {})); /* @internal */ var ts; @@ -20542,10 +20983,10 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(217 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(217 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(219 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(219 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 210 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 212 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -20557,7 +20998,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 220 /* YieldExpression */) { + && operand.kind === 222 /* YieldExpression */) { return false; } return true; @@ -20645,7 +21086,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 217 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 219 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -20671,7 +21112,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 208 /* ParenthesizedExpression */) { + if (skipped.kind === 210 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -20688,7 +21129,7 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(218 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(220 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { @@ -20721,8 +21162,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 222 /* ClassExpression */: - case 209 /* FunctionExpression */: + case 224 /* ClassExpression */: + case 211 /* FunctionExpression */: needsParens = true; } } @@ -20735,9 +21176,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 204 /* CallExpression */: + case 206 /* CallExpression */: return factory.createParenthesizedExpression(expression); - case 205 /* NewExpression */: + case 207 /* NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -20757,7 +21198,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 205 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 207 /* NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -20779,7 +21220,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(217 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(219 /* BinaryExpression */, 27 /* CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -20788,44 +21229,44 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 209 /* FunctionExpression */ || kind === 210 /* ArrowFunction */) { + if (kind === 211 /* FunctionExpression */ || kind === 212 /* ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 201 /* ObjectLiteralExpression */ || leftmostExpressionKind === 209 /* FunctionExpression */) { + if (leftmostExpressionKind === 203 /* ObjectLiteralExpression */ || leftmostExpressionKind === 211 /* FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 201 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 203 /* ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } return body; } function parenthesizeMemberOfConditionalType(member) { - return member.kind === 185 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; + return member.kind === 187 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; } function parenthesizeMemberOfElementType(member) { switch (member.kind) { - case 183 /* UnionType */: - case 184 /* IntersectionType */: - case 175 /* FunctionType */: - case 176 /* ConstructorType */: + case 185 /* UnionType */: + case 186 /* IntersectionType */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfConditionalType(member); } function parenthesizeElementTypeOfArrayType(member) { switch (member.kind) { - case 177 /* TypeQuery */: - case 189 /* TypeOperator */: - case 186 /* InferType */: + case 179 /* TypeQuery */: + case 191 /* TypeOperator */: + case 188 /* InferType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfElementType(member); @@ -20931,11 +21372,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 198 /* ArrayBindingPattern */: - case 200 /* ArrayLiteralExpression */: + case 200 /* ArrayBindingPattern */: + case 202 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 197 /* ObjectBindingPattern */: - case 201 /* ObjectLiteralExpression */: + case 199 /* ObjectBindingPattern */: + case 203 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -21063,6 +21504,8 @@ var ts; updateConstructSignature: updateConstructSignature, createIndexSignature: createIndexSignature, updateIndexSignature: updateIndexSignature, + createClassStaticBlockDeclaration: createClassStaticBlockDeclaration, + updateClassStaticBlockDeclaration: updateClassStaticBlockDeclaration, createTemplateLiteralTypeSpan: createTemplateLiteralTypeSpan, updateTemplateLiteralTypeSpan: updateTemplateLiteralTypeSpan, createKeywordTypeNode: createKeywordTypeNode, @@ -21276,18 +21719,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(304 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(305 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(307 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(307 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(306 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(306 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(308 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(308 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(311 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(311 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(307 /* JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(308 /* JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(311 /* JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(311 /* JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(313 /* JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(313 /* JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(314 /* JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(314 /* JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -21314,33 +21757,39 @@ var ts; updateJSDocSeeTag: updateJSDocSeeTag, createJSDocNameReference: createJSDocNameReference, updateJSDocNameReference: updateJSDocNameReference, + createJSDocMemberName: createJSDocMemberName, + updateJSDocMemberName: updateJSDocMemberName, createJSDocLink: createJSDocLink, updateJSDocLink: updateJSDocLink, + createJSDocLinkCode: createJSDocLinkCode, + updateJSDocLinkCode: updateJSDocLinkCode, + createJSDocLinkPlain: createJSDocLinkPlain, + updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(333 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(333 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(331 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(331 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(332 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(332 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(329 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(329 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(320 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(320 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(322 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(322 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(323 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(323 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(324 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(324 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(325 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(325 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(326 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(326 /* JSDocReadonlyTag */); }, - get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(327 /* JSDocOverrideTag */); }, - get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(327 /* JSDocOverrideTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(321 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(321 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(338 /* JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(338 /* JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(336 /* JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(336 /* JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(337 /* JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(337 /* JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(334 /* JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(334 /* JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(325 /* JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(325 /* JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(327 /* JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(327 /* JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(328 /* JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(328 /* JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(329 /* JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(329 /* JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(326 /* JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(326 /* JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -21409,7 +21858,7 @@ var ts; cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(62 /* EqualsToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, @@ -21455,8 +21904,11 @@ var ts; createArraySliceCall: createArraySliceCall, createArrayConcatCall: createArrayConcatCall, createObjectDefinePropertyCall: createObjectDefinePropertyCall, + createReflectGetCall: createReflectGetCall, + createReflectSetCall: createReflectSetCall, createPropertyDescriptor: createPropertyDescriptor, createCallBinding: createCallBinding, + createAssignmentTargetWrapper: createAssignmentTargetWrapper, // Utilities inlineExpressions: inlineExpressions, getInternalName: getInternalName, @@ -21483,12 +21935,24 @@ var ts; elements = []; } else if (ts.isNodeArray(elements)) { - // Ensure the transform flags have been aggregated for this NodeArray - if (elements.transformFlags === undefined) { - aggregateChildrenFlags(elements); - } - ts.Debug.attachNodeArrayDebugInfo(elements); - return elements; + if (hasTrailingComma === undefined || elements.hasTrailingComma === hasTrailingComma) { + // Ensure the transform flags have been aggregated for this NodeArray + if (elements.transformFlags === undefined) { + aggregateChildrenFlags(elements); + } + ts.Debug.attachNodeArrayDebugInfo(elements); + return elements; + } + // This *was* a `NodeArray`, but the `hasTrailingComma` option differs. Recreate the + // array with the same elements, text range, and transform flags but with the updated + // value for `hasTrailingComma` + var array_8 = elements.slice(); + array_8.pos = elements.pos; + array_8.end = elements.end; + array_8.hasTrailingComma = hasTrailingComma; + array_8.transformFlags = elements.transformFlags; + ts.Debug.attachNodeArrayDebugInfo(array_8); + return array_8; } // Since the element list of a node array is typically created by starting with an empty array and // repeatedly calling push(), the list may not have the optimal memory layout. We invoke slice() for @@ -21528,11 +21992,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 164 /* PropertyDeclaration */: - case 289 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 291 /* PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -21678,10 +22142,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 78 /* Identifier */) { + if (originalKeywordKind === 79 /* Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(78 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -21700,7 +22164,7 @@ var ts; // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 130 /* AwaitKeyword */) { + if (node.originalKeywordKind === 131 /* AwaitKeyword */) { node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; } return node; @@ -21751,7 +22215,7 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(79 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.transformFlags |= 8388608 /* ContainsClassFields */; return node; @@ -21763,45 +22227,47 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 157 /* LastToken */, "Invalid token"); + ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 158 /* LastToken */, "Invalid token"); ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 78 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); var transformFlags = 0 /* None */; switch (token) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = 128 /* ContainsES2017 */ | 64 /* ContainsES2018 */; break; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 125 /* AbstractKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: - case 156 /* OverrideKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 152 /* UnknownKeyword */: - case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 134 /* DeclareKeyword */: + case 85 /* ConstKeyword */: + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: + case 157 /* OverrideKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 153 /* UnknownKeyword */: + case 151 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. transformFlags = 1 /* ContainsTypeScript */; break; - case 123 /* StaticKeyword */: - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: + transformFlags = 512 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */; + break; + case 124 /* StaticKeyword */: transformFlags = 512 /* ContainsES2015 */; break; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: // 'this' indicates a lexical 'this' transformFlags = 8192 /* ContainsLexicalThis */; break; @@ -21816,23 +22282,23 @@ var ts; // // @api function createSuper() { - return createToken(105 /* SuperKeyword */); + return createToken(106 /* SuperKeyword */); } // @api function createThis() { - return createToken(107 /* ThisKeyword */); + return createToken(108 /* ThisKeyword */); } // @api function createNull() { - return createToken(103 /* NullKeyword */); + return createToken(104 /* NullKeyword */); } // @api function createTrue() { - return createToken(109 /* TrueKeyword */); + return createToken(110 /* TrueKeyword */); } // @api function createFalse() { - return createToken(94 /* FalseKeyword */); + return createToken(95 /* FalseKeyword */); } // // Modifiers @@ -21845,40 +22311,40 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(92 /* ExportKeyword */)); + result.push(createModifier(93 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(133 /* DeclareKeyword */)); + result.push(createModifier(134 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(87 /* DefaultKeyword */)); + result.push(createModifier(88 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(84 /* ConstKeyword */)); + result.push(createModifier(85 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(122 /* PublicKeyword */)); + result.push(createModifier(123 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(120 /* PrivateKeyword */)); + result.push(createModifier(121 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(121 /* ProtectedKeyword */)); + result.push(createModifier(122 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(125 /* AbstractKeyword */)); + result.push(createModifier(126 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(123 /* StaticKeyword */)); + result.push(createModifier(124 /* StaticKeyword */)); } if (flags & 16384 /* Override */) { - result.push(createModifier(156 /* OverrideKeyword */)); + result.push(createModifier(157 /* OverrideKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(142 /* ReadonlyKeyword */)); + result.push(createModifier(143 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(129 /* AsyncKeyword */)); + result.push(createModifier(130 /* AsyncKeyword */)); } return result; } @@ -21887,7 +22353,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(158 /* QualifiedName */); + var node = createBaseNode(159 /* QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -21904,7 +22370,7 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(159 /* ComputedPropertyName */); + var node = createBaseNode(160 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -21923,7 +22389,7 @@ var ts; // // @api function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createBaseNamedDeclaration(160 /* TypeParameter */, + var node = createBaseNamedDeclaration(161 /* TypeParameter */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.constraint = constraint; @@ -21941,7 +22407,7 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(161 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(162 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { @@ -21974,7 +22440,7 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(162 /* Decorator */); + var node = createBaseNode(163 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -21993,7 +22459,7 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(163 /* PropertySignature */, + var node = createBaseNamedDeclaration(164 /* PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; @@ -22011,7 +22477,7 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(165 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= @@ -22040,7 +22506,7 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(165 /* MethodSignature */, + var node = createBaseSignatureDeclaration(166 /* MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; node.transformFlags = 1 /* ContainsTypeScript */; @@ -22059,7 +22525,7 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(166 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(167 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= @@ -22097,8 +22563,25 @@ var ts; : node; } // @api + function createClassStaticBlockDeclaration(decorators, modifiers, body) { + var node = createBaseGenericNamedDeclaration(168 /* ClassStaticBlockDeclaration */, decorators, modifiers, + /*name*/ undefined, + /*typeParameters*/ undefined); + node.body = body; + node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */; + return node; + } + // @api + function updateClassStaticBlockDeclaration(node, decorators, modifiers, body) { + return node.decorators !== decorators + || node.modifier !== modifiers + || node.body !== body + ? update(createClassStaticBlockDeclaration(decorators, modifiers, body), node) + : node; + } + // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(167 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(169 /* Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); @@ -22116,7 +22599,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(168 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(170 /* GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -22132,7 +22615,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(169 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(171 /* SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -22148,7 +22631,7 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(170 /* CallSignature */, + var node = createBaseSignatureDeclaration(172 /* CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -22165,7 +22648,7 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(171 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(173 /* ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -22182,7 +22665,7 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(172 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(174 /* IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22199,7 +22682,7 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(195 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(197 /* TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; @@ -22221,7 +22704,7 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(173 /* TypePredicate */); + var node = createBaseNode(175 /* TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; @@ -22238,7 +22721,7 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(174 /* TypeReference */); + var node = createBaseNode(176 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22253,7 +22736,7 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* FunctionType */, + var node = createBaseSignatureDeclaration(177 /* FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -22279,7 +22762,7 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(176 /* ConstructorType */, + var node = createBaseSignatureDeclaration(178 /* ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22313,7 +22796,7 @@ var ts; } // @api function createTypeQueryNode(exprName) { - var node = createBaseNode(177 /* TypeQuery */); + var node = createBaseNode(179 /* TypeQuery */); node.exprName = exprName; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22326,7 +22809,7 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(178 /* TypeLiteral */); + var node = createBaseNode(180 /* TypeLiteral */); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22339,7 +22822,7 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(179 /* ArrayType */); + var node = createBaseNode(181 /* ArrayType */); node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22352,7 +22835,7 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(180 /* TupleType */); + var node = createBaseNode(182 /* TupleType */); node.elements = createNodeArray(elements); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22365,7 +22848,7 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(193 /* NamedTupleMember */); + var node = createBaseNode(195 /* NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; @@ -22384,7 +22867,7 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(181 /* OptionalType */); + var node = createBaseNode(183 /* OptionalType */); node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22397,7 +22880,7 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(182 /* RestType */); + var node = createBaseNode(184 /* RestType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22421,7 +22904,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(183 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(185 /* UnionType */, types); } // @api function updateUnionTypeNode(node, types) { @@ -22429,7 +22912,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(184 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(186 /* IntersectionType */, types); } // @api function updateIntersectionTypeNode(node, types) { @@ -22437,7 +22920,7 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(185 /* ConditionalType */); + var node = createBaseNode(187 /* ConditionalType */); node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType); node.trueType = trueType; @@ -22456,7 +22939,7 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(186 /* InferType */); + var node = createBaseNode(188 /* InferType */); node.typeParameter = typeParameter; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22469,7 +22952,7 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(194 /* TemplateLiteralType */); + var node = createBaseNode(196 /* TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22485,7 +22968,7 @@ var ts; // @api function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(196 /* ImportType */); + var node = createBaseNode(198 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); @@ -22505,7 +22988,7 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(187 /* ParenthesizedType */); + var node = createBaseNode(189 /* ParenthesizedType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22518,13 +23001,13 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(188 /* ThisType */); + var node = createBaseNode(190 /* ThisType */); node.transformFlags = 1 /* ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(189 /* TypeOperator */); + var node = createBaseNode(191 /* TypeOperator */); node.operator = operator; node.type = parenthesizerRules().parenthesizeMemberOfElementType(type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22538,7 +23021,7 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(190 /* IndexedAccessType */); + var node = createBaseNode(192 /* IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType); node.indexType = indexType; node.transformFlags = 1 /* ContainsTypeScript */; @@ -22553,7 +23036,7 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { - var node = createBaseNode(191 /* MappedType */); + var node = createBaseNode(193 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; @@ -22574,7 +23057,7 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(192 /* LiteralType */); + var node = createBaseNode(194 /* LiteralType */); node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22590,7 +23073,7 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(197 /* ObjectBindingPattern */); + var node = createBaseNode(199 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | @@ -22611,7 +23094,7 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(198 /* ArrayBindingPattern */); + var node = createBaseNode(200 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | @@ -22627,7 +23110,7 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(199 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(201 /* BindingElement */, /*decorators*/ undefined, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); @@ -22663,8 +23146,13 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(200 /* ArrayLiteralExpression */); - node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(elements)); + var node = createBaseExpression(202 /* ArrayLiteralExpression */); + // Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that + // we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like + // a trailing comma. + var lastElement = elements && ts.lastOrUndefined(elements); + var elementsArray = createNodeArray(elements, lastElement && ts.isOmittedExpression(lastElement) ? true : undefined); + node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(elementsArray); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -22677,7 +23165,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(201 /* ObjectLiteralExpression */); + var node = createBaseExpression(203 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -22691,7 +23179,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(202 /* PropertyAccessExpression */); + var node = createBaseExpression(204 /* PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -22720,7 +23208,7 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(202 /* PropertyAccessExpression */); + var node = createBaseExpression(204 /* PropertyAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22747,7 +23235,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(203 /* ElementAccessExpression */); + var node = createBaseExpression(205 /* ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -22774,7 +23262,7 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(203 /* ElementAccessExpression */); + var node = createBaseExpression(205 /* ElementAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22799,7 +23287,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(204 /* CallExpression */); + var node = createBaseExpression(206 /* CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -22831,7 +23319,7 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(204 /* CallExpression */); + var node = createBaseExpression(206 /* CallExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22863,7 +23351,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(205 /* NewExpression */); + var node = createBaseExpression(207 /* NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -22887,7 +23375,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(206 /* TaggedTemplateExpression */); + var node = createBaseExpression(208 /* TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -22914,7 +23402,7 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(207 /* TypeAssertionExpression */); + var node = createBaseExpression(209 /* TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= @@ -22932,7 +23420,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(208 /* ParenthesizedExpression */); + var node = createBaseExpression(210 /* ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -22945,7 +23433,7 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(209 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(211 /* FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); @@ -22979,7 +23467,7 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(210 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(212 /* ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); @@ -22987,7 +23475,7 @@ var ts; propagateChildFlags(node.equalsGreaterThanToken) | 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 128 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */; } return node; } @@ -23004,7 +23492,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(211 /* DeleteExpression */); + var node = createBaseExpression(213 /* DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23017,7 +23505,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(212 /* TypeOfExpression */); + var node = createBaseExpression(214 /* TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23030,7 +23518,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(213 /* VoidExpression */); + var node = createBaseExpression(215 /* VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23043,7 +23531,7 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(214 /* AwaitExpression */); + var node = createBaseExpression(216 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -23060,10 +23548,18 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(215 /* PrefixUnaryExpression */); + var node = createBaseExpression(217 /* PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); + // Only set this flag for non-generated identifiers and non-"local" names. See the + // comment in `visitPreOrPostfixUnaryExpression` in module.ts + if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) && + ts.isIdentifier(node.operand) && + !ts.isGeneratedIdentifier(node.operand) && + !ts.isLocalName(node.operand)) { + node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + } return node; } // @api @@ -23074,10 +23570,17 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(216 /* PostfixUnaryExpression */); + var node = createBaseExpression(218 /* PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); - node.transformFlags = propagateChildFlags(node.operand); + node.transformFlags |= propagateChildFlags(node.operand); + // Only set this flag for non-generated identifiers and non-"local" names. See the + // comment in `visitPreOrPostfixUnaryExpression` in module.ts + if (ts.isIdentifier(node.operand) && + !ts.isGeneratedIdentifier(node.operand) && + !ts.isLocalName(node.operand)) { + node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */; + } return node; } // @api @@ -23088,7 +23591,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(217 /* BinaryExpression */); + var node = createBaseExpression(219 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -23101,7 +23604,7 @@ var ts; if (operatorKind === 60 /* QuestionQuestionToken */) { node.transformFlags |= 16 /* ContainsES2020 */; } - else if (operatorKind === 62 /* EqualsToken */) { + else if (operatorKind === 63 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= 512 /* ContainsES2015 */ | @@ -23116,7 +23619,7 @@ var ts; propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 66 /* AsteriskAsteriskEqualsToken */) { + else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { node.transformFlags |= 256 /* ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { @@ -23157,7 +23660,7 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(218 /* ConditionalExpression */); + var node = createBaseExpression(220 /* ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); @@ -23183,7 +23686,7 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(219 /* TemplateExpression */); + var node = createBaseExpression(221 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= @@ -23253,7 +23756,7 @@ var ts; // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(220 /* YieldExpression */); + var node = createBaseExpression(222 /* YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= @@ -23273,7 +23776,7 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(221 /* SpreadElement */); + var node = createBaseExpression(223 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -23289,7 +23792,7 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(222 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(224 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); node.transformFlags |= 512 /* ContainsES2015 */; return node; } @@ -23306,11 +23809,11 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(223 /* OmittedExpression */); + return createBaseExpression(225 /* OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(224 /* ExpressionWithTypeArguments */); + var node = createBaseNode(226 /* ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= @@ -23328,7 +23831,7 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(225 /* AsExpression */); + var node = createBaseExpression(227 /* AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= @@ -23346,7 +23849,7 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(226 /* NonNullExpression */); + var node = createBaseExpression(228 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -23364,7 +23867,7 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(226 /* NonNullExpression */); + var node = createBaseExpression(228 /* NonNullExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= @@ -23381,15 +23884,15 @@ var ts; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(227 /* MetaProperty */); + var node = createBaseExpression(229 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: node.transformFlags |= 512 /* ContainsES2015 */; break; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: node.transformFlags |= 4 /* ContainsESNext */; break; default: @@ -23408,7 +23911,7 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(229 /* TemplateSpan */); + var node = createBaseNode(231 /* TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= @@ -23426,7 +23929,7 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(230 /* SemicolonClassElement */); + var node = createBaseNode(232 /* SemicolonClassElement */); node.transformFlags |= 512 /* ContainsES2015 */; return node; } @@ -23435,7 +23938,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(231 /* Block */); + var node = createBaseNode(233 /* Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -23449,7 +23952,7 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(233 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(235 /* VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); @@ -23467,11 +23970,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(232 /* EmptyStatement */); + return createBaseNode(234 /* EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(234 /* ExpressionStatement */); + var node = createBaseNode(236 /* ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23484,7 +23987,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(235 /* IfStatement */); + var node = createBaseNode(237 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -23504,7 +24007,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(236 /* DoStatement */); + var node = createBaseNode(238 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -23521,7 +24024,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(237 /* WhileStatement */); + var node = createBaseNode(239 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23538,7 +24041,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(238 /* ForStatement */); + var node = createBaseNode(240 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -23561,7 +24064,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(239 /* ForInStatement */); + var node = createBaseNode(241 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -23581,7 +24084,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(240 /* ForOfStatement */); + var node = createBaseNode(242 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -23607,7 +24110,7 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(241 /* ContinueStatement */); + var node = createBaseNode(243 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | @@ -23622,7 +24125,7 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(242 /* BreakStatement */); + var node = createBaseNode(244 /* BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | @@ -23637,7 +24140,7 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(243 /* ReturnStatement */); + var node = createBaseNode(245 /* ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= @@ -23654,7 +24157,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(244 /* WithStatement */); + var node = createBaseNode(246 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23671,7 +24174,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(245 /* SwitchStatement */); + var node = createBaseNode(247 /* SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -23688,7 +24191,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(246 /* LabeledStatement */); + var node = createBaseNode(248 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23705,7 +24208,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(247 /* ThrowStatement */); + var node = createBaseNode(249 /* ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23718,7 +24221,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(248 /* TryStatement */); + var node = createBaseNode(250 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -23738,11 +24241,11 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(249 /* DebuggerStatement */); + return createBaseNode(251 /* DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(250 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(252 /* VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; @@ -23764,7 +24267,7 @@ var ts; // @api function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(251 /* VariableDeclarationList */); + var node = createBaseNode(253 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= @@ -23785,7 +24288,7 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(252 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(254 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; @@ -23823,7 +24326,7 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(253 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(255 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } @@ -23848,7 +24351,7 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(254 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(256 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23866,7 +24369,7 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(255 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(257 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23883,7 +24386,7 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(256 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(258 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | @@ -23903,7 +24406,7 @@ var ts; // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(257 /* ModuleDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(259 /* ModuleDeclaration */, decorators, modifiers); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.name = name; node.body = body; @@ -23930,7 +24433,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(258 /* ModuleBlock */); + var node = createBaseNode(260 /* ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -23943,7 +24446,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(259 /* CaseBlock */); + var node = createBaseNode(261 /* CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -23956,7 +24459,7 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(260 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(262 /* NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.transformFlags = 1 /* ContainsTypeScript */; @@ -23970,7 +24473,7 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(261 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(263 /* ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); @@ -23991,7 +24494,7 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createBaseDeclaration(262 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(264 /* ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= @@ -24011,7 +24514,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(263 /* ImportClause */); + var node = createBaseNode(265 /* ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -24034,7 +24537,7 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(264 /* NamespaceImport */); + var node = createBaseNode(266 /* NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -24048,7 +24551,7 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(270 /* NamespaceExport */); + var node = createBaseNode(272 /* NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | @@ -24064,7 +24567,7 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(265 /* NamedImports */); + var node = createBaseNode(267 /* NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -24078,7 +24581,7 @@ var ts; } // @api function createImportSpecifier(propertyName, name) { - var node = createBaseNode(266 /* ImportSpecifier */); + var node = createBaseNode(268 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; node.transformFlags |= @@ -24096,10 +24599,10 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(267 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(269 /* ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(62 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -24115,7 +24618,7 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { - var node = createBaseDeclaration(268 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(270 /* ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; @@ -24137,7 +24640,7 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(269 /* NamedExports */); + var node = createBaseNode(271 /* NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -24151,7 +24654,7 @@ var ts; } // @api function createExportSpecifier(propertyName, name) { - var node = createBaseNode(271 /* ExportSpecifier */); + var node = createBaseNode(273 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= @@ -24169,7 +24672,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(272 /* MissingDeclaration */, + var node = createBaseDeclaration(274 /* MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -24179,7 +24682,7 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(273 /* ExternalModuleReference */); + var node = createBaseNode(275 /* ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -24224,7 +24727,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(309 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(312 /* JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -24241,7 +24744,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(314 /* JSDocTypeLiteral */); + var node = createBaseNode(317 /* JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -24255,7 +24758,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(302 /* JSDocTypeExpression */); + var node = createBaseNode(304 /* JSDocTypeExpression */); node.type = type; return node; } @@ -24267,7 +24770,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(315 /* JSDocSignature */); + var node = createBaseNode(318 /* JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -24296,7 +24799,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(334 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(339 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -24313,7 +24816,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(335 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(340 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -24331,7 +24834,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(330 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(335 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -24352,7 +24855,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(337 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(342 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -24373,7 +24876,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(328 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(333 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -24391,7 +24894,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(318 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(323 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -24406,13 +24909,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(319 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(324 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(336 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(341 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -24426,7 +24929,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(303 /* JSDocNameReference */); + var node = createBaseNode(305 /* JSDocNameReference */); node.name = name; return node; } @@ -24437,8 +24940,25 @@ var ts; : node; } // @api + function createJSDocMemberName(left, right) { + var node = createBaseNode(306 /* JSDocMemberName */); + node.left = left; + node.right = right; + node.transformFlags |= + propagateChildFlags(node.left) | + propagateChildFlags(node.right); + return node; + } + // @api + function updateJSDocMemberName(node, left, right) { + return node.left !== left + || node.right !== right + ? update(createJSDocMemberName(left, right), node) + : node; + } + // @api function createJSDocLink(name, text) { - var node = createBaseNode(316 /* JSDocLink */); + var node = createBaseNode(319 /* JSDocLink */); node.name = name; node.text = text; return node; @@ -24450,6 +24970,32 @@ var ts; : node; } // @api + function createJSDocLinkCode(name, text) { + var node = createBaseNode(320 /* JSDocLinkCode */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkCode(node, name, text) { + return node.name !== name + ? update(createJSDocLinkCode(name, text), node) + : node; + } + // @api + function createJSDocLinkPlain(name, text) { + var node = createBaseNode(321 /* JSDocLinkPlain */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkPlain(node, name, text) { + return node.name !== name + ? update(createJSDocLinkPlain(name, text), node) + : node; + } + // @api function updateJSDocImplementsTag(node, tagName, className, comment) { if (tagName === void 0) { tagName = getDefaultTagName(node); } return node.tagName !== tagName @@ -24510,7 +25056,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(317 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(322 /* JSDocTag */, tagName, comment); return node; } // @api @@ -24522,7 +25068,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(313 /* JSDocText */); + var node = createBaseNode(316 /* JSDocText */); node.text = text; return node; } @@ -24534,7 +25080,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(312 /* JSDocComment */); + var node = createBaseNode(315 /* JSDocComment */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -24551,7 +25097,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(274 /* JsxElement */); + var node = createBaseNode(276 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -24572,7 +25118,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(275 /* JsxSelfClosingElement */); + var node = createBaseNode(277 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -24596,7 +25142,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(276 /* JsxOpeningElement */); + var node = createBaseNode(278 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -24620,7 +25166,7 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(277 /* JsxClosingElement */); + var node = createBaseNode(279 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | @@ -24635,7 +25181,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(278 /* JsxFragment */); + var node = createBaseNode(280 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -24671,19 +25217,19 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(279 /* JsxOpeningFragment */); + var node = createBaseNode(281 /* JsxOpeningFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(280 /* JsxClosingFragment */); + var node = createBaseNode(282 /* JsxClosingFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(281 /* JsxAttribute */); + var node = createBaseNode(283 /* JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= @@ -24701,7 +25247,7 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(282 /* JsxAttributes */); + var node = createBaseNode(284 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | @@ -24716,7 +25262,7 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(283 /* JsxSpreadAttribute */); + var node = createBaseNode(285 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | @@ -24731,7 +25277,7 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(284 /* JsxExpression */); + var node = createBaseNode(286 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= @@ -24751,7 +25297,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(285 /* CaseClause */); + var node = createBaseNode(287 /* CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -24768,7 +25314,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(286 /* DefaultClause */); + var node = createBaseNode(288 /* DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -24781,15 +25327,15 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(287 /* HeritageClause */); + var node = createBaseNode(289 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 93 /* ExtendsKeyword */: + case 94 /* ExtendsKeyword */: node.transformFlags |= 512 /* ContainsES2015 */; break; - case 116 /* ImplementsKeyword */: + case 117 /* ImplementsKeyword */: node.transformFlags |= 1 /* ContainsTypeScript */; break; default: @@ -24805,7 +25351,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(288 /* CatchClause */); + var node = createBaseNode(290 /* CatchClause */); variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, /*type*/ undefined, @@ -24831,7 +25377,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(289 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(291 /* PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -24861,7 +25407,7 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(290 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(292 /* ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); @@ -24893,7 +25439,7 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(291 /* SpreadAssignment */); + var node = createBaseNode(293 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -24912,7 +25458,7 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(292 /* EnumMember */); + var node = createBaseNode(294 /* EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -24933,7 +25479,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(298 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(300 /* SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -24950,7 +25496,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(298 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(300 /* SourceFile */); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -24988,7 +25534,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(299 /* Bundle */); + var node = createBaseNode(301 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -25003,7 +25549,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(300 /* UnparsedSource */); + var node = createBaseNode(302 /* UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -25021,28 +25567,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(293 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(295 /* UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(294 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(296 /* UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 296 /* UnparsedInternalText */ : 295 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 298 /* UnparsedInternalText */ : 297 /* UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(297 /* UnparsedSyntheticReference */); + var node = createBaseNode(299 /* UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(301 /* InputFiles */); + var node = createBaseNode(303 /* InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -25053,7 +25599,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(228 /* SyntheticExpression */); + var node = createBaseNode(230 /* SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -25061,7 +25607,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(338 /* SyntaxList */); + var node = createBaseNode(343 /* SyntaxList */); node._children = children; return node; } @@ -25076,7 +25622,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(339 /* NotEmittedStatement */); + var node = createBaseNode(344 /* NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -25090,7 +25636,7 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(340 /* PartiallyEmittedExpression */); + var node = createBaseNode(345 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= @@ -25118,7 +25664,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(341 /* CommaListExpression */); + var node = createBaseNode(346 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -25135,7 +25681,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(343 /* EndOfDeclarationMarker */); + var node = createBaseNode(348 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -25146,14 +25692,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(342 /* MergeDeclarationMarker */); + var node = createBaseNode(347 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(344 /* SyntheticReferenceExpression */); + var node = createBaseNode(349 /* SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -25175,9 +25721,9 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(298 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(78 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(79 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(300 /* SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); clone.flags |= (node.flags & ~8 /* Synthesized */); @@ -25238,14 +25784,20 @@ var ts; : factory.createStrictEquality(createTypeOfExpression(value), createStringLiteral(tag)); } function createMethodCall(object, methodName, argumentsList) { + // Preserve the optionality of `object`. + if (ts.isCallChain(object)) { + return createCallChain(createPropertyAccessChain(object, /*questionDotToken*/ undefined, methodName), + /*questionDotToken*/ undefined, + /*typeArguments*/ undefined, argumentsList); + } return createCallExpression(createPropertyAccessExpression(object, methodName), /*typeArguments*/ undefined, argumentsList); } function createFunctionBindCall(target, thisArg, argumentsList) { - return createMethodCall(target, "bind", __spreadArray([thisArg], argumentsList)); + return createMethodCall(target, "bind", __spreadArray([thisArg], argumentsList, true)); } function createFunctionCallCall(target, thisArg, argumentsList) { - return createMethodCall(target, "call", __spreadArray([thisArg], argumentsList)); + return createMethodCall(target, "call", __spreadArray([thisArg], argumentsList, true)); } function createFunctionApplyCall(target, thisArg, argumentsExpression) { return createMethodCall(target, "apply", [thisArg, argumentsExpression]); @@ -25262,6 +25814,12 @@ var ts; function createObjectDefinePropertyCall(target, propertyName, attributes) { return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); } + function createReflectGetCall(target, propertyKey, receiver) { + return createGlobalMethodCall("Reflect", "get", receiver ? [target, propertyKey, receiver] : [target, propertyKey]); + } + function createReflectSetCall(target, propertyKey, value, receiver) { + return createGlobalMethodCall("Reflect", "set", receiver ? [target, propertyKey, value, receiver] : [target, propertyKey, value]); + } function tryAddPropertyAssignment(properties, propertyName, expression) { if (expression) { properties.push(createPropertyAssignment(propertyName, expression)); @@ -25282,11 +25840,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 208 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 207 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 225 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 226 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 340 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 210 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 209 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 227 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 228 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 345 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -25333,20 +25891,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return cacheIdentifiers; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -25402,6 +25960,23 @@ var ts; } return { target: target, thisArg: thisArg }; } + function createAssignmentTargetWrapper(paramName, expression) { + return createPropertyAccessExpression( + // Explicit parens required because of v8 regression (https://bugs.chromium.org/p/v8/issues/detail?id=9560) + createParenthesizedExpression(createObjectLiteralExpression([ + createSetAccessorDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, "value", [createParameterDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, paramName, + /*questionToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined)], createBlock([ + createExpressionStatement(expression) + ])) + ])), "value"); + } function inlineExpressions(expressions) { // Avoid deeply nested comma expressions as traversing them during emit can result in "Maximum call // stack size exceeded" errors. @@ -25582,7 +26157,7 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = ts.findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(createNodeArray(__spreadArray([createUseStrictPrologue()], statements)), statements); + return ts.setTextRange(createNodeArray(__spreadArray([createUseStrictPrologue()], statements, true)), statements); } return statements; } @@ -25649,20 +26224,20 @@ var ts; var left = ts.isNodeArray(statements) ? statements.slice() : statements; // splice other custom prologues from right into left if (rightCustomPrologueEnd > rightHoistedVariablesEnd) { - left.splice.apply(left, __spreadArray([leftHoistedVariablesEnd, 0], declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd))); + left.splice.apply(left, __spreadArray([leftHoistedVariablesEnd, 0], declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd), false)); } // splice hoisted variables from right into left if (rightHoistedVariablesEnd > rightHoistedFunctionsEnd) { - left.splice.apply(left, __spreadArray([leftHoistedFunctionsEnd, 0], declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd))); + left.splice.apply(left, __spreadArray([leftHoistedFunctionsEnd, 0], declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd), false)); } // splice hoisted functions from right into left if (rightHoistedFunctionsEnd > rightStandardPrologueEnd) { - left.splice.apply(left, __spreadArray([leftStandardPrologueEnd, 0], declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd))); + left.splice.apply(left, __spreadArray([leftStandardPrologueEnd, 0], declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd), false)); } // splice standard prologues from right into left (that are not already in left) if (rightStandardPrologueEnd > 0) { if (leftStandardPrologueEnd === 0) { - left.splice.apply(left, __spreadArray([0, 0], declarations.slice(0, rightStandardPrologueEnd))); + left.splice.apply(left, __spreadArray([0, 0], declarations.slice(0, rightStandardPrologueEnd), false)); } else { var leftPrologues = new ts.Map(); @@ -25749,24 +26324,24 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 333 /* JSDocTypeTag */: return "type"; - case 331 /* JSDocReturnTag */: return "returns"; - case 332 /* JSDocThisTag */: return "this"; - case 329 /* JSDocEnumTag */: return "enum"; - case 320 /* JSDocAuthorTag */: return "author"; - case 322 /* JSDocClassTag */: return "class"; - case 323 /* JSDocPublicTag */: return "public"; - case 324 /* JSDocPrivateTag */: return "private"; - case 325 /* JSDocProtectedTag */: return "protected"; - case 326 /* JSDocReadonlyTag */: return "readonly"; - case 327 /* JSDocOverrideTag */: return "override"; - case 334 /* JSDocTemplateTag */: return "template"; - case 335 /* JSDocTypedefTag */: return "typedef"; - case 330 /* JSDocParameterTag */: return "param"; - case 337 /* JSDocPropertyTag */: return "prop"; - case 328 /* JSDocCallbackTag */: return "callback"; - case 318 /* JSDocAugmentsTag */: return "augments"; - case 319 /* JSDocImplementsTag */: return "implements"; + case 338 /* JSDocTypeTag */: return "type"; + case 336 /* JSDocReturnTag */: return "returns"; + case 337 /* JSDocThisTag */: return "this"; + case 334 /* JSDocEnumTag */: return "enum"; + case 325 /* JSDocAuthorTag */: return "author"; + case 327 /* JSDocClassTag */: return "class"; + case 328 /* JSDocPublicTag */: return "public"; + case 329 /* JSDocPrivateTag */: return "private"; + case 330 /* JSDocProtectedTag */: return "protected"; + case 331 /* JSDocReadonlyTag */: return "readonly"; + case 332 /* JSDocOverrideTag */: return "override"; + case 339 /* JSDocTemplateTag */: return "template"; + case 340 /* JSDocTypedefTag */: return "typedef"; + case 335 /* JSDocParameterTag */: return "param"; + case 342 /* JSDocPropertyTag */: return "prop"; + case 333 /* JSDocCallbackTag */: return "callback"; + case 323 /* JSDocAugmentsTag */: return "augments"; + case 324 /* JSDocImplementsTag */: return "implements"; default: return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); } @@ -25794,7 +26369,7 @@ var ts; break; } var token = rawTextScanner.scan(); - if (token === 23 /* CloseBracketToken */) { + if (token === 19 /* CloseBraceToken */) { token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false); } if (rawTextScanner.isUnterminated()) { @@ -25822,7 +26397,7 @@ var ts; return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 8192 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) @@ -25846,69 +26421,69 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 173 /* FirstTypeNode */ && kind <= 196 /* LastTypeNode */) { + if (kind >= 175 /* FirstTypeNode */ && kind <= 198 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 204 /* CallExpression */: - case 205 /* NewExpression */: - case 200 /* ArrayLiteralExpression */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: + case 202 /* ArrayLiteralExpression */: return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; - case 257 /* ModuleDeclaration */: - return 555888640 /* ModuleExcludes */; - case 161 /* Parameter */: + case 259 /* ModuleDeclaration */: + return 589443072 /* ModuleExcludes */; + case 162 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return 557748224 /* ArrowFunctionExcludes */; - case 209 /* FunctionExpression */: - case 252 /* FunctionDeclaration */: - return 557756416 /* FunctionExcludes */; - case 251 /* VariableDeclarationList */: + case 211 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: + return 591310848 /* FunctionExcludes */; + case 253 /* VariableDeclarationList */: return 537165824 /* VariableDeclarationListExcludes */; - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: return 536940544 /* ClassExcludes */; - case 167 /* Constructor */: - return 557752320 /* ConstructorExcludes */; - case 164 /* PropertyDeclaration */: - return 536879104 /* PropertyExcludes */; - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - return 540975104 /* MethodOrAccessorExcludes */; - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 147 /* StringKeyword */: - case 145 /* ObjectKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 160 /* TypeParameter */: - case 163 /* PropertySignature */: - case 165 /* MethodSignature */: - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 172 /* IndexSignature */: - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: + case 169 /* Constructor */: + return 591306752 /* ConstructorExcludes */; + case 165 /* PropertyDeclaration */: + return 570433536 /* PropertyExcludes */; + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + return 574529536 /* MethodOrAccessorExcludes */; + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 148 /* StringKeyword */: + case 146 /* ObjectKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 161 /* TypeParameter */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 174 /* IndexSignature */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return 536973312 /* ObjectLiteralExcludes */; - case 288 /* CatchClause */: + case 290 /* CatchClause */: return 536903680 /* CatchClauseExcludes */; - case 197 /* ObjectBindingPattern */: - case 198 /* ArrayBindingPattern */: + case 199 /* ObjectBindingPattern */: + case 200 /* ArrayBindingPattern */: return 536887296 /* BindingPatternExcludes */; - case 207 /* TypeAssertionExpression */: - case 225 /* AsExpression */: - case 340 /* PartiallyEmittedExpression */: - case 208 /* ParenthesizedExpression */: - case 105 /* SuperKeyword */: + case 209 /* TypeAssertionExpression */: + case 227 /* AsExpression */: + case 345 /* PartiallyEmittedExpression */: + case 210 /* ParenthesizedExpression */: + case 106 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -26165,7 +26740,7 @@ var ts; if (trailingComments) destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) - destEmitNode.flags = flags; + destEmitNode.flags = flags & ~268435456 /* Immutable */; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) @@ -26207,7 +26782,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 298 /* SourceFile */) { + if (node.kind === 300 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -26215,6 +26790,9 @@ var ts; } node.emitNode = {}; } + else { + ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node."); + } return node.emitNode; } ts.getOrCreateEmitNode = getOrCreateEmitNode; @@ -26472,6 +27050,8 @@ var ts; (function (ts) { function createEmitHelperFactory(context) { var factory = context.factory; + var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); }); + var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); }); return { getUnscopedHelperName: getUnscopedHelperName, // TypeScript Helpers @@ -26642,10 +27222,10 @@ var ts; return factory.createCallExpression(getUnscopedHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [cooked, raw]); } - function createSpreadArrayHelper(to, from) { + function createSpreadArrayHelper(to, from, packFrom) { context.requestEmitHelper(ts.spreadArrayHelper); return factory.createCallExpression(getUnscopedHelperName("__spreadArray"), - /*typeArguments*/ undefined, [to, from]); + /*typeArguments*/ undefined, [to, from, packFrom ? immutableTrue() : immutableFalse()]); } // ES2015 Destructuring Helpers function createValuesHelper(expression) { @@ -26670,7 +27250,7 @@ var ts; function createCreateBindingHelper(module, inputName, outputName) { context.requestEmitHelper(ts.createBindingHelper); return factory.createCallExpression(getUnscopedHelperName("__createBinding"), - /*typeArguments*/ undefined, __spreadArray([factory.createIdentifier("exports"), module, inputName], (outputName ? [outputName] : []))); + /*typeArguments*/ undefined, __spreadArray([factory.createIdentifier("exports"), module, inputName], (outputName ? [outputName] : []), true)); } function createImportStarHelper(expression) { context.requestEmitHelper(ts.importStarHelper); @@ -26847,7 +27427,7 @@ var ts; name: "typescript:spreadArray", importName: "__spreadArray", scoped: false, - text: "\n var __spreadArray = (this && this.__spreadArray) || function (to, from) {\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\n to[j] = from[i];\n return to;\n };" + text: "\n var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n };" }; // ES2015 Destructuring Helpers ts.valuesHelper = { @@ -27115,7 +27695,7 @@ var ts; function isCallToHelper(firstSegment, helperName) { return ts.isCallExpression(firstSegment) && ts.isIdentifier(firstSegment.expression) - && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0 && firstSegment.expression.escapedText === helperName; } ts.isCallToHelper = isCallToHelper; @@ -27209,639 +27789,648 @@ var ts; ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 78 /* Identifier */; + return node.kind === 79 /* Identifier */; } ts.isIdentifier = isIdentifier; function isPrivateIdentifier(node) { - return node.kind === 79 /* PrivateIdentifier */; + return node.kind === 80 /* PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; // Reserved Words /* @internal */ function isExportModifier(node) { - return node.kind === 92 /* ExportKeyword */; + return node.kind === 93 /* ExportKeyword */; } ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 129 /* AsyncKeyword */; + return node.kind === 130 /* AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ function isAssertsKeyword(node) { - return node.kind === 127 /* AssertsKeyword */; + return node.kind === 128 /* AssertsKeyword */; } ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 130 /* AwaitKeyword */; + return node.kind === 131 /* AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 142 /* ReadonlyKeyword */; + return node.kind === 143 /* ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ function isStaticModifier(node) { - return node.kind === 123 /* StaticKeyword */; + return node.kind === 124 /* StaticKeyword */; } ts.isStaticModifier = isStaticModifier; + /* @internal */ + function isAbstractModifier(node) { + return node.kind === 126 /* AbstractKeyword */; + } + ts.isAbstractModifier = isAbstractModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 105 /* SuperKeyword */; + return node.kind === 106 /* SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 99 /* ImportKeyword */; + return node.kind === 100 /* ImportKeyword */; } ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 158 /* QualifiedName */; + return node.kind === 159 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 159 /* ComputedPropertyName */; + return node.kind === 160 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 160 /* TypeParameter */; + return node.kind === 161 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 161 /* Parameter */; + return node.kind === 162 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 162 /* Decorator */; + return node.kind === 163 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 163 /* PropertySignature */; + return node.kind === 164 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 164 /* PropertyDeclaration */; + return node.kind === 165 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 165 /* MethodSignature */; + return node.kind === 166 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 166 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; + function isClassStaticBlockDeclaration(node) { + return node.kind === 168 /* ClassStaticBlockDeclaration */; + } + ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 167 /* Constructor */; + return node.kind === 169 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 168 /* GetAccessor */; + return node.kind === 170 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 169 /* SetAccessor */; + return node.kind === 171 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 170 /* CallSignature */; + return node.kind === 172 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 171 /* ConstructSignature */; + return node.kind === 173 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 172 /* IndexSignature */; + return node.kind === 174 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 173 /* TypePredicate */; + return node.kind === 175 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 174 /* TypeReference */; + return node.kind === 176 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 175 /* FunctionType */; + return node.kind === 177 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 176 /* ConstructorType */; + return node.kind === 178 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 177 /* TypeQuery */; + return node.kind === 179 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 178 /* TypeLiteral */; + return node.kind === 180 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 179 /* ArrayType */; + return node.kind === 181 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 180 /* TupleType */; + return node.kind === 182 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 193 /* NamedTupleMember */; + return node.kind === 195 /* NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 181 /* OptionalType */; + return node.kind === 183 /* OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 182 /* RestType */; + return node.kind === 184 /* RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 183 /* UnionType */; + return node.kind === 185 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 184 /* IntersectionType */; + return node.kind === 186 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 185 /* ConditionalType */; + return node.kind === 187 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 186 /* InferType */; + return node.kind === 188 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 187 /* ParenthesizedType */; + return node.kind === 189 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 188 /* ThisType */; + return node.kind === 190 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 189 /* TypeOperator */; + return node.kind === 191 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 190 /* IndexedAccessType */; + return node.kind === 192 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 191 /* MappedType */; + return node.kind === 193 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 192 /* LiteralType */; + return node.kind === 194 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 196 /* ImportType */; + return node.kind === 198 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 195 /* TemplateLiteralTypeSpan */; + return node.kind === 197 /* TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 194 /* TemplateLiteralType */; + return node.kind === 196 /* TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 197 /* ObjectBindingPattern */; + return node.kind === 199 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 198 /* ArrayBindingPattern */; + return node.kind === 200 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 199 /* BindingElement */; + return node.kind === 201 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 200 /* ArrayLiteralExpression */; + return node.kind === 202 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 201 /* ObjectLiteralExpression */; + return node.kind === 203 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 202 /* PropertyAccessExpression */; + return node.kind === 204 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 203 /* ElementAccessExpression */; + return node.kind === 205 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 204 /* CallExpression */; + return node.kind === 206 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 205 /* NewExpression */; + return node.kind === 207 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 206 /* TaggedTemplateExpression */; + return node.kind === 208 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 207 /* TypeAssertionExpression */; + return node.kind === 209 /* TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 208 /* ParenthesizedExpression */; + return node.kind === 210 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 209 /* FunctionExpression */; + return node.kind === 211 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 210 /* ArrowFunction */; + return node.kind === 212 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 211 /* DeleteExpression */; + return node.kind === 213 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 212 /* TypeOfExpression */; + return node.kind === 214 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 213 /* VoidExpression */; + return node.kind === 215 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 214 /* AwaitExpression */; + return node.kind === 216 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 215 /* PrefixUnaryExpression */; + return node.kind === 217 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 216 /* PostfixUnaryExpression */; + return node.kind === 218 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 217 /* BinaryExpression */; + return node.kind === 219 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 218 /* ConditionalExpression */; + return node.kind === 220 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 219 /* TemplateExpression */; + return node.kind === 221 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 220 /* YieldExpression */; + return node.kind === 222 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 221 /* SpreadElement */; + return node.kind === 223 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 222 /* ClassExpression */; + return node.kind === 224 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 223 /* OmittedExpression */; + return node.kind === 225 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 224 /* ExpressionWithTypeArguments */; + return node.kind === 226 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 225 /* AsExpression */; + return node.kind === 227 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 226 /* NonNullExpression */; + return node.kind === 228 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 227 /* MetaProperty */; + return node.kind === 229 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 228 /* SyntheticExpression */; + return node.kind === 230 /* SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 340 /* PartiallyEmittedExpression */; + return node.kind === 345 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 341 /* CommaListExpression */; + return node.kind === 346 /* CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 229 /* TemplateSpan */; + return node.kind === 231 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 230 /* SemicolonClassElement */; + return node.kind === 232 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 231 /* Block */; + return node.kind === 233 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 233 /* VariableStatement */; + return node.kind === 235 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 232 /* EmptyStatement */; + return node.kind === 234 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 234 /* ExpressionStatement */; + return node.kind === 236 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 235 /* IfStatement */; + return node.kind === 237 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 236 /* DoStatement */; + return node.kind === 238 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 237 /* WhileStatement */; + return node.kind === 239 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 238 /* ForStatement */; + return node.kind === 240 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 239 /* ForInStatement */; + return node.kind === 241 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 240 /* ForOfStatement */; + return node.kind === 242 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 241 /* ContinueStatement */; + return node.kind === 243 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 242 /* BreakStatement */; + return node.kind === 244 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 243 /* ReturnStatement */; + return node.kind === 245 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 244 /* WithStatement */; + return node.kind === 246 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 245 /* SwitchStatement */; + return node.kind === 247 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 246 /* LabeledStatement */; + return node.kind === 248 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 247 /* ThrowStatement */; + return node.kind === 249 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 248 /* TryStatement */; + return node.kind === 250 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 249 /* DebuggerStatement */; + return node.kind === 251 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 250 /* VariableDeclaration */; + return node.kind === 252 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 251 /* VariableDeclarationList */; + return node.kind === 253 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 252 /* FunctionDeclaration */; + return node.kind === 254 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 253 /* ClassDeclaration */; + return node.kind === 255 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 254 /* InterfaceDeclaration */; + return node.kind === 256 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 255 /* TypeAliasDeclaration */; + return node.kind === 257 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 256 /* EnumDeclaration */; + return node.kind === 258 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 257 /* ModuleDeclaration */; + return node.kind === 259 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 258 /* ModuleBlock */; + return node.kind === 260 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 259 /* CaseBlock */; + return node.kind === 261 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 260 /* NamespaceExportDeclaration */; + return node.kind === 262 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 261 /* ImportEqualsDeclaration */; + return node.kind === 263 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 262 /* ImportDeclaration */; + return node.kind === 264 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 263 /* ImportClause */; + return node.kind === 265 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 264 /* NamespaceImport */; + return node.kind === 266 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 270 /* NamespaceExport */; + return node.kind === 272 /* NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 265 /* NamedImports */; + return node.kind === 267 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 266 /* ImportSpecifier */; + return node.kind === 268 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 267 /* ExportAssignment */; + return node.kind === 269 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 268 /* ExportDeclaration */; + return node.kind === 270 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 269 /* NamedExports */; + return node.kind === 271 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 271 /* ExportSpecifier */; + return node.kind === 273 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 272 /* MissingDeclaration */; + return node.kind === 274 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 339 /* NotEmittedStatement */; + return node.kind === 344 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 344 /* SyntheticReferenceExpression */; + return node.kind === 349 /* SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 342 /* MergeDeclarationMarker */; + return node.kind === 347 /* MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 343 /* EndOfDeclarationMarker */; + return node.kind === 348 /* EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 273 /* ExternalModuleReference */; + return node.kind === 275 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 274 /* JsxElement */; + return node.kind === 276 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 275 /* JsxSelfClosingElement */; + return node.kind === 277 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 276 /* JsxOpeningElement */; + return node.kind === 278 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 277 /* JsxClosingElement */; + return node.kind === 279 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 278 /* JsxFragment */; + return node.kind === 280 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 279 /* JsxOpeningFragment */; + return node.kind === 281 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 280 /* JsxClosingFragment */; + return node.kind === 282 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 281 /* JsxAttribute */; + return node.kind === 283 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 282 /* JsxAttributes */; + return node.kind === 284 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 283 /* JsxSpreadAttribute */; + return node.kind === 285 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 284 /* JsxExpression */; + return node.kind === 286 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 285 /* CaseClause */; + return node.kind === 287 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 286 /* DefaultClause */; + return node.kind === 288 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 287 /* HeritageClause */; + return node.kind === 289 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 288 /* CatchClause */; + return node.kind === 290 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 289 /* PropertyAssignment */; + return node.kind === 291 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 290 /* ShorthandPropertyAssignment */; + return node.kind === 292 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 291 /* SpreadAssignment */; + return node.kind === 293 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 292 /* EnumMember */; + return node.kind === 294 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 294 /* UnparsedPrepend */; + return node.kind === 296 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -27849,164 +28438,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 298 /* SourceFile */; + return node.kind === 300 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 299 /* Bundle */; + return node.kind === 301 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 300 /* UnparsedSource */; + return node.kind === 302 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 302 /* JSDocTypeExpression */; + return node.kind === 304 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 303 /* JSDocNameReference */; + return node.kind === 305 /* JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; + function isJSDocMemberName(node) { + return node.kind === 306 /* JSDocMemberName */; + } + ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 316 /* JSDocLink */; + return node.kind === 319 /* JSDocLink */; } ts.isJSDocLink = isJSDocLink; + function isJSDocLinkCode(node) { + return node.kind === 320 /* JSDocLinkCode */; + } + ts.isJSDocLinkCode = isJSDocLinkCode; + function isJSDocLinkPlain(node) { + return node.kind === 321 /* JSDocLinkPlain */; + } + ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 304 /* JSDocAllType */; + return node.kind === 307 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 305 /* JSDocUnknownType */; + return node.kind === 308 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 306 /* JSDocNullableType */; + return node.kind === 309 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 307 /* JSDocNonNullableType */; + return node.kind === 310 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 308 /* JSDocOptionalType */; + return node.kind === 311 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 309 /* JSDocFunctionType */; + return node.kind === 312 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 310 /* JSDocVariadicType */; + return node.kind === 313 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 311 /* JSDocNamepathType */; + return node.kind === 314 /* JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 312 /* JSDocComment */; + return node.kind === 315 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 314 /* JSDocTypeLiteral */; + return node.kind === 317 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 315 /* JSDocSignature */; + return node.kind === 318 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 318 /* JSDocAugmentsTag */; + return node.kind === 323 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 320 /* JSDocAuthorTag */; + return node.kind === 325 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 322 /* JSDocClassTag */; + return node.kind === 327 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 328 /* JSDocCallbackTag */; + return node.kind === 333 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 323 /* JSDocPublicTag */; + return node.kind === 328 /* JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 324 /* JSDocPrivateTag */; + return node.kind === 329 /* JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 325 /* JSDocProtectedTag */; + return node.kind === 330 /* JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 326 /* JSDocReadonlyTag */; + return node.kind === 331 /* JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 327 /* JSDocOverrideTag */; + return node.kind === 332 /* JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 321 /* JSDocDeprecatedTag */; + return node.kind === 326 /* JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 336 /* JSDocSeeTag */; + return node.kind === 341 /* JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 329 /* JSDocEnumTag */; + return node.kind === 334 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 330 /* JSDocParameterTag */; + return node.kind === 335 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 331 /* JSDocReturnTag */; + return node.kind === 336 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 332 /* JSDocThisTag */; + return node.kind === 337 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 333 /* JSDocTypeTag */; + return node.kind === 338 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 334 /* JSDocTemplateTag */; + return node.kind === 339 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 335 /* JSDocTypedefTag */; + return node.kind === 340 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 317 /* JSDocTag */; + return node.kind === 322 /* JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 337 /* JSDocPropertyTag */; + return node.kind === 342 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 319 /* JSDocImplementsTag */; + return node.kind === 324 /* JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 338 /* SyntaxList */; + return n.kind === 343 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -28125,7 +28726,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(factory, dest, source) { if (ts.isBlock(dest)) { - return factory.updateBlock(dest, ts.setTextRange(factory.createNodeArray(__spreadArray([source], dest.statements)), dest.statements)); + return factory.updateBlock(dest, ts.setTextRange(factory.createNodeArray(__spreadArray([source], dest.statements, true)), dest.statements)); } else { return factory.createBlock(factory.createNodeArray([dest, source]), /*multiLine*/ true); @@ -28205,18 +28806,73 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; + /** + * Expand the read and increment/decrement operations a pre- or post-increment or pre- or post-decrement expression. + * + * ```ts + * // input + * ++ + * // output (if result is not discarded) + * var ; + * ( = , = ++, ) + * // output (if result is discarded) + * var ; + * ( = , ++, ) + * + * // input + * ++ + * // output (if result is not discarded) + * var ; + * ( = , = ++) + * // output (if result is discarded) + * var ; + * ( = , ++) + * ``` + * + * It is up to the caller to supply a temporary variable for `` if one is needed. + * The temporary variable `` is injected so that `++` and `--` work uniformly with `number` and `bigint`. + * The result of the expression is always the final result of incrementing or decrementing the expression, so that it can be used for storage. + * + * @param factory {@link NodeFactory} used to create the expanded representation. + * @param node The original prefix or postfix unary node. + * @param expression The expression to use as the value to increment or decrement + * @param resultVariable A temporary variable in which to store the result. Pass `undefined` if the result is discarded, or if the value of `` is the expected result. + */ + function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) { + var operator = node.operator; + ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); + var temp = factory.createTempVariable(recordTempVariable); + expression = factory.createAssignment(temp, expression); + ts.setTextRange(expression, node.operand); + var operation = ts.isPrefixUnaryExpression(node) ? + factory.createPrefixUnaryExpression(operator, temp) : + factory.createPostfixUnaryExpression(temp, operator); + ts.setTextRange(operation, node); + if (resultVariable) { + operation = factory.createAssignment(resultVariable, operation); + ts.setTextRange(operation, node); + } + expression = factory.createComma(expression, operation); + ts.setTextRange(expression, node); + if (ts.isPostfixUnaryExpression(node)) { + expression = factory.createComma(expression, temp); + ts.setTextRange(expression, node); + } + return expression; + } + ts.expandPreOrPostfixIncrementOrDecrementExpression = expandPreOrPostfixIncrementOrDecrementExpression; /** * Gets whether an identifier should only be referred to by its internal name. */ @@ -28265,21 +28921,21 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 217 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 341 /* CommaListExpression */; + return node.kind === 219 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 346 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 15 /* All */; } switch (node.kind) { - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 207 /* TypeAssertionExpression */: - case 225 /* AsExpression */: + case 209 /* TypeAssertionExpression */: + case 227 /* AsExpression */: return (kinds & 2 /* TypeAssertions */) !== 0; - case 226 /* NonNullExpression */: + case 228 /* NonNullExpression */: return (kinds & 4 /* NonNullAssertions */) !== 0; - case 340 /* PartiallyEmittedExpression */: + case 345 /* PartiallyEmittedExpression */: return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -28400,10 +29056,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 262 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 264 /* ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 268 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 270 /* ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -28522,7 +29178,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -28534,11 +29190,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 291 /* SpreadAssignment */: + case 293 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -28570,12 +29226,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 161 /* Parameter */: - case 199 /* BindingElement */: + case 162 /* Parameter */: + case 201 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 221 /* SpreadElement */: - case 291 /* SpreadAssignment */: + case 223 /* SpreadElement */: + case 293 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -28593,7 +29249,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 199 /* BindingElement */: + case 201 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -28608,7 +29264,7 @@ var ts; : propertyName; } break; - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -28623,7 +29279,7 @@ var ts; : propertyName; } break; - case 291 /* SpreadAssignment */: + case 293 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -28646,13 +29302,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 197 /* ObjectBindingPattern */: - case 198 /* ArrayBindingPattern */: - case 200 /* ArrayLiteralExpression */: + case 199 /* ObjectBindingPattern */: + case 200 /* ArrayBindingPattern */: + case 202 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -28673,29 +29329,29 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 161 /* Parameter */ - || kind === 163 /* PropertySignature */ - || kind === 164 /* PropertyDeclaration */ - || kind === 165 /* MethodSignature */ - || kind === 166 /* MethodDeclaration */ - || kind === 167 /* Constructor */ - || kind === 168 /* GetAccessor */ - || kind === 169 /* SetAccessor */ - || kind === 172 /* IndexSignature */ - || kind === 209 /* FunctionExpression */ - || kind === 210 /* ArrowFunction */ - || kind === 222 /* ClassExpression */ - || kind === 233 /* VariableStatement */ - || kind === 252 /* FunctionDeclaration */ - || kind === 253 /* ClassDeclaration */ - || kind === 254 /* InterfaceDeclaration */ - || kind === 255 /* TypeAliasDeclaration */ - || kind === 256 /* EnumDeclaration */ - || kind === 257 /* ModuleDeclaration */ - || kind === 261 /* ImportEqualsDeclaration */ - || kind === 262 /* ImportDeclaration */ - || kind === 267 /* ExportAssignment */ - || kind === 268 /* ExportDeclaration */; + return kind === 162 /* Parameter */ + || kind === 164 /* PropertySignature */ + || kind === 165 /* PropertyDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* Constructor */ + || kind === 170 /* GetAccessor */ + || kind === 171 /* SetAccessor */ + || kind === 174 /* IndexSignature */ + || kind === 211 /* FunctionExpression */ + || kind === 212 /* ArrowFunction */ + || kind === 224 /* ClassExpression */ + || kind === 235 /* VariableStatement */ + || kind === 254 /* FunctionDeclaration */ + || kind === 255 /* ClassDeclaration */ + || kind === 256 /* InterfaceDeclaration */ + || kind === 257 /* TypeAliasDeclaration */ + || kind === 258 /* EnumDeclaration */ + || kind === 259 /* ModuleDeclaration */ + || kind === 263 /* ImportEqualsDeclaration */ + || kind === 264 /* ImportDeclaration */ + || kind === 269 /* ExportAssignment */ + || kind === 270 /* ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -28706,9 +29362,9 @@ var ts; ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); function isLiteralTypeLikeExpression(node) { var kind = node.kind; - return kind === 103 /* NullKeyword */ - || kind === 109 /* TrueKeyword */ - || kind === 94 /* FalseKeyword */ + return kind === 104 /* NullKeyword */ + || kind === 110 /* TrueKeyword */ + || kind === 95 /* FalseKeyword */ || ts.isLiteralExpression(node) || ts.isPrefixUnaryExpression(node); } @@ -28747,8 +29403,8 @@ var ts; || kind === 32 /* LessThanEqualsToken */ || kind === 31 /* GreaterThanToken */ || kind === 33 /* GreaterThanEqualsToken */ - || kind === 101 /* InstanceOfKeyword */ - || kind === 100 /* InKeyword */; + || kind === 102 /* InstanceOfKeyword */ + || kind === 101 /* InKeyword */; } function isRelationalOperatorOrHigher(kind) { return isRelationalOperator(kind) @@ -29042,19 +29698,19 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 157 /* LastToken */) { + if (!node || node.kind <= 158 /* LastToken */) { return; } switch (node.kind) { - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 160 /* TypeParameter */: + case 161 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -29062,9 +29718,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 291 /* SpreadAssignment */: + case 293 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 161 /* Parameter */: + case 162 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -29072,7 +29728,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -29080,51 +29736,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 163 /* PropertySignature */: + case 164 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 199 /* BindingElement */: + case 201 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 175 /* FunctionType */: - case 176 /* ConstructorType */: - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 172 /* IndexSignature */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 174 /* IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 209 /* FunctionExpression */: - case 252 /* FunctionDeclaration */: - case 210 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 211 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: + case 212 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -29136,390 +29792,399 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 174 /* TypeReference */: + case 168 /* ClassStaticBlockDeclaration */: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.body); + case 176 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 173 /* TypePredicate */: + case 175 /* TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 177 /* TypeQuery */: + case 179 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 178 /* TypeLiteral */: + case 180 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 179 /* ArrayType */: + case 181 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 180 /* TupleType */: + case 182 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* UnionType */: - case 184 /* IntersectionType */: + case 185 /* UnionType */: + case 186 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 185 /* ConditionalType */: + case 187 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 186 /* InferType */: + case 188 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 196 /* ImportType */: + case 198 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 187 /* ParenthesizedType */: - case 189 /* TypeOperator */: + case 189 /* ParenthesizedType */: + case 191 /* TypeOperator */: return visitNode(cbNode, node.type); - case 190 /* IndexedAccessType */: + case 192 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 191 /* MappedType */: + case 193 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 192 /* LiteralType */: + case 194 /* LiteralType */: return visitNode(cbNode, node.literal); - case 193 /* NamedTupleMember */: + case 195 /* NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 197 /* ObjectBindingPattern */: - case 198 /* ArrayBindingPattern */: + case 199 /* ObjectBindingPattern */: + case 200 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 204 /* CallExpression */: - case 205 /* NewExpression */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 207 /* TypeAssertionExpression */: + case 209 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 211 /* DeleteExpression */: + case 213 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 212 /* TypeOfExpression */: + case 214 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 213 /* VoidExpression */: + case 215 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 220 /* YieldExpression */: + case 222 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 214 /* AwaitExpression */: + case 216 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 216 /* PostfixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 225 /* AsExpression */: + case 227 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 226 /* NonNullExpression */: + case 228 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 227 /* MetaProperty */: + case 229 /* MetaProperty */: return visitNode(cbNode, node.name); - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 221 /* SpreadElement */: + case 223 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 231 /* Block */: - case 258 /* ModuleBlock */: + case 233 /* Block */: + case 260 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 298 /* SourceFile */: + case 300 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 251 /* VariableDeclarationList */: + case 253 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 235 /* IfStatement */: + case 237 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 236 /* DoStatement */: + case 238 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 237 /* WhileStatement */: + case 239 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 238 /* ForStatement */: + case 240 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 240 /* ForOfStatement */: + case 242 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 241 /* ContinueStatement */: - case 242 /* BreakStatement */: + case 243 /* ContinueStatement */: + case 244 /* BreakStatement */: return visitNode(cbNode, node.label); - case 243 /* ReturnStatement */: + case 245 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 244 /* WithStatement */: + case 246 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 259 /* CaseBlock */: + case 261 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 285 /* CaseClause */: + case 287 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 286 /* DefaultClause */: + case 288 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 247 /* ThrowStatement */: + case 249 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 248 /* TryStatement */: + case 250 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 288 /* CatchClause */: + case 290 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 162 /* Decorator */: + case 163 /* Decorator */: return visitNode(cbNode, node.expression); - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 254 /* InterfaceDeclaration */: + case 256 /* InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 255 /* TypeAliasDeclaration */: + case 257 /* TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 292 /* EnumMember */: + case 294 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 263 /* ImportClause */: + case 265 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 260 /* NamespaceExportDeclaration */: + case 262 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 270 /* NamespaceExport */: + case 272 /* NamespaceExport */: return visitNode(cbNode, node.name); - case 265 /* NamedImports */: - case 269 /* NamedExports */: + case 267 /* NamedImports */: + case 271 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 266 /* ImportSpecifier */: - case 271 /* ExportSpecifier */: + case 268 /* ImportSpecifier */: + case 273 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 219 /* TemplateExpression */: + case 221 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 229 /* TemplateSpan */: + case 231 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 194 /* TemplateLiteralType */: + case 196 /* TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 195 /* TemplateLiteralTypeSpan */: + case 197 /* TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 287 /* HeritageClause */: + case 289 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 273 /* ExternalModuleReference */: + case 275 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 272 /* MissingDeclaration */: + case 274 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 341 /* CommaListExpression */: + case 346 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 274 /* JsxElement */: + case 276 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 278 /* JsxFragment */: + case 280 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 275 /* JsxSelfClosingElement */: - case 276 /* JsxOpeningElement */: + case 277 /* JsxSelfClosingElement */: + case 278 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 282 /* JsxAttributes */: + case 284 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 281 /* JsxAttribute */: + case 283 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 283 /* JsxSpreadAttribute */: + case 285 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 284 /* JsxExpression */: + case 286 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 277 /* JsxClosingElement */: + case 279 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 181 /* OptionalType */: - case 182 /* RestType */: - case 302 /* JSDocTypeExpression */: - case 307 /* JSDocNonNullableType */: - case 306 /* JSDocNullableType */: - case 308 /* JSDocOptionalType */: - case 310 /* JSDocVariadicType */: + case 183 /* OptionalType */: + case 184 /* RestType */: + case 304 /* JSDocTypeExpression */: + case 310 /* JSDocNonNullableType */: + case 309 /* JSDocNullableType */: + case 311 /* JSDocOptionalType */: + case 313 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 309 /* JSDocFunctionType */: + case 312 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 312 /* JSDocComment */: + case 315 /* JSDocComment */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 336 /* JSDocSeeTag */: + case 341 /* JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 303 /* JSDocNameReference */: + case 305 /* JSDocNameReference */: return visitNode(cbNode, node.name); - case 330 /* JSDocParameterTag */: - case 337 /* JSDocPropertyTag */: + case 306 /* JSDocMemberName */: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 335 /* JSDocParameterTag */: + case 342 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 320 /* JSDocAuthorTag */: + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); + case 325 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 319 /* JSDocImplementsTag */: + case 324 /* JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 318 /* JSDocAugmentsTag */: + case 323 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 334 /* JSDocTemplateTag */: + case 339 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 335 /* JSDocTypedefTag */: + case 340 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 302 /* JSDocTypeExpression */ + node.typeExpression.kind === 304 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 328 /* JSDocCallbackTag */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); + case 333 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 331 /* JSDocReturnTag */: - case 333 /* JSDocTypeTag */: - case 332 /* JSDocThisTag */: - case 329 /* JSDocEnumTag */: + case 336 /* JSDocReturnTag */: + case 338 /* JSDocTypeTag */: + case 337 /* JSDocThisTag */: + case 334 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 315 /* JSDocSignature */: + case 318 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 316 /* JSDocLink */: + case 319 /* JSDocLink */: + case 320 /* JSDocLinkCode */: + case 321 /* JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 314 /* JSDocTypeLiteral */: + case 317 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 317 /* JSDocTag */: - case 322 /* JSDocClassTag */: - case 323 /* JSDocPublicTag */: - case 324 /* JSDocPrivateTag */: - case 325 /* JSDocProtectedTag */: - case 326 /* JSDocReadonlyTag */: - case 321 /* JSDocDeprecatedTag */: + case 322 /* JSDocTag */: + case 327 /* JSDocClassTag */: + case 328 /* JSDocPublicTag */: + case 329 /* JSDocPrivateTag */: + case 330 /* JSDocProtectedTag */: + case 331 /* JSDocReadonlyTag */: + case 326 /* JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 340 /* PartiallyEmittedExpression */: + case 345 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -29568,7 +30233,7 @@ var ts; continue; return res; } - if (current.kind >= 158 /* FirstNode */) { + if (current.kind >= 159 /* FirstNode */) { // add children in reverse order to the queue, so popping gives the first child for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { var child = _a[_i]; @@ -29839,9 +30504,9 @@ var ts; case 22 /* OpenBracketToken */: expression_1 = parseArrayLiteralExpression(); break; - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: expression_1 = parseTokenNode(); break; case 40 /* MinusToken */: @@ -30293,6 +30958,9 @@ var ts; function reScanLessThanToken() { return currentToken = scanner.reScanLessThanToken(); } + function reScanHashToken() { + return currentToken = scanner.reScanHashToken(); + } function scanJsxIdentifier() { return currentToken = scanner.scanJsxIdentifier(); } @@ -30347,27 +31015,28 @@ var ts; return speculationHelper(callback, 0 /* TryParse */); } function isBindingIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* Identifier */) { return true; } - return token() > 115 /* LastReservedWord */; + // `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder. + return token() > 116 /* LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* 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() === 124 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* 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() === 130 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 131 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 115 /* LastReservedWord */; + return token() > 116 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -30386,6 +31055,128 @@ var ts; } return false; } + var viableKeywordSuggestions = Object.keys(ts.textToKeywordObj).filter(function (keyword) { return keyword.length > 2; }); + /** + * Provides a better error message than the generic "';' expected" if possible for + * known common variants of a missing semicolon, such as from a mispelled names. + * + * @param node Node preceding the expected semicolon location. + */ + function parseErrorForMissingSemicolonAfter(node) { + var _a; + // Tagged template literals are sometimes used in places where only simple strings are allowed, i.e.: + // module `M1` { + // ^^^^^^^^^^^ This block is parsed as a template literal like module`M1`. + if (ts.isTaggedTemplateExpression(node)) { + parseErrorAt(ts.skipTrivia(sourceText, node.template.pos), node.template.end, ts.Diagnostics.Module_declaration_names_may_only_use_or_quoted_strings); + return; + } + // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. + var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined; + if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + return; + } + var pos = ts.skipTrivia(sourceText, node.pos); + // Some known keywords are likely signs of syntax being used improperly. + switch (expressionText) { + case "const": + case "let": + case "var": + parseErrorAt(pos, node.end, ts.Diagnostics.Variable_declaration_not_allowed_at_this_location); + return; + case "declare": + // If a declared node failed to parse, it would have emitted a diagnostic already. + return; + case "interface": + parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */); + return; + case "is": + parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); + return; + case "module": + case "namespace": + parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */); + return; + case "type": + parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */); + return; + } + // The user alternatively might have misspelled or forgotten to add a space after a common keyword. + var suggestion = (_a = ts.getSpellingSuggestion(expressionText, viableKeywordSuggestions, function (n) { return n; })) !== null && _a !== void 0 ? _a : getSpaceSuggestion(expressionText); + if (suggestion) { + parseErrorAt(pos, node.end, ts.Diagnostics.Unknown_keyword_or_identifier_Did_you_mean_0, suggestion); + return; + } + // Unknown tokens are handled with their own errors in the scanner + if (token() === 0 /* Unknown */) { + return; + } + // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. + parseErrorAt(pos, node.end, ts.Diagnostics.Unexpected_keyword_or_identifier); + } + /** + * Reports a diagnostic error for the current token being an invalid name. + * + * @param blankDiagnostic Diagnostic to report for the case of the name being blank (matched tokenIfBlankName). + * @param nameDiagnostic Diagnostic to report for all other cases. + * @param tokenIfBlankName Current token if the name was invalid for being blank (not provided / skipped). + */ + function parseErrorForInvalidName(nameDiagnostic, blankDiagnostic, tokenIfBlankName) { + if (token() === tokenIfBlankName) { + parseErrorAtCurrentToken(blankDiagnostic); + } + else { + parseErrorAtCurrentToken(nameDiagnostic, ts.tokenToString(token())); + } + } + function getSpaceSuggestion(expressionText) { + for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { + var keyword = viableKeywordSuggestions_1[_i]; + if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { + return keyword + " " + expressionText.slice(keyword.length); + } + } + return undefined; + } + function parseSemicolonAfterPropertyName(name, type, initializer) { + if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) { + parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); + return; + } + if (token() === 20 /* OpenParenToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); + nextToken(); + return; + } + if (type && !canParseSemicolon()) { + if (initializer) { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + } + else { + parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer); + } + return; + } + if (tryParseSemicolon()) { + return; + } + // If an initializer was parsed but there is still an error in finding the next semicolon, + // we generally know there was an error already reported in the initializer... + // class Example { a = new Map([), ) } + // ~ + if (initializer) { + // ...unless we've found the start of a block after a property declaration, in which + // case we can know that regardless of the initializer we should complain on the block. + // class Example { a = 0 {} } + // ~ + if (token() === 18 /* OpenBraceToken */) { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + } + return; + } + parseErrorForMissingSemicolonAfter(name); + } function parseExpectedJSDoc(kind) { if (token() === kind) { nextTokenJSDoc(); @@ -30441,17 +31232,18 @@ var ts; // We can parse out an optional semicolon in ASI cases in the following cases. return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } - function parseSemicolon() { - if (canParseSemicolon()) { - if (token() === 26 /* SemicolonToken */) { - // consume the semicolon if it was explicitly provided. - nextToken(); - } - return true; + function tryParseSemicolon() { + if (!canParseSemicolon()) { + return false; } - else { - return parseExpected(26 /* SemicolonToken */); + if (token() === 26 /* SemicolonToken */) { + // consume the semicolon if it was explicitly provided. + nextToken(); } + return true; + } + function parseSemicolon() { + return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */); } function createNodeArray(elements, pos, end, hasTrailingComma) { var array = factory.createNodeArray(elements, hasTrailingComma); @@ -30480,11 +31272,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 78 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 272 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 274 /* MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -30508,11 +31300,11 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(/*isIdentifier*/ true); } - if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 78 /* Identifier */; })) { + if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) { // Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser. return createIdentifier(/*isIdentifier*/ true); } @@ -30524,7 +31316,7 @@ var ts; var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(78 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -30549,7 +31341,7 @@ var ts; if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -30595,24 +31387,24 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 91 /* EnumKeyword */; - case 92 /* ExportKeyword */: + return nextToken() === 92 /* EnumKeyword */; + case 93 /* ExportKeyword */: nextToken(); - if (token() === 87 /* DefaultKeyword */) { + if (token() === 88 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 149 /* TypeKeyword */) { + if (token() === 150 /* TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 87 /* DefaultKeyword */: + case 88 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return nextTokenIsOnSameLineAndCanFollowModifier(); - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -30621,7 +31413,7 @@ var ts; } function canFollowExportModifier() { return token() !== 41 /* AsteriskToken */ - && token() !== 126 /* AsKeyword */ + && token() !== 127 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); } @@ -30641,10 +31433,10 @@ var ts; } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 83 /* ClassKeyword */ || token() === 97 /* FunctionKeyword */ || - token() === 117 /* InterfaceKeyword */ || - (token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 129 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || + token() === 118 /* InterfaceKeyword */ || + (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 130 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -30664,7 +31456,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -30750,7 +31542,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 93 /* ExtendsKeyword */ || next === 116 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; } return true; } @@ -30767,8 +31559,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 116 /* ImplementsKeyword */ || - token() === 93 /* ExtendsKeyword */) { + if (token() === 117 /* ImplementsKeyword */ || + token() === 94 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -30798,14 +31590,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -31021,20 +31813,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 167 /* Constructor */: - case 172 /* IndexSignature */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 164 /* PropertyDeclaration */: - case 230 /* SemicolonClassElement */: + case 169 /* Constructor */: + case 174 /* IndexSignature */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 232 /* SemicolonClassElement */: return true; - case 166 /* MethodDeclaration */: + case 167 /* 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 === 78 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 132 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 133 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -31043,8 +31835,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 285 /* CaseClause */: - case 286 /* DefaultClause */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: return true; } } @@ -31053,58 +31845,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 252 /* FunctionDeclaration */: - case 233 /* VariableStatement */: - case 231 /* Block */: - case 235 /* IfStatement */: - case 234 /* ExpressionStatement */: - case 247 /* ThrowStatement */: - case 243 /* ReturnStatement */: - case 245 /* SwitchStatement */: - case 242 /* BreakStatement */: - case 241 /* ContinueStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 238 /* ForStatement */: - case 237 /* WhileStatement */: - case 244 /* WithStatement */: - case 232 /* EmptyStatement */: - case 248 /* TryStatement */: - case 246 /* LabeledStatement */: - case 236 /* DoStatement */: - case 249 /* DebuggerStatement */: - case 262 /* ImportDeclaration */: - case 261 /* ImportEqualsDeclaration */: - case 268 /* ExportDeclaration */: - case 267 /* ExportAssignment */: - case 257 /* ModuleDeclaration */: - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 256 /* EnumDeclaration */: - case 255 /* TypeAliasDeclaration */: + case 254 /* FunctionDeclaration */: + case 235 /* VariableStatement */: + case 233 /* Block */: + case 237 /* IfStatement */: + case 236 /* ExpressionStatement */: + case 249 /* ThrowStatement */: + case 245 /* ReturnStatement */: + case 247 /* SwitchStatement */: + case 244 /* BreakStatement */: + case 243 /* ContinueStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 240 /* ForStatement */: + case 239 /* WhileStatement */: + case 246 /* WithStatement */: + case 234 /* EmptyStatement */: + case 250 /* TryStatement */: + case 248 /* LabeledStatement */: + case 238 /* DoStatement */: + case 251 /* DebuggerStatement */: + case 264 /* ImportDeclaration */: + case 263 /* ImportEqualsDeclaration */: + case 270 /* ExportDeclaration */: + case 269 /* ExportAssignment */: + case 259 /* ModuleDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 258 /* EnumDeclaration */: + case 257 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 292 /* EnumMember */; + return node.kind === 294 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 171 /* ConstructSignature */: - case 165 /* MethodSignature */: - case 172 /* IndexSignature */: - case 163 /* PropertySignature */: - case 170 /* CallSignature */: + case 173 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 174 /* IndexSignature */: + case 164 /* PropertySignature */: + case 172 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 250 /* VariableDeclaration */) { + if (node.kind !== 252 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -31125,7 +31917,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 161 /* Parameter */) { + if (node.kind !== 162 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -31143,7 +31935,10 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 0 /* SourceElements */: + return token() === 88 /* DefaultKeyword */ + ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */)) + : parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); @@ -31292,12 +32087,12 @@ var ts; // 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(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -31406,14 +32201,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 174 /* TypeReference */: + case 176 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 175 /* FunctionType */: - case 176 /* ConstructorType */: { + case 177 /* FunctionType */: + case 178 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 187 /* ParenthesizedType */: + case 189 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -31455,7 +32250,7 @@ var ts; token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || token() === 31 /* GreaterThanToken */ || - token() === 62 /* EqualsToken */ || + token() === 63 /* EqualsToken */ || token() === 51 /* BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } @@ -31477,7 +32272,7 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 107 /* ThisKeyword */ || token() === 102 /* NewKeyword */) { + if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { name = parseIdentifierName(); parseExpected(58 /* ColonToken */); } @@ -31493,7 +32288,7 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(139 /* ModuleKeyword */)) { + if (parseOptional(140 /* ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { @@ -31516,7 +32311,7 @@ var ts; if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 62 /* EqualsToken */) { + if (token() === 63 /* EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -31524,7 +32319,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(111 /* TypeOfKeyword */); + parseExpected(112 /* TypeOfKeyword */); return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true)), pos); } function parseTypeParameter() { @@ -31532,7 +32327,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(93 /* ExtendsKeyword */)) { + if (parseOptional(94 /* 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 @@ -31551,7 +32346,7 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(62 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); @@ -31598,7 +32393,7 @@ var ts; // BindingElement[?Yield,?Await] // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); - if (token() === 107 /* ThisKeyword */) { + if (token() === 108 /* ThisKeyword */) { var node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), @@ -31695,14 +32490,14 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 171 /* ConstructSignature */) { - parseExpected(102 /* NewKeyword */); + if (kind === 173 /* ConstructSignature */) { + parseExpected(103 /* NewKeyword */); } var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 170 /* CallSignature */ + var node = kind === 172 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -31785,7 +32580,7 @@ var ts; // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === 62 /* EqualsToken */) + if (token() === 63 /* EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -31795,8 +32590,8 @@ var ts; // Return true if we have the start of a signature member if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || - token() === 134 /* GetKeyword */ || - token() === 146 /* SetKeyword */) { + token() === 135 /* GetKeyword */ || + token() === 147 /* SetKeyword */) { return true; } var idToken = false; @@ -31828,19 +32623,19 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(170 /* CallSignature */); + return parseSignatureMember(172 /* CallSignature */); } - if (token() === 102 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(171 /* ConstructSignature */); + if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(173 /* ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 168 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 170 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 169 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 171 /* SetAccessor */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -31881,17 +32676,17 @@ var ts; function isStartOfMappedType() { nextToken(); if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 142 /* ReadonlyKeyword */; + return nextToken() === 143 /* ReadonlyKeyword */; } - if (token() === 142 /* ReadonlyKeyword */) { + if (token() === 143 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 100 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(100 /* InKeyword */); + parseExpected(101 /* InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(name, type, /*defaultType*/ undefined), pos); } @@ -31899,15 +32694,15 @@ var ts; var pos = getNodePos(); parseExpected(18 /* OpenBraceToken */); var readonlyToken; - if (token() === 142 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 143 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 142 /* ReadonlyKeyword */) { - parseExpected(142 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 143 /* ReadonlyKeyword */) { + parseExpected(143 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(126 /* AsKeyword */) ? parseType() : undefined; + var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; parseExpected(23 /* CloseBracketToken */); var questionToken; if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { @@ -31971,10 +32766,10 @@ var ts; } function parseModifiersForConstructorType() { var modifiers; - if (token() === 125 /* AbstractKeyword */) { + if (token() === 126 /* AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(125 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -31983,7 +32778,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(102 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* NewKeyword */); var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); @@ -32003,7 +32798,7 @@ var ts; if (negative) { nextToken(); } - var expression = token() === 109 /* TrueKeyword */ || token() === 94 /* FalseKeyword */ || token() === 103 /* NullKeyword */ ? + var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -32013,13 +32808,13 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 99 /* ImportKeyword */; + return token() === 100 /* ImportKeyword */; } function parseImportType() { sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(111 /* TypeOfKeyword */); - parseExpected(99 /* ImportKeyword */); + var isTypeOf = parseOptional(112 /* TypeOfKeyword */); + parseExpected(100 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); var type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -32033,19 +32828,19 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 148 /* SymbolKeyword */: - case 131 /* BooleanKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 149 /* SymbolKeyword */: + case 132 /* BooleanKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through @@ -32057,7 +32852,7 @@ var ts; // falls through case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseJSDocFunctionType(); case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); @@ -32065,24 +32860,24 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: return parseLiteralTypeNode(); case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseTokenNode(); - case 107 /* ThisKeyword */: { + case 108 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -32090,9 +32885,9 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportType(); - case 127 /* AssertsKeyword */: + case 128 /* AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); case 15 /* TemplateHead */: return parseTemplateType(); @@ -32102,44 +32897,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 142 /* ReadonlyKeyword */: - case 148 /* SymbolKeyword */: - case 151 /* UniqueKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 111 /* TypeOfKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 143 /* ReadonlyKeyword */: + case 149 /* SymbolKeyword */: + case 152 /* UniqueKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 112 /* TypeOfKeyword */: + case 142 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: case 29 /* LessThanToken */: case 51 /* BarToken */: case 50 /* AmpersandToken */: - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 145 /* ObjectKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 146 /* ObjectKeyword */: case 41 /* AsteriskToken */: case 57 /* QuestionToken */: case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 135 /* InferKeyword */: - case 99 /* ImportKeyword */: - case 127 /* AssertsKeyword */: + case 136 /* InferKeyword */: + case 100 /* ImportKeyword */: + case 128 /* AssertsKeyword */: case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: return true; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return !inStartOfParameter; case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); @@ -32203,17 +32998,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(135 /* InferKeyword */); + parseExpected(136 /* InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 138 /* KeyOfKeyword */: - case 151 /* UniqueKeyword */: - case 142 /* ReadonlyKeyword */: + case 139 /* KeyOfKeyword */: + case 152 /* UniqueKeyword */: + case 143 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 135 /* InferKeyword */: + case 136 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -32263,7 +33058,7 @@ var ts; } function nextTokenIsNewKeyword() { nextToken(); - return token() === 102 /* NewKeyword */; + return token() === 103 /* NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { if (token() === 29 /* LessThanToken */) { @@ -32272,15 +33067,15 @@ var ts; if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 102 /* NewKeyword */ || - token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* NewKeyword */ || + token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 107 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* ThisKeyword */) { nextToken(); return true; } @@ -32303,7 +33098,7 @@ var ts; // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 57 /* QuestionToken */ || token() === 62 /* EqualsToken */) { + token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -32333,16 +33128,16 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(127 /* AssertsKeyword */); - var parameterName = token() === 107 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(137 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); + var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(138 /* IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { @@ -32356,7 +33151,7 @@ var ts; } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(93 /* ExtendsKeyword */)) { + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = parseTypeWorker(/*noConditionalTypes*/ true); parseExpected(57 /* QuestionToken */); @@ -32373,11 +33168,11 @@ var ts; // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -32386,14 +33181,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 102 /* NewKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 103 /* NewKeyword */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: - case 78 /* Identifier */: + case 68 /* SlashEqualsToken */: + case 79 /* Identifier */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -32408,15 +33203,15 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: case 45 /* PlusPlusToken */: case 46 /* MinusMinusToken */: case 29 /* LessThanToken */: - case 130 /* AwaitKeyword */: - case 124 /* YieldKeyword */: - case 79 /* PrivateIdentifier */: + case 131 /* AwaitKeyword */: + case 125 /* YieldKeyword */: + case 80 /* PrivateIdentifier */: // 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. @@ -32435,8 +33230,8 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && token() !== 59 /* AtToken */ && isStartOfExpression(); } @@ -32461,7 +33256,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -32507,7 +33302,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 === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -32523,7 +33318,7 @@ var ts; return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 124 /* YieldKeyword */) { + if (token() === 125 /* YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -32603,7 +33398,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() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 129 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 130 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token() === 38 /* EqualsGreaterThanToken */) { @@ -32616,7 +33411,7 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; @@ -32660,13 +33455,13 @@ var ts; // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 129 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 130 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 107 /* ThisKeyword */) { + if (!isIdentifier() && second !== 108 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { @@ -32677,13 +33472,13 @@ var ts; case 57 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -32702,10 +33497,10 @@ var ts; if (languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 93 /* ExtendsKeyword */) { + if (third === 94 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 31 /* GreaterThanToken */: return false; default: @@ -32739,7 +33534,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); @@ -32753,7 +33548,7 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" @@ -32762,7 +33557,7 @@ var ts; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } @@ -32827,8 +33622,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -32866,7 +33661,7 @@ var ts; var colonToken; return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -32874,7 +33669,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 100 /* InKeyword */ || t === 157 /* OfKeyword */; + return t === 101 /* InKeyword */ || t === 158 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -32909,10 +33704,10 @@ var ts; if (!consumeCurrentOperator) { break; } - if (token() === 100 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -32933,7 +33728,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 100 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -32961,7 +33756,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 130 /* AwaitKeyword */) { + if (token() === 131 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -33014,7 +33809,7 @@ var ts; if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 207 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 209 /* TypeAssertionExpression */) { parseErrorAt(pos, end, 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 { @@ -33044,18 +33839,18 @@ var ts; case 54 /* TildeToken */: case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 88 /* DeleteKeyword */: + case 89 /* DeleteKeyword */: return parseDeleteExpression(); - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseVoidExpression(); case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 130 /* AwaitKeyword */: + case 131 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -33082,10 +33877,10 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: - case 130 /* AwaitKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: + case 131 /* AwaitKeyword */: return false; case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression @@ -33161,7 +33956,7 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 99 /* ImportKeyword */) { + if (token() === 100 /* ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: @@ -33175,7 +33970,7 @@ var ts; // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(99 /* ImportKeyword */, parseIdentifierName()), pos); + expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); sourceFlags |= 2097152 /* PossiblyContainsImportMeta */; } else { @@ -33183,7 +33978,7 @@ var ts; } } else { - expression = token() === 105 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression or OptionalExpression. As such, we need to consume the rest @@ -33261,23 +34056,45 @@ var ts; // private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } - function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition) { + function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) { var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 276 /* JsxOpeningElement */) { + if (opening.kind === 278 /* JsxOpeningElement */) { var children = parseJsxChildren(opening); - var closingElement = parseJsxClosingElement(inExpressionContext); - if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { - parseErrorAtRange(closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + var closingElement = void 0; + var lastChild = children[children.length - 1]; + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 276 /* JsxElement */ + && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) + && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { + // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, + // restructure (
(...
)) --> (
(...)
) + // (no need to error; the parent will error) + var end = lastChild.openingElement.end; // newly-created children and closing are both zero-width end/end + var newLast = finishNode(factory.createJsxElement(lastChild.openingElement, createNodeArray([], end, end), finishNode(factory.createJsxClosingElement(finishNode(factory.createIdentifier(""), end, end)), end, end)), lastChild.openingElement.pos, end); + children = createNodeArray(__spreadArray(__spreadArray([], children.slice(0, children.length - 1), true), [newLast], false), children.pos, end); + closingElement = lastChild.closingElement; + } + else { + closingElement = parseJsxClosingElement(opening, inExpressionContext); + if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { + if (openingTag && ts.isJsxOpeningElement(openingTag) && tagNamesAreEquivalent(closingElement.tagName, openingTag.tagName)) { + // opening incorrectly matched with its parent's closing -- put error on opening + parseErrorAtRange(opening.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + else { + // other opening/closing mismatches -- put error on closing + parseErrorAtRange(closingElement.tagName, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + } } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 279 /* JsxOpeningFragment */) { + else if (opening.kind === 281 /* JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 275 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 277 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -33331,7 +34148,7 @@ var ts; case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); case 29 /* LessThanToken */: - return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); + return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); } @@ -33346,6 +34163,13 @@ var ts; if (!child) break; list.push(child); + if (ts.isJsxOpeningElement(openingTag) + && (child === null || child === void 0 ? void 0 : child.kind) === 276 /* JsxElement */ + && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) + && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { + // stop after parsing a mismatched child like
...(
) in order to reattach the higher + break; + } } parsingContext = saveParsingContext; return createNodeArray(list, listPos); @@ -33375,12 +34199,14 @@ var ts; } else { parseExpected(43 /* SlashToken */); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } node = factory.createJsxSelfClosingElement(tagName, typeArguments, attributes); } @@ -33394,7 +34220,7 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 107 /* ThisKeyword */ ? + var expression = token() === 108 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); @@ -33431,7 +34257,7 @@ var ts; } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 62 /* EqualsToken */ ? undefined : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined : scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() : parseJsxExpression(/*inExpressionContext*/ true)), pos); } @@ -33443,16 +34269,18 @@ var ts; parseExpected(19 /* CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } - function parseJsxClosingElement(inExpressionContext) { + function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); parseExpected(30 /* LessThanSlashToken */); var tagName = parseJsxElementName(); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { + nextToken(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxClosingElement(tagName), pos); } @@ -33462,12 +34290,14 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxJsxClosingFragment(), pos); } @@ -33524,7 +34354,7 @@ var ts; function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -33619,7 +34449,7 @@ var ts; } if (questionDotToken) { // We failed to parse anything, so report a missing identifier here. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -33700,11 +34530,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -33712,7 +34542,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 129 /* AsyncKeyword */: + case 130 /* 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. @@ -33720,14 +34550,14 @@ var ts; break; } return parseFunctionExpression(); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassExpression(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionExpression(); - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -33776,11 +34606,11 @@ var ts; } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 171 /* SetAccessor */); } var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -33799,7 +34629,7 @@ var ts; var node; var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(62 /* EqualsToken */); + var equalsToken = parseOptionalToken(63 /* EqualsToken */); var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. @@ -33838,14 +34668,12 @@ var ts; // // FunctionExpression: // function BindingIdentifier[opt](FormalParameters){ FunctionBody } - var saveDecoratorContext = inDecoratorContext(); - if (saveDecoratorContext) { - setDecoratorContext(/*val*/ false); - } + var savedDecoratorContext = inDecoratorContext(); + setDecoratorContext(/*val*/ false); var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(97 /* FunctionKeyword */); + parseExpected(98 /* FunctionKeyword */); var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; @@ -33857,9 +34685,7 @@ var ts; var parameters = parseParameters(isGenerator | isAsync); var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); var body = parseFunctionBlock(isGenerator | isAsync); - if (saveDecoratorContext) { - setDecoratorContext(/*val*/ true); - } + setDecoratorContext(savedDecoratorContext); var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -33868,10 +34694,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(102 /* NewKeyword */); + parseExpected(103 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(102 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parsePrimaryExpression(); @@ -33910,7 +34736,7 @@ var ts; } } var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); - if (token() === 62 /* EqualsToken */) { + if (token() === 63 /* EqualsToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); nextToken(); } @@ -33952,20 +34778,20 @@ var ts; function parseIfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(98 /* IfKeyword */); + parseExpected(99 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var thenStatement = parseStatement(); - var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; + var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(89 /* DoKeyword */); + parseExpected(90 /* DoKeyword */); var statement = parseStatement(); - parseExpected(114 /* WhileKeyword */); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -33979,7 +34805,7 @@ var ts; function parseWhileStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(114 /* WhileKeyword */); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -33989,12 +34815,12 @@ var ts; function parseForOrForInOrForOfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(96 /* ForKeyword */); - var awaitToken = parseOptionalToken(130 /* AwaitKeyword */); + parseExpected(97 /* ForKeyword */); + var awaitToken = parseOptionalToken(131 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 112 /* VarKeyword */ || token() === 118 /* LetKeyword */ || token() === 84 /* ConstKeyword */) { + if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -34002,12 +34828,12 @@ var ts; } } var node; - if (awaitToken ? parseExpected(157 /* OfKeyword */) : parseOptional(157 /* OfKeyword */)) { + if (awaitToken ? parseExpected(158 /* OfKeyword */) : parseOptional(158 /* OfKeyword */)) { var expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(100 /* InKeyword */)) { + else if (parseOptional(101 /* InKeyword */)) { var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); @@ -34029,10 +34855,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 242 /* BreakStatement */ ? 80 /* BreakKeyword */ : 85 /* ContinueKeyword */); + parseExpected(kind === 244 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 242 /* BreakStatement */ + var node = kind === 244 /* BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -34040,7 +34866,7 @@ var ts; function parseReturnStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(104 /* ReturnKeyword */); + parseExpected(105 /* ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); @@ -34048,7 +34874,7 @@ var ts; function parseWithStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(115 /* WithKeyword */); + parseExpected(116 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -34057,7 +34883,7 @@ var ts; } function parseCaseClause() { var pos = getNodePos(); - parseExpected(81 /* CaseKeyword */); + parseExpected(82 /* CaseKeyword */); var expression = allowInAnd(parseExpression); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -34065,13 +34891,13 @@ var ts; } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 81 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); @@ -34083,7 +34909,7 @@ var ts; function parseSwitchStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(106 /* SwitchKeyword */); + parseExpected(107 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -34095,7 +34921,7 @@ var ts; // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(108 /* ThrowKeyword */); + parseExpected(109 /* ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' // directly as that might consume an expression on the following line. @@ -34106,28 +34932,30 @@ var ts; identifierCount++; expression = finishNode(factory.createIdentifier(""), getNodePos()); } - parseSemicolon(); + if (!tryParseSemicolon()) { + parseErrorForMissingSemicolonAfter(expression); + } return withJSDoc(finishNode(factory.createThrowStatement(expression), pos), hasJSDoc); } // TODO: Review for error recovery function parseTryStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(110 /* TryKeyword */); + parseExpected(111 /* TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 82 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* 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. var finallyBlock; - if (!catchClause || token() === 95 /* FinallyKeyword */) { - parseExpected(95 /* FinallyKeyword */); + if (!catchClause || token() === 96 /* FinallyKeyword */) { + parseExpected(96 /* FinallyKeyword */); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(82 /* CatchKeyword */); + parseExpected(83 /* CatchKeyword */); var variableDeclaration; if (parseOptional(20 /* OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); @@ -34143,7 +34971,7 @@ var ts; function parseDebuggerStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(86 /* DebuggerKeyword */); + parseExpected(87 /* DebuggerKeyword */); parseSemicolon(); return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } @@ -34160,7 +34988,9 @@ var ts; node = factory.createLabeledStatement(expression, parseStatement()); } else { - parseSemicolon(); + if (!tryParseSemicolon()) { + parseErrorForMissingSemicolonAfter(expression); + } node = factory.createExpressionStatement(expression); if (hasParen) { // do not parse the same jsdoc twice @@ -34175,11 +35005,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 83 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 97 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -34188,12 +35018,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 92 /* 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 @@ -34216,44 +35046,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 142 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 143 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 154 /* GlobalKeyword */: + case 155 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 78 /* Identifier */ || token() === 92 /* ExportKeyword */; - case 99 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; + case 100 /* ImportKeyword */: nextToken(); return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 149 /* TypeKeyword */) { + if (currentToken_1 === 150 /* TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 62 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 87 /* DefaultKeyword */ || - currentToken_1 === 126 /* AsKeyword */) { + if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || + currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || + currentToken_1 === 127 /* AsKeyword */) { return true; } continue; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: nextToken(); continue; default: @@ -34269,48 +35099,48 @@ var ts; case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: - case 98 /* IfKeyword */: - case 89 /* DoKeyword */: - case 114 /* WhileKeyword */: - case 96 /* ForKeyword */: - case 85 /* ContinueKeyword */: - case 80 /* BreakKeyword */: - case 104 /* ReturnKeyword */: - case 115 /* WithKeyword */: - case 106 /* SwitchKeyword */: - case 108 /* ThrowKeyword */: - case 110 /* TryKeyword */: - case 86 /* DebuggerKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 92 /* EnumKeyword */: + case 99 /* IfKeyword */: + case 90 /* DoKeyword */: + case 115 /* WhileKeyword */: + case 97 /* ForKeyword */: + case 86 /* ContinueKeyword */: + case 81 /* BreakKeyword */: + case 105 /* ReturnKeyword */: + case 116 /* WithKeyword */: + case 107 /* SwitchKeyword */: + case 109 /* ThrowKeyword */: + case 111 /* TryKeyword */: + case 87 /* 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. // falls through - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 84 /* ConstKeyword */: - case 92 /* ExportKeyword */: + case 85 /* ConstKeyword */: + case 93 /* ExportKeyword */: return isStartOfDeclaration(); - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 117 /* InterfaceKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 149 /* TypeKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 118 /* InterfaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 150 /* TypeKeyword */: + case 155 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 124 /* StaticKeyword */: + case 143 /* ReadonlyKeyword */: // 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); @@ -34318,14 +35148,14 @@ var ts; return isStartOfExpression(); } } - function nextTokenIsIdentifierOrStartOfDestructuring() { + function nextTokenIsBindingIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; + return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { // or [. - return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); + return lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token()) { @@ -34333,64 +35163,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 98 /* IfKeyword */: + case 99 /* IfKeyword */: return parseIfStatement(); - case 89 /* DoKeyword */: + case 90 /* DoKeyword */: return parseDoStatement(); - case 114 /* WhileKeyword */: + case 115 /* WhileKeyword */: return parseWhileStatement(); - case 96 /* ForKeyword */: + case 97 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 85 /* ContinueKeyword */: - return parseBreakOrContinueStatement(241 /* ContinueStatement */); - case 80 /* BreakKeyword */: - return parseBreakOrContinueStatement(242 /* BreakStatement */); - case 104 /* ReturnKeyword */: + case 86 /* ContinueKeyword */: + return parseBreakOrContinueStatement(243 /* ContinueStatement */); + case 81 /* BreakKeyword */: + return parseBreakOrContinueStatement(244 /* BreakStatement */); + case 105 /* ReturnKeyword */: return parseReturnStatement(); - case 115 /* WithKeyword */: + case 116 /* WithKeyword */: return parseWithStatement(); - case 106 /* SwitchKeyword */: + case 107 /* SwitchKeyword */: return parseSwitchStatement(); - case 108 /* ThrowKeyword */: + case 109 /* ThrowKeyword */: return parseThrowStatement(); - case 110 /* TryKeyword */: + case 111 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return parseTryStatement(); - case 86 /* DebuggerKeyword */: + case 87 /* DebuggerKeyword */: return parseDebuggerStatement(); case 59 /* AtToken */: return parseDeclaration(); - case 129 /* AsyncKeyword */: - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 91 /* EnumKeyword */: - case 92 /* ExportKeyword */: - case 99 /* ImportKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 125 /* AbstractKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 134 /* DeclareKeyword */: + case 85 /* ConstKeyword */: + case 92 /* EnumKeyword */: + case 93 /* ExportKeyword */: + case 100 /* ImportKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 126 /* AbstractKeyword */: + case 124 /* StaticKeyword */: + case 143 /* ReadonlyKeyword */: + case 155 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -34399,7 +35229,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 133 /* DeclareKeyword */; + return modifier.kind === 134 /* DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -34440,33 +35270,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 117 /* InterfaceKeyword */: + case 118 /* InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 149 /* TypeKeyword */: + case 150 /* TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 91 /* EnumKeyword */: + case 92 /* EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 154 /* GlobalKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 155 /* GlobalKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: nextToken(); switch (token()) { - case 87 /* DefaultKeyword */: - case 62 /* EqualsToken */: + case 88 /* DefaultKeyword */: + case 63 /* EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 126 /* AsKeyword */: + case 127 /* AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -34475,7 +35305,7 @@ var ts; 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 missing = createMissingNode(272 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(274 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -34540,7 +35370,7 @@ var ts; function isBindingIdentifierOrPrivateIdentifierOrPattern() { return token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */ - || token() === 79 /* PrivateIdentifier */ + || token() === 80 /* PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { @@ -34560,7 +35390,7 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 78 /* Identifier */ && + if (allowExclamation && name.kind === 79 /* Identifier */ && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } @@ -34573,12 +35403,12 @@ var ts; var pos = getNodePos(); var flags = 0; switch (token()) { - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: break; - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: flags |= 1 /* Let */; break; - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: flags |= 2 /* Const */; break; default: @@ -34595,7 +35425,7 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 157 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 158 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { @@ -34620,7 +35450,7 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(97 /* FunctionKeyword */); + parseExpected(98 /* FunctionKeyword */); var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); @@ -34637,8 +35467,8 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 132 /* ConstructorKeyword */) { - return parseExpected(132 /* ConstructorKeyword */); + if (token() === 133 /* ConstructorKeyword */) { + return parseExpected(133 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -34678,7 +35508,7 @@ var ts; var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined; var type = parseTypeAnnotation(); var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer); - parseSemicolon(); + parseSemicolonAfterPropertyName(name, type, initializer); var node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -34699,12 +35529,12 @@ var ts; var parameters = parseParameters(0 /* None */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 168 /* GetAccessor */ + var node = kind === 170 /* GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 169 /* SetAccessor */) + if (type && node.kind === 171 /* SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -34743,7 +35573,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 === 146 /* SetKeyword */ || idToken === 134 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 147 /* SetKeyword */ || idToken === 135 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -34753,7 +35583,7 @@ var ts; case 29 /* LessThanToken */: // Generic Method declaration case 53 /* ExclamationToken */: // Non-null assertion on property name case 58 /* ColonToken */: // Type Annotation for declaration - case 62 /* EqualsToken */: // Initializer for declaration + case 63 /* EqualsToken */: // Initializer for declaration case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: @@ -34767,8 +35597,23 @@ var ts; } return false; } + function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { + parseExpectedToken(124 /* StaticKeyword */); + var body = parseClassStaticBlockBody(); + return withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(decorators, modifiers, body), pos), hasJSDoc); + } + function parseClassStaticBlockBody() { + var savedYieldContext = inYieldContext(); + var savedAwaitContext = inAwaitContext(); + setYieldContext(false); + setAwaitContext(true); + var body = parseBlock(/*ignoreMissingOpenBrace*/ false); + setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); + return body; + } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 130 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 131 /* AwaitKeyword */) { // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails // This simply parses the missing identifier and moves on. var pos = getNodePos(); @@ -34795,16 +35640,19 @@ var ts; } return list && createNodeArray(list, pos); } - function tryParseModifier(permitInvalidConstAsModifier) { + function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) { var pos = getNodePos(); var kind = token(); - if (token() === 84 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } } + else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + return undefined; + } else { if (!parseAnyContextualModifier()) { return undefined; @@ -34819,20 +35667,20 @@ var ts; * * In such situations, 'permitInvalidConstAsModifier' should be set to true. */ - function parseModifiers(permitInvalidConstAsModifier) { + function parseModifiers(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) { var pos = getNodePos(); var list, modifier; - while (modifier = tryParseModifier(permitInvalidConstAsModifier)) { + while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock)) { list = ts.append(list, modifier); } return list && createNodeArray(list, pos); } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(129 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(130 /* AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -34845,14 +35693,17 @@ var ts; } var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); - var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* GetAccessor */); + var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true); + if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* SetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* GetAccessor */); } - if (token() === 132 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 171 /* SetAccessor */); + } + if (token() === 133 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -34882,21 +35733,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 222 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 224 /* ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 253 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 255 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(83 /* ClassKeyword */); + parseExpected(84 /* ClassKeyword */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); @@ -34914,7 +35765,7 @@ var ts; members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 253 /* ClassDeclaration */ + var node = kind === 255 /* ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -34930,7 +35781,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 116 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -34943,7 +35794,7 @@ var ts; function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 93 /* ExtendsKeyword */ || tok === 116 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. nextToken(); var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); @@ -34959,13 +35810,13 @@ var ts; parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(117 /* InterfaceKeyword */); + parseExpected(118 /* InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -34974,11 +35825,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(149 /* TypeKeyword */); + parseExpected(150 /* TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(62 /* EqualsToken */); - var type = token() === 136 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* EqualsToken */); + var type = token() === 137 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -34995,7 +35846,7 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(91 /* EnumKeyword */); + parseExpected(92 /* EnumKeyword */); var name = parseIdentifier(); var members; if (parseExpected(18 /* OpenBraceToken */)) { @@ -35034,7 +35885,7 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); flags |= 1024 /* GlobalAugmentation */; @@ -35055,15 +35906,15 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(140 /* NamespaceKeyword */)) { + else if (parseOptional(141 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(139 /* ModuleKeyword */); + parseExpected(140 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } @@ -35071,18 +35922,21 @@ var ts; return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 143 /* RequireKeyword */ && + return token() === 144 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20 /* OpenParenToken */; } + function nextTokenIsOpenBrace() { + return nextToken() === 18 /* OpenBraceToken */; + } function nextTokenIsSlash() { return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(126 /* AsKeyword */); - parseExpected(140 /* NamespaceKeyword */); + parseExpected(127 /* AsKeyword */); + parseExpected(141 /* NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -35092,7 +35946,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(99 /* ImportKeyword */); + parseExpected(100 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); // We don't parse the identifier here in await context, instead we will report a grammar error in the checker. var identifier; @@ -35100,7 +35954,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 153 /* FromKeyword */ && + if (token() !== 154 /* FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -35118,7 +35972,7 @@ var ts; token() === 18 /* OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -35131,10 +35985,10 @@ var ts; function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 153 /* FromKeyword */; + return token() === 27 /* CommaToken */ || token() === 154 /* FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(62 /* EqualsToken */); + parseExpected(63 /* EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -35153,7 +36007,7 @@ var ts; var namedBindings; if (!identifier || parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(265 /* NamedImports */); + namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(267 /* NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -35164,7 +36018,7 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(143 /* RequireKeyword */); + parseExpected(144 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); var expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -35188,7 +36042,7 @@ var ts; // * as ImportedBinding var pos = getNodePos(); parseExpected(41 /* AsteriskToken */); - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -35201,16 +36055,16 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 265 /* NamedImports */ + var node = kind === 267 /* NamedImports */ ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(271 /* ExportSpecifier */); + return parseImportOrExportSpecifier(273 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(266 /* ImportSpecifier */); + return parseImportOrExportSpecifier(268 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -35226,9 +36080,9 @@ var ts; var identifierName = parseIdentifierName(); var propertyName; var name; - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { propertyName = identifierName; - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -35237,10 +36091,10 @@ var ts; else { name = identifierName; } - if (kind === 266 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 268 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 266 /* ImportSpecifier */ + var node = kind === 268 /* ImportSpecifier */ ? factory.createImportSpecifier(propertyName, name) : factory.createExportSpecifier(propertyName, name); return finishNode(node, pos); @@ -35253,22 +36107,22 @@ var ts; setAwaitContext(/*value*/ true); var exportClause; var moduleSpecifier; - var isTypeOnly = parseOptional(149 /* TypeKeyword */); + var isTypeOnly = parseOptional(150 /* TypeKeyword */); var namespaceExportPos = getNodePos(); if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(126 /* AsKeyword */)) { + if (parseOptional(127 /* AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(269 /* NamedExports */); + exportClause = parseNamedImportsOrExports(271 /* 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() === 153 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(153 /* FromKeyword */); + if (token() === 154 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } @@ -35281,11 +36135,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(62 /* EqualsToken */)) { + if (parseOptional(63 /* EqualsToken */)) { isExportEquals = true; } else { - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); } var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -35301,7 +36155,7 @@ var ts; getImportMetaIfNecessary(sourceFile); } function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 92 /* ExportKeyword */) + return hasModifierOfKind(node, 93 /* ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) @@ -35320,7 +36174,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 99 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -35388,7 +36242,13 @@ var ts; function parseJSDocNameReference() { var pos = getNodePos(); var hasBrace = parseOptional(18 /* OpenBraceToken */); + var p2 = getNodePos(); var entityName = parseEntityName(/* allowReservedWords*/ false); + while (token() === 80 /* PrivateIdentifier */) { + reScanHashToken(); // rescan #id as # id + nextTokenJSDoc(); // then skip the # + entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); + } if (hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -35817,28 +36677,44 @@ var ts; return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; } function parseJSDocLink(start) { - if (!tryParse(parseJSDocLinkPrefix)) { + var linkType = tryParse(parseJSDocLinkPrefix); + if (!linkType) { return undefined; } nextTokenJSDoc(); // start at token after link, then skip any whitespace skipWhitespace(); // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error + var p2 = getNodePos(); var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseEntityName(/*allowReservedWords*/ true) : undefined; + if (name) { + while (token() === 80 /* PrivateIdentifier */) { + reScanHashToken(); // rescan #id as # id + nextTokenJSDoc(); // then skip the # + name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); + } + } var text = []; while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { text.push(scanner.getTokenText()); nextTokenJSDoc(); } - return finishNode(factory.createJSDocLink(name, text.join("")), start, scanner.getTextPos()); + var create = linkType === "link" ? factory.createJSDocLink + : linkType === "linkcode" ? factory.createJSDocLinkCode + : factory.createJSDocLinkPlain; + return finishNode(create(name, text.join("")), start, scanner.getTextPos()); } function parseJSDocLinkPrefix() { skipWhitespaceOrAsterisk(); - return token() === 18 /* OpenBraceToken */ + if (token() === 18 /* OpenBraceToken */ && nextTokenJSDoc() === 59 /* AtToken */ - && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) - && scanner.getTokenValue() === "link"; + && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { + var kind = scanner.getTokenValue(); + if (kind === "link" || kind === "linkcode" || kind === "linkplain") { + return kind; + } + } } function parseUnknownTag(start, tagName, indent, indentText) { return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); @@ -35875,7 +36751,7 @@ var ts; if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(62 /* EqualsToken */)) { + if (parseOptionalToken(63 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -35884,9 +36760,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return true; - case 179 /* ArrayType */: + case 181 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -35918,12 +36794,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 330 /* JSDocParameterTag */ || child.kind === 337 /* JSDocPropertyTag */) { + if (child.kind === 335 /* JSDocParameterTag */ || child.kind === 342 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 179 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 181 /* ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -36040,7 +36916,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 333 /* JSDocTypeTag */) { + if (child.kind === 338 /* JSDocTypeTag */) { if (childTypeTag) { parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); var lastError = ts.lastOrUndefined(parseDiagnostics); @@ -36058,7 +36934,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 179 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 181 /* ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -36111,7 +36987,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 331 /* JSDocReturnTag */) { + if (tag && tag.kind === 336 /* JSDocReturnTag */) { return tag; } } @@ -36145,7 +37021,7 @@ var ts; case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 330 /* JSDocParameterTag */ || child.kind === 337 /* JSDocPropertyTag */) && + if (child && (child.kind === 335 /* JSDocParameterTag */ || child.kind === 342 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -36164,7 +37040,7 @@ var ts; } seenAsterisk = true; break; - case 78 /* Identifier */: + case 79 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -36262,7 +37138,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -36425,8 +37301,8 @@ var ts; function visitArray(array) { array._children = undefined; ts.setTextRangePosEnd(array, array.pos + delta, array.end + delta); - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var node = array_8[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } } @@ -36435,7 +37311,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 78 /* Identifier */: + case 79 /* Identifier */: return true; } return false; @@ -36574,8 +37450,8 @@ var ts; array._children = undefined; // Adjust the pos or end (or both) of the intersecting array accordingly. adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { + var node = array_10[_i]; visitNode(node); } return; @@ -36909,7 +37785,7 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im"); + var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); namedArgRegExCache.set(name, result); return result; } @@ -36933,16 +37809,17 @@ var ts; return; // Missing required argument, don't parse } else if (matchResult) { + var value = matchResult[2] || matchResult[3]; if (arg.captureSpan) { - var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length; + var startPos = range.pos + matchResult.index + matchResult[1].length + 1; argument[arg.name] = { - value: matchResult[3], + value: value, pos: startPos, - end: startPos + matchResult[3].length + end: startPos + value.length }; } else { - argument[arg.name] = matchResult[3]; + argument[arg.name] = value; } } } @@ -36958,7 +37835,7 @@ var ts; return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); } if (range.kind === 3 /* MultiLineCommentTrivia */) { - var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) + var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch); @@ -36985,7 +37862,7 @@ var ts; return {}; if (!pragma.args) return {}; - var args = text.split(/\s+/); + var args = ts.trimString(text).split(/\s+/); var argMap = {}; for (var i = 0; i < pragma.args.length; i++) { var argument = pragma.args[i]; @@ -37004,10 +37881,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 78 /* Identifier */) { + if (lhs.kind === 79 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 107 /* ThisKeyword */) { + if (lhs.kind === 108 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -37127,8 +38004,8 @@ var ts; usefsevents: ts.WatchFileKind.UseFsEvents, usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_how_the_TypeScript_watch_mode_works, }, { name: "watchDirectory", @@ -37138,8 +38015,8 @@ var ts; dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling, fixedchunksizepolling: ts.WatchDirectoryKind.FixedChunkSizePolling, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality, }, { name: "fallbackPolling", @@ -37149,13 +38026,13 @@ var ts; dynamicpriority: ts.PollingWatchKind.DynamicPriority, fixedchunksize: ts.PollingWatchKind.FixedChunkSize, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers, }, { name: "synchronousWatchDirectory", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -37167,8 +38044,8 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Remove_a_list_of_directories_from_the_watch_process, }, { name: "excludeFiles", @@ -37179,8 +38056,8 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Remove_a_list_of_files_from_the_watch_mode_s_processing, }, ]; /* @internal */ @@ -37203,6 +38080,7 @@ var ts; shortName: "w", type: "boolean", showInSimplifiedHelpView: true, + isCommandLineOnly: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Watch_input_files, }, @@ -37210,58 +38088,67 @@ var ts; name: "preserveWatchOutput", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Command_line_Options, - description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, + category: ts.Diagnostics.Output_Formatting, + description: ts.Diagnostics.Disable_wiping_the_console_in_watch_mode, + defaultValueDescription: "n/a" }, { name: "listFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation + category: ts.Diagnostics.Compiler_Diagnostics, + description: ts.Diagnostics.Print_all_of_the_files_read_during_the_compilation, + defaultValueDescription: "false" }, { name: "explainFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Print_names_of_files_and_the_reason_they_are_part_of_the_compilation - }, { + category: ts.Diagnostics.Compiler_Diagnostics, + description: ts.Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included + }, + { name: "listEmittedFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation + category: ts.Diagnostics.Compiler_Diagnostics, + description: ts.Diagnostics.Print_the_names_of_emitted_files_after_a_compilation, + defaultValueDescription: "false" }, { name: "pretty", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Command_line_Options, - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + category: ts.Diagnostics.Output_Formatting, + description: ts.Diagnostics.Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read, + defaultValueDescription: "true" }, { name: "traceResolution", type: "boolean", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + category: ts.Diagnostics.Compiler_Diagnostics, + description: ts.Diagnostics.Log_paths_used_during_the_moduleResolution_process, + defaultValueDescription: "false" }, { name: "diagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Show_diagnostic_information + category: ts.Diagnostics.Compiler_Diagnostics, + description: ts.Diagnostics.Output_compiler_performance_information_after_building, + defaultValueDescription: "false" }, { name: "extendedDiagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Show_verbose_diagnostic_information + category: ts.Diagnostics.Compiler_Diagnostics, + description: ts.Diagnostics.Output_more_detailed_compiler_performance_information_after_building, + defaultValueDescription: "false" }, { name: "generateCpuProfile", type: "string", isFilePath: true, paramType: ts.Diagnostics.FILE_OR_DIRECTORY, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Generates_a_CPU_profile + category: ts.Diagnostics.Compiler_Diagnostics, + description: ts.Diagnostics.Emit_a_v8_CPU_profile_of_the_compiler_run_for_debugging, + defaultValueDescription: "profile.cpuprofile" }, { name: "generateTrace", @@ -37269,30 +38156,33 @@ var ts; isFilePath: true, isCommandLineOnly: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_an_event_trace_and_a_list_of_types }, { name: "incremental", shortName: "i", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_incremental_compilation, - transpileOptionValue: undefined + transpileOptionValue: undefined, + defaultValueDescription: ts.Diagnostics.false_unless_composite_is_set }, { name: "assumeChangesOnlyAffectDirectDependencies", type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it }, { name: "locale", type: "string", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us + category: ts.Diagnostics.Command_line_Options, + isCommandLineOnly: true, + description: ts.Diagnostics.Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit, + defaultValueDescription: ts.Diagnostics.Platform_specific }, ]; /* @internal */ @@ -37317,8 +38207,9 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.VERSION, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT, + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, + defaultValueDescription: "ES3" }; var commandOptionsWithoutBuild = [ // CommandLine only options @@ -37365,6 +38256,7 @@ var ts; { name: "showConfig", type: "boolean", + showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, isCommandLineOnly: true, description: ts.Diagnostics.Print_the_final_configuration_instead_of_building @@ -37398,8 +38290,8 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext, + category: ts.Diagnostics.Modules, + description: ts.Diagnostics.Specify_what_module_code_is_generated, }, { name: "lib", @@ -37408,10 +38300,10 @@ var ts; name: "lib", type: ts.libMap }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_a_set_of_bundled_library_declaration_files_that_describe_the_target_runtime_environment, transpileOptionValue: undefined }, { @@ -37419,14 +38311,17 @@ var ts; type: "boolean", affectsModuleResolution: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + category: ts.Diagnostics.JavaScript_Support, + description: ts.Diagnostics.Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files, + defaultValueDescription: "false" }, { name: "checkJs", type: "boolean", - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Report_errors_in_js_files + showInSimplifiedHelpView: true, + category: ts.Diagnostics.JavaScript_Support, + description: ts.Diagnostics.Enable_error_reporting_in_type_checked_JavaScript_files, + defaultValueDescription: "false" }, { name: "jsx", @@ -37436,8 +38331,9 @@ var ts; affectsModuleResolution: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev, + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_what_JSX_code_is_generated, + defaultValueDescription: "undefined" }, { name: "declaration", @@ -37445,34 +38341,39 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Generates_corresponding_d_ts_file, - transpileOptionValue: undefined + category: ts.Diagnostics.Emit, + transpileOptionValue: undefined, + description: ts.Diagnostics.Generate_d_ts_files_from_TypeScript_and_JavaScript_files_in_your_project, + defaultValueDescription: ts.Diagnostics.false_unless_composite_is_set, }, { name: "declarationMap", type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, - transpileOptionValue: undefined + category: ts.Diagnostics.Emit, + transpileOptionValue: undefined, + defaultValueDescription: "false", + description: ts.Diagnostics.Create_sourcemaps_for_d_ts_files }, { name: "emitDeclarationOnly", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Only_emit_d_ts_declaration_files, - transpileOptionValue: undefined + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files, + transpileOptionValue: undefined, + defaultValueDescription: "false", }, { name: "sourceMap", type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Generates_corresponding_map_file, + category: ts.Diagnostics.Emit, + defaultValueDescription: "false", + description: ts.Diagnostics.Create_source_map_files_for_emitted_JavaScript_files, }, { name: "outFile", @@ -37481,9 +38382,10 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.FILE, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - transpileOptionValue: undefined + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output, + transpileOptionValue: undefined, + defaultValueDescription: "n/a" }, { name: "outDir", @@ -37492,8 +38394,9 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Specify_an_output_folder_for_all_emitted_files, + defaultValueDescription: "n/a" }, { name: "rootDir", @@ -37501,17 +38404,19 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + category: ts.Diagnostics.Modules, + description: ts.Diagnostics.Specify_the_root_folder_within_your_source_files, + defaultValueDescription: ts.Diagnostics.Computed_from_the_list_of_input_files }, { name: "composite", type: "boolean", affectsEmit: true, isTSConfigOnly: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Enable_project_compilation, - transpileOptionValue: undefined + category: ts.Diagnostics.Projects, + transpileOptionValue: undefined, + defaultValueDescription: "false", + description: ts.Diagnostics.Enable_constraints_that_allow_a_TypeScript_project_to_be_used_with_project_references, }, { name: "tsBuildInfoFile", @@ -37519,32 +38424,36 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.FILE, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, - transpileOptionValue: undefined + category: ts.Diagnostics.Projects, + transpileOptionValue: undefined, + defaultValueDescription: ".tsbuildinfo", + description: ts.Diagnostics.Specify_the_folder_for_tsbuildinfo_incremental_compilation_files, }, { name: "removeComments", type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Do_not_emit_comments_to_output, + category: ts.Diagnostics.Emit, + defaultValueDescription: "false", + description: ts.Diagnostics.Disable_emitting_comments, }, { name: "noEmit", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Do_not_emit_outputs, - transpileOptionValue: undefined + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Disable_emitting_files_from_a_compilation, + transpileOptionValue: undefined, + defaultValueDescription: "false" }, { name: "importHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Import_emit_helpers_from_tslib + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file, + defaultValueDescription: "false" }, { name: "importsNotUsedAsValues", @@ -37555,149 +38464,166 @@ var ts; })), affectsEmit: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types }, { name: "downlevelIteration", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration, + defaultValueDescription: "false" }, { name: "isolatedModules", type: "boolean", - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, - transpileOptionValue: true + category: ts.Diagnostics.Interop_Constraints, + description: ts.Diagnostics.Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports, + transpileOptionValue: true, + defaultValueDescription: "false" }, // Strict Type Checks { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, - description: ts.Diagnostics.Enable_all_strict_type_checking_options + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_all_strict_type_checking_options, + defaultValueDescription: "false" }, { name: "noImplicitAny", type: "boolean", affectsSemanticDiagnostics: true, strictFlag: true, - showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type, + defaultValueDescription: ts.Diagnostics.false_unless_strict_is_set }, { name: "strictNullChecks", type: "boolean", affectsSemanticDiagnostics: true, strictFlag: true, - showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, - description: ts.Diagnostics.Enable_strict_null_checks + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.When_type_checking_take_into_account_null_and_undefined, + defaultValueDescription: ts.Diagnostics.false_unless_strict_is_set }, { name: "strictFunctionTypes", type: "boolean", - affectsSemanticDiagnostics: true, strictFlag: true, - showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, - description: ts.Diagnostics.Enable_strict_checking_of_function_types + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible, + defaultValueDescription: ts.Diagnostics.false_unless_strict_is_set }, { name: "strictBindCallApply", type: "boolean", strictFlag: true, - showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, - description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function, + defaultValueDescription: ts.Diagnostics.false_unless_strict_is_set }, { name: "strictPropertyInitialization", type: "boolean", affectsSemanticDiagnostics: true, strictFlag: true, - showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, - description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor, + defaultValueDescription: ts.Diagnostics.false_unless_strict_is_set }, { name: "noImplicitThis", type: "boolean", affectsSemanticDiagnostics: true, strictFlag: true, - showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_error_reporting_when_this_is_given_the_type_any, + defaultValueDescription: ts.Diagnostics.false_unless_strict_is_set + }, + { + name: "useUnknownInCatchVariables", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any, }, { name: "alwaysStrict", type: "boolean", affectsSourceFile: true, strictFlag: true, - showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, - description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Ensure_use_strict_is_always_emitted, + defaultValueDescription: ts.Diagnostics.false_unless_strict_is_set }, // Additional Checks { name: "noUnusedLocals", type: "boolean", affectsSemanticDiagnostics: true, - showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, - description: ts.Diagnostics.Report_errors_on_unused_locals, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_error_reporting_when_a_local_variables_aren_t_read, + defaultValueDescription: "false" }, { name: "noUnusedParameters", type: "boolean", affectsSemanticDiagnostics: true, - showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, - description: ts.Diagnostics.Report_errors_on_unused_parameters, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read, + defaultValueDescription: "false" + }, + { + name: "exactOptionalPropertyTypes", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined }, { name: "noImplicitReturns", type: "boolean", affectsSemanticDiagnostics: true, - showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function, + defaultValueDescription: "false" }, { name: "noFallthroughCasesInSwitch", type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements }, { name: "noUncheckedIndexedAccess", type: "boolean", affectsSemanticDiagnostics: true, - showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Include_undefined_in_index_signature_results }, { name: "noImplicitOverride", type: "boolean", affectsSemanticDiagnostics: true, - showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier }, { name: "noPropertyAccessFromIndexSignature", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, - description: ts.Diagnostics.Require_undeclared_properties_from_index_signatures_to_use_element_accesses + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type, + defaultValueDescription: "false" }, // Module Resolution { @@ -37708,16 +38634,17 @@ var ts; })), affectsModuleResolution: true, paramType: ts.Diagnostics.STRATEGY, - category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + category: ts.Diagnostics.Modules, + description: ts.Diagnostics.Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier, + defaultValueDescription: ts.Diagnostics.module_AMD_or_UMD_or_System_or_ES6_then_Classic_Otherwise_Node }, { name: "baseUrl", type: "string", affectsModuleResolution: true, isFilePath: true, - category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + category: ts.Diagnostics.Modules, + description: ts.Diagnostics.Specify_the_base_directory_to_resolve_non_relative_module_names }, { // this option can only be specified in tsconfig.json @@ -37726,8 +38653,8 @@ var ts; type: "object", affectsModuleResolution: true, isTSConfigOnly: true, - category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + category: ts.Diagnostics.Modules, + description: ts.Diagnostics.Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations, transpileOptionValue: undefined }, { @@ -37742,9 +38669,10 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, - transpileOptionValue: undefined + category: ts.Diagnostics.Modules, + description: ts.Diagnostics.Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules, + transpileOptionValue: undefined, + defaultValueDescription: ts.Diagnostics.Computed_from_the_list_of_input_files }, { name: "typeRoots", @@ -37755,8 +38683,8 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from + category: ts.Diagnostics.Modules, + description: ts.Diagnostics.Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types }, { name: "types", @@ -37765,18 +38693,19 @@ var ts; name: "types", type: "string" }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + category: ts.Diagnostics.Modules, + description: ts.Diagnostics.Specify_type_package_names_to_be_included_without_being_referenced_in_a_source_file, transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + category: ts.Diagnostics.Interop_Constraints, + description: ts.Diagnostics.Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export, + defaultValueDescription: ts.Diagnostics.module_system_or_esModuleInterop }, { name: "esModuleInterop", @@ -37784,21 +38713,24 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports + category: ts.Diagnostics.Interop_Constraints, + description: ts.Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility, + defaultValueDescription: "false" }, { name: "preserveSymlinks", type: "boolean", - category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, + category: ts.Diagnostics.Interop_Constraints, + description: ts.Diagnostics.Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node, + defaultValueDescription: "n/a" }, { name: "allowUmdGlobalAccess", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules, + defaultValueDescription: "false" }, // Source Maps { @@ -37806,59 +38738,62 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Specify_the_root_path_for_debuggers_to_find_the_reference_source_code, }, { name: "mapRoot", type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, }, { name: "inlineSourceMap", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, - description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript, + defaultValueDescription: "false" }, { name: "inlineSources", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, - description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript, + defaultValueDescription: "false" }, // Experimental { name: "experimentalDecorators", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Experimental_Options, - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators }, { name: "emitDecoratorMetadata", type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Experimental_Options, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files }, // Advanced { name: "jsxFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h, + defaultValueDescription: "`React.createElement`" }, { name: "jsxFragmentFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragment_or_Fragment }, { name: "jsxImportSource", @@ -37866,15 +38801,17 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk, + defaultValueDescription: "react" }, { name: "resolveJsonModule", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Include_modules_imported_with_json_extension + category: ts.Diagnostics.Modules, + description: ts.Diagnostics.Enable_importing_json_files, + defaultValueDescription: "false" }, { name: "out", @@ -37882,36 +38819,41 @@ var ts; affectsEmit: true, isFilePath: false, // for correct behaviour, please use outFile - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, paramType: ts.Diagnostics.FILE, - description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, - transpileOptionValue: undefined + transpileOptionValue: undefined, + defaultValueDescription: "n/a", + description: ts.Diagnostics.Deprecated_setting_Use_outFile_instead, }, { name: "reactNamespace", type: "string", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit, + defaultValueDescription: "`React`", }, { name: "skipDefaultLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files + category: ts.Diagnostics.Completeness, + description: ts.Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript, + defaultValueDescription: "false", }, { name: "charset", type: "string", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.The_character_set_of_the_input_files + category: ts.Diagnostics.Backwards_Compatibility, + description: ts.Diagnostics.No_longer_supported_In_early_versions_manually_set_the_text_encoding_for_reading_files, + defaultValueDescription: "utf8" }, { name: "emitBOM", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files, + defaultValueDescription: "false" }, { name: "newLine", @@ -37921,99 +38863,108 @@ var ts; })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Set_the_newline_character_for_emitting_files, + defaultValueDescription: ts.Diagnostics.Platform_specific }, { name: "noErrorTruncation", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_truncate_error_messages + category: ts.Diagnostics.Output_Formatting, + description: ts.Diagnostics.Disable_truncating_types_in_error_messages, + defaultValueDescription: "false" }, { name: "noLib", type: "boolean", - affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + category: ts.Diagnostics.Language_and_Environment, + affectsProgramStructure: true, + description: ts.Diagnostics.Disable_including_any_library_files_including_the_default_lib_d_ts, // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. - transpileOptionValue: true + transpileOptionValue: true, + defaultValueDescription: "false" }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + category: ts.Diagnostics.Modules, + description: ts.Diagnostics.Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add_to_a_project, // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. - transpileOptionValue: true + transpileOptionValue: true, + defaultValueDescription: "false" }, { name: "stripInternal", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments, }, { name: "disableSizeLimit", type: "boolean", - affectsSourceFile: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + affectsProgramStructure: true, + category: ts.Diagnostics.Editor_Support, + description: ts.Diagnostics.Remove_the_20mb_cap_on_total_source_code_size_for_JavaScript_files_in_the_TypeScript_language_server, + defaultValueDescription: "false" }, { name: "disableSourceOfProjectReferenceRedirect", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + category: ts.Diagnostics.Projects, + description: ts.Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects }, { name: "disableSolutionSearching", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_solution_searching_for_this_project + category: ts.Diagnostics.Projects, + description: ts.Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing }, { name: "disableReferencedProjectLoad", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_loading_referenced_projects + category: ts.Diagnostics.Projects, + description: ts.Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript }, { name: "noImplicitUseStrict", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + category: ts.Diagnostics.Backwards_Compatibility, + description: ts.Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files, + defaultValueDescription: "false" }, { name: "noEmitHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output, + defaultValueDescription: "false" }, { name: "noEmitOnError", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - transpileOptionValue: undefined + category: ts.Diagnostics.Emit, + transpileOptionValue: undefined, + description: ts.Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported, + defaultValueDescription: "false" }, { name: "preserveConstEnums", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code, + defaultValueDescription: "n/a" }, { name: "declarationDir", @@ -38021,80 +38972,91 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files, - transpileOptionValue: undefined + category: ts.Diagnostics.Emit, + transpileOptionValue: undefined, + description: ts.Diagnostics.Specify_the_output_directory_for_generated_declaration_files, + defaultValueDescription: "n/a" }, { name: "skipLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + category: ts.Diagnostics.Completeness, + description: ts.Diagnostics.Skip_type_checking_all_d_ts_files, + defaultValueDescription: "false" }, { name: "allowUnusedLabels", type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Disable_error_reporting_for_unused_labels, + defaultValueDescription: "undefined" }, { name: "allowUnreachableCode", type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Disable_error_reporting_for_unreachable_code, + defaultValueDescription: "undefined" }, { name: "suppressExcessPropertyErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + category: ts.Diagnostics.Backwards_Compatibility, + description: ts.Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals, + defaultValueDescription: "false" }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + category: ts.Diagnostics.Backwards_Compatibility, + description: ts.Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures, + defaultValueDescription: "false" }, { name: "forceConsistentCasingInFileNames", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + category: ts.Diagnostics.Interop_Constraints, + description: ts.Diagnostics.Ensure_that_casing_is_correct_in_imports, + defaultValueDescription: "false" }, { name: "maxNodeModuleJsDepth", type: "number", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + category: ts.Diagnostics.JavaScript_Support, + description: ts.Diagnostics.Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicable_with_allowJs, + defaultValueDescription: "0" }, { name: "noStrictGenericChecks", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, + defaultValueDescription: "false" }, { name: "useDefineForClassFields", type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields, + defaultValueDescription: "false" }, { name: "keyofStringsOnly", type: "boolean", - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols, + category: ts.Diagnostics.Backwards_Compatibility, + description: ts.Diagnostics.Make_keyof_only_return_strings_instead_of_string_numbers_or_symbols_Legacy_option, + defaultValueDescription: "false" }, { // A list of plugins to load in the language service @@ -38105,11 +39067,12 @@ var ts; name: "plugin", type: "object" }, - description: ts.Diagnostics.List_of_language_service_plugins + description: ts.Diagnostics.List_of_language_service_plugins, + category: ts.Diagnostics.Editor_Support, }, ]; /* @internal */ - ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsWithoutBuild); + ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild, true), commandOptionsWithoutBuild, true); /* @internal */ ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; }); /* @internal */ @@ -38121,10 +39084,14 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ + ts.optionsAffectingProgramStructure = ts.optionDeclarations.filter(function (option) { return !!option.affectsProgramStructure; }); + /* @internal */ ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { return ts.hasProperty(option, "transpileOptionValue"); }); - var commandOptionsOnlyBuild = [ + // Build related options + /* @internal */ + ts.optionsForBuild = [ { name: "verbose", shortName: "v", @@ -38154,7 +39121,7 @@ var ts; } ]; /* @internal */ - ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsOnlyBuild); + ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild, true), ts.optionsForBuild, true); /* @internal */ ts.typeAcquisitionDeclarations = [ { @@ -38245,13 +39212,13 @@ var ts; } /* @internal */ function parseCustomTypeOption(opt, value, errors) { - return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); + return convertJsonOptionOfCustomType(opt, ts.trimString(value || ""), errors); } ts.parseCustomTypeOption = parseCustomTypeOption; /* @internal */ function parseListTypeOption(opt, value, errors) { if (value === void 0) { value = ""; } - value = trimString(value); + value = ts.trimString(value); if (ts.startsWith(value, "-")) { return undefined; } @@ -38635,7 +39602,8 @@ var ts; }, { name: "extends", - type: "string" + type: "string", + category: ts.Diagnostics.File_Management, }, { name: "references", @@ -38643,7 +39611,8 @@ var ts; element: { name: "references", type: "object" - } + }, + category: ts.Diagnostics.Projects, }, { name: "files", @@ -38651,7 +39620,8 @@ var ts; element: { name: "files", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "include", @@ -38659,7 +39629,9 @@ var ts; element: { name: "include", type: "string" - } + }, + category: ts.Diagnostics.File_Management, + defaultValueDescription: ts.Diagnostics.if_files_is_specified_otherwise_Asterisk_Asterisk_Slash_Asterisk }, { name: "exclude", @@ -38667,7 +39639,9 @@ var ts; element: { name: "exclude", type: "string" - } + }, + category: ts.Diagnostics.File_Management, + defaultValueDescription: ts.Diagnostics.node_modules_bower_components_jspm_packages_plus_the_value_of_outDir_if_one_is_specified }, ts.compileOnSaveCommandLineOption ]) @@ -38679,7 +39653,7 @@ var ts; var _a; var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; - if (rootExpression && rootExpression.kind !== 201 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 203 /* ObjectLiteralExpression */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json")); // Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that @@ -38719,7 +39693,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 289 /* PropertyAssignment */) { + if (element.kind !== 291 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -38786,13 +39760,13 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 109 /* TrueKeyword */: + case 110 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: @@ -38813,13 +39787,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -38836,7 +39810,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -38853,7 +39827,7 @@ var ts; if (!invalidReported) { var diagnostic = (_a = option === null || option === void 0 ? void 0 : option.extraValidation) === null || _a === void 0 ? void 0 : _a.call(option, value); if (diagnostic) { - errors.push(ts.createDiagnosticForNodeInSourceFile.apply(void 0, __spreadArray([sourceFile, valueExpression], diagnostic))); + errors.push(ts.createDiagnosticForNodeInSourceFile.apply(void 0, __spreadArray([sourceFile, valueExpression], diagnostic, false))); return undefined; } } @@ -38974,7 +39948,7 @@ var ts; if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + if (optionsNameMap.has(name) && (optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options || optionsNameMap.get(name).category === ts.Diagnostics.Output_Formatting)) { return "continue"; } var value = options[name]; @@ -39040,13 +40014,11 @@ var ts; function makePadding(paddingLength) { return Array(paddingLength + 1).join(" "); } - function isAllowedOption(_a) { - var category = _a.category, name = _a.name; - // Skip options which do not have a category or have category `Command_line_Options` - // Exclude all possible `Advanced_Options` in tsconfig.json which were NOT defined in command line - return category !== undefined - && category !== ts.Diagnostics.Command_line_Options - && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name)); + function isAllowedOptionForOutput(_a) { + var category = _a.category, name = _a.name, isCommandLineOnly = _a.isCommandLineOnly; + // Skip options which do not have a category or have categories which are more niche + var categoriesToSkip = [ts.Diagnostics.Command_line_Options, ts.Diagnostics.Editor_Support, ts.Diagnostics.Compiler_Diagnostics, ts.Diagnostics.Backwards_Compatibility, ts.Diagnostics.Watch_and_Build_Modes, ts.Diagnostics.Output_Formatting]; + return !isCommandLineOnly && category !== undefined && (!categoriesToSkip.includes(category) || compilerOptionsMap.has(name)); } function writeConfigurations() { // Filter applicable options to place in the file @@ -39054,7 +40026,7 @@ var ts; for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) { var option = optionDeclarations_1[_i]; var category = option.category; - if (isAllowedOption(option)) { + if (isAllowedOptionForOutput(option)) { categorizedOptions.add(ts.getLocaleSpecificMessage(category), option); } } @@ -39271,6 +40243,7 @@ var ts; validatedFilesSpec: ts.filter(filesSpecs, ts.isString), validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, + pathPatterns: undefined, // Initialized on first use }; } function getFileNames(basePath) { @@ -39368,7 +40341,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArray(__spreadArray([], resolutionStack), [resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArray(__spreadArray([], resolutionStack, true), [resolvedPath], false).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -39668,9 +40641,6 @@ var ts; function convertJsonOptionOfListType(option, values, basePath, errors) { return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } /** * Tests for a path that ends in a recursive directory wildcard. * Matches **, \**, **\, and \**\, but not a**b. @@ -39683,34 +40653,6 @@ var ts; * \/?$ # matches an optional trailing directory separator at the end of the string. */ var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - /** - * Tests for a path where .. appears after a recursive directory wildcard. - * Matches **\..\*, **\a\..\*, and **\.., but not ..\**\* - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * (^|\/) # matches either the beginning of the string or a directory separator. - * \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator. - * (.*\/)? # optionally matches any number of characters followed by a directory separator. - * \.\. # matches a parent directory path component ".." - * ($|\/) # matches either the end of the string or a directory separator. - */ - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - /** - * Tests for a path containing a wildcard character in a directory component of the path. - * Matches \*\, \?\, and \a*b\, but not \a\ or \a\*. - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * \/ # matches a directory separator. - * [^/]*? # matches any number of characters excluding directory separators (non-greedy). - * [*?] # matches either a wildcard character (* or ?) - * [^/]* # matches any number of characters excluding directory separators (greedy). - * \/ # matches a directory separator. - */ - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; /** * Matches the portion of a wildcard path that does not contain wildcards. * Matches \a of \a\*, or \a\b\c of \a\b\c\?\d. @@ -39751,7 +40693,7 @@ var ts; // via wildcard of *.json kind var wildCardJsonFileMap = new ts.Map(); var validatedFilesSpec = configFileSpecs.validatedFilesSpec, validatedIncludeSpecs = configFileSpecs.validatedIncludeSpecs, validatedExcludeSpecs = configFileSpecs.validatedExcludeSpecs; - // Rather than requery this for each file and filespec, we query the supported extensions + // Rather than re-query this for each file and filespec, we query the supported extensions // once and store it on the expansion context. var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions); var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); @@ -39829,9 +40771,22 @@ var ts; return matchesExcludeWorker(pathToCheck, validatedExcludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath); } ts.isExcludedFile = isExcludedFile; + function invalidDotDotAfterRecursiveWildcard(s) { + // We used to use the regex /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/ to check for this case, but + // in v8, that has polynomial performance because the recursive wildcard match - **/ - + // can be matched in many arbitrary positions when multiple are present, resulting + // in bad backtracking (and we don't care which is matched - just that some /.. segment + // comes after some **/ segment). + var wildcardIndex = ts.startsWith(s, "**/") ? 0 : s.indexOf("/**/"); + if (wildcardIndex === -1) { + return false; + } + var lastDotIndex = ts.endsWith(s, "/..") ? s.length : s.lastIndexOf("/../"); + return lastDotIndex > wildcardIndex; + } /* @internal */ function matchesExclude(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory) { - return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcardPattern.test(spec); }), useCaseSensitiveFileNames, currentDirectory); + return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcard(spec); }), useCaseSensitiveFileNames, currentDirectory); } ts.matchesExclude = matchesExclude; function matchesExcludeWorker(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath) { @@ -39864,7 +40819,7 @@ var ts; if (disallowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { return [ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + else if (invalidDotDotAfterRecursiveWildcard(spec)) { return [ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } } @@ -39925,9 +40880,18 @@ var ts; function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { var match = wildcardDirectoryPattern.exec(spec); if (match) { + // We check this with a few `indexOf` calls because 3 `indexOf`/`lastIndexOf` calls is + // less algorithmically complex (roughly O(3n) worst-case) than the regex we used to use, + // \/[^/]*?[*?][^/]*\/ which was polynominal in v8, since arbitrary sequences of wildcard + // characters could match any of the central patterns, resulting in bad backtracking. + var questionWildcardIndex = spec.indexOf("?"); + var starWildcardIndex = spec.indexOf("*"); + var lastDirectorySeperatorIndex = spec.lastIndexOf(ts.directorySeparator); return { key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), - flags: watchRecursivePattern.test(spec) ? 1 /* Recursive */ : 0 /* None */ + flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) + || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) + ? 1 /* Recursive */ : 0 /* None */ }; } if (ts.isImplicitGlob(spec)) { @@ -40432,7 +41396,7 @@ var ts; ts.createCacheWithRedirects = createCacheWithRedirects; function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { var cache; - return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear }; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries }; function getPackageJsonInfo(packageJsonPath) { return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); } @@ -40442,6 +41406,10 @@ var ts; function clear() { cache = undefined; } + function entries() { + var iter = cache === null || cache === void 0 ? void 0 : cache.entries(); + return iter ? ts.arrayFrom(iter) : []; + } } function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); @@ -40497,9 +41465,7 @@ var ts; var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options)); var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, - clear: clear, - update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } }); + return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } }); function clear() { preDirectoryResolutionCache.clear(); moduleNameToDirectoryMap.clear(); @@ -40737,7 +41703,8 @@ var ts; } } function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var _a; + var _b = state.compilerOptions, baseUrl = _b.baseUrl, paths = _b.paths, configFile = _b.configFile; if (paths && !ts.pathIsRelative(moduleName)) { if (state.traceEnabled) { if (baseUrl) { @@ -40746,7 +41713,8 @@ var ts; trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); } var baseDirectory = ts.getPathsBasePath(state.compilerOptions, state.host); // Always defined when 'paths' is defined - return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, /*onlyRecordFailures*/ false, state); + var pathPatterns = (configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) ? (_a = configFile.configFileSpecs).pathPatterns || (_a.pathPatterns = ts.tryParsePatterns(paths)) : undefined; + return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, /*onlyRecordFailures*/ false, state); } } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { @@ -40853,7 +41821,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions), [Extensions.Json]); + var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); @@ -41144,7 +42112,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, moduleName); } - var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); + var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, /*pathPatterns*/ undefined, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); if (result) { return removeIgnoredPackageId(result.value); } @@ -41251,7 +42219,7 @@ var ts; trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest); } var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host); - var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state); + var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state); if (fromPaths) { return fromPaths.value; } @@ -41259,8 +42227,9 @@ var ts; } return loader(extensions, candidate, !nodeModulesDirectoryExists, state); } - function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) { - var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName); + function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, onlyRecordFailures, state) { + pathPatterns || (pathPatterns = ts.tryParsePatterns(paths)); + var matchedPattern = ts.matchPatternOrExact(pathPatterns, moduleName); if (matchedPattern) { var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName); var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern); @@ -41435,26 +42404,26 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 262 /* ImportDeclaration */: - case 261 /* ImportEqualsDeclaration */: + case 264 /* ImportDeclaration */: + case 263 /* ImportEqualsDeclaration */: if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 269 /* NamedExports */) { + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 271 /* NamedExports */) { var state = 0 /* NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -41470,7 +42439,7 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 258 /* ModuleBlock */: { + case 260 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); @@ -41492,9 +42461,9 @@ var ts; }); return state_1; } - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 78 /* Identifier */: + case 79 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -41693,7 +42662,7 @@ var ts; // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 267 /* ExportAssignment */) { + if (node.kind === 269 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -41702,7 +42671,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 159 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -41728,36 +42697,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 167 /* Constructor */: + case 169 /* Constructor */: return "__constructor" /* Constructor */; - case 175 /* FunctionType */: - case 170 /* CallSignature */: - case 315 /* JSDocSignature */: + case 177 /* FunctionType */: + case 172 /* CallSignature */: + case 318 /* JSDocSignature */: return "__call" /* Call */; - case 176 /* ConstructorType */: - case 171 /* ConstructSignature */: + case 178 /* ConstructorType */: + case 173 /* ConstructSignature */: return "__new" /* New */; - case 172 /* IndexSignature */: + case 174 /* IndexSignature */: return "__index" /* Index */; - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 298 /* SourceFile */: + case 300 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 309 /* JSDocFunctionType */: + case 312 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 161 /* Parameter */: + case 162 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 309 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 312 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -41774,11 +42743,13 @@ var ts; * @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.) * @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations. */ - function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod) { - ts.Debug.assert(!ts.hasDynamicName(node)); + function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) { + ts.Debug.assert(isComputedName || !ts.hasDynamicName(node)); var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" - var name = isDefaultExport && parent ? "default" /* Default */ : getDeclarationName(node); + var name = isComputedName ? "__computed" /* Computed */ + : isDefaultExport && parent ? "default" /* Default */ + : getDeclarationName(node); var symbol; if (name === undefined) { symbol = createSymbol(0 /* None */, "__missing" /* Missing */); @@ -41857,7 +42828,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 267 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 269 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -41879,7 +42850,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1))); + file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false))); symbol = createSymbol(0 /* None */, name); } } @@ -41896,7 +42867,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 271 /* ExportSpecifier */ || (node.kind === 261 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 273 /* ExportSpecifier */ || (node.kind === 263 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -41985,7 +42956,7 @@ var ts; // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 210 /* ArrowFunction */) { + if (node.kind !== 212 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -42018,7 +42989,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 167 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 252 /* FunctionDeclaration */ || node.kind === 209 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 169 /* Constructor */ || node.kind === 168 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 254 /* FunctionDeclaration */ || node.kind === 211 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -42033,14 +43004,14 @@ var ts; node.flags |= 512 /* HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 298 /* SourceFile */) { + if (node.kind === 300 /* SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 167 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 252 /* FunctionDeclaration */ || node.kind === 209 /* FunctionExpression */))) { + if (node.kind === 169 /* Constructor */ || node.kind === 168 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 254 /* FunctionDeclaration */ || node.kind === 211 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -42067,8 +43038,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 252 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 252 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 254 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 254 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -42091,59 +43062,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 233 /* FirstStatement */ && node.kind <= 249 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 235 /* FirstStatement */ && node.kind <= 251 /* LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 237 /* WhileStatement */: + case 239 /* WhileStatement */: bindWhileStatement(node); break; - case 236 /* DoStatement */: + case 238 /* DoStatement */: bindDoStatement(node); break; - case 238 /* ForStatement */: + case 240 /* ForStatement */: bindForStatement(node); break; - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 235 /* IfStatement */: + case 237 /* IfStatement */: bindIfStatement(node); break; - case 243 /* ReturnStatement */: - case 247 /* ThrowStatement */: + case 245 /* ReturnStatement */: + case 249 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 242 /* BreakStatement */: - case 241 /* ContinueStatement */: + case 244 /* BreakStatement */: + case 243 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 248 /* TryStatement */: + case 250 /* TryStatement */: bindTryStatement(node); break; - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: bindSwitchStatement(node); break; - case 259 /* CaseBlock */: + case 261 /* CaseBlock */: bindCaseBlock(node); break; - case 285 /* CaseClause */: + case 287 /* CaseClause */: bindCaseClause(node); break; - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: bindExpressionStatement(node); break; - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: bindLabeledStatement(node); break; - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 216 /* PostfixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -42153,47 +43124,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 211 /* DeleteExpression */: + case 213 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 204 /* CallExpression */: + case 206 /* CallExpression */: bindCallExpressionFlow(node); break; - case 226 /* NonNullExpression */: + case 228 /* NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 335 /* JSDocTypedefTag */: - case 328 /* JSDocCallbackTag */: - case 329 /* JSDocEnumTag */: + case 340 /* JSDocTypedefTag */: + case 333 /* JSDocCallbackTag */: + case 334 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 298 /* SourceFile */: { + case 300 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 231 /* Block */: - case 258 /* ModuleBlock */: + case 233 /* Block */: + case 260 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 199 /* BindingElement */: + case 201 /* BindingElement */: bindBindingElementFlow(node); break; - case 201 /* ObjectLiteralExpression */: - case 200 /* ArrayLiteralExpression */: - case 289 /* PropertyAssignment */: - case 221 /* SpreadElement */: + case 203 /* ObjectLiteralExpression */: + case 202 /* ArrayLiteralExpression */: + case 291 /* PropertyAssignment */: + case 223 /* SpreadElement */: // Carry over whether we are in an assignment pattern of Object and Array literals // as well as their children that are valid assignment targets. inAssignmentPattern = saveInAssignmentPattern; @@ -42207,22 +43178,22 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 107 /* ThisKeyword */: - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 108 /* ThisKeyword */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: return containsNarrowableReference(expr); - case 204 /* CallExpression */: + case 206 /* CallExpression */: return hasNarrowableArgument(expr); - case 208 /* ParenthesizedExpression */: - case 226 /* NonNullExpression */: + case 210 /* ParenthesizedExpression */: + case 228 /* NonNullExpression */: return isNarrowingExpression(expr.expression); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 212 /* TypeOfExpression */: + case 214 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -42246,7 +43217,7 @@ var ts; } } } - if (expr.expression.kind === 202 /* PropertyAccessExpression */ && + if (expr.expression.kind === 204 /* PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -42255,15 +43226,12 @@ var ts; function isNarrowingTypeofOperands(expr1, expr2) { return ts.isTypeOfExpression(expr1) && isNarrowableOperand(expr1.expression) && ts.isStringLiteralLike(expr2); } - function isNarrowableInOperands(left, right) { - return ts.isStringLiteralLike(left) && isNarrowingExpression(right); - } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: @@ -42271,10 +43239,10 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 100 /* InKeyword */: - return isNarrowableInOperands(expr.left, expr.right); + case 101 /* InKeyword */: + return isNarrowingExpression(expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); } @@ -42282,11 +43250,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -42320,8 +43288,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 109 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 94 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -42360,26 +43328,26 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 235 /* IfStatement */: - case 237 /* WhileStatement */: - case 236 /* DoStatement */: + case 237 /* IfStatement */: + case 239 /* WhileStatement */: + case 238 /* DoStatement */: return parent.expression === node; - case 238 /* ForStatement */: - case 218 /* ConditionalExpression */: + case 240 /* ForStatement */: + case 220 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 208 /* ParenthesizedExpression */) { + if (node.kind === 210 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 215 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 217 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 217 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + return node.kind === 219 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */); } @@ -42426,7 +43394,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 246 /* LabeledStatement */) { + while (label && node.parent.kind === 248 /* LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -42477,12 +43445,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 240 /* ForOfStatement */) { + if (node.kind === 242 /* ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 251 /* VariableDeclarationList */) { + if (node.initializer.kind !== 253 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -42504,7 +43472,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 243 /* ReturnStatement */) { + if (node.kind === 245 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -42521,7 +43489,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 242 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 244 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -42626,7 +43594,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 286 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 288 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -42674,9 +43642,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or LHS of comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 204 /* CallExpression */) { + if (node.kind === 206 /* CallExpression */) { var call = node; - if (call.expression.kind !== 105 /* SuperKeyword */ && ts.isDottedName(call.expression)) { + if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -42700,7 +43668,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 217 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { + if (node.kind === 219 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -42711,10 +43679,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); } - else if (node.kind === 200 /* ArrayLiteralExpression */) { + else if (node.kind === 202 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 221 /* SpreadElement */) { + if (e.kind === 223 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -42722,16 +43690,16 @@ var ts; } } } - else if (node.kind === 201 /* ObjectLiteralExpression */) { + else if (node.kind === 203 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 289 /* PropertyAssignment */) { + if (p.kind === 291 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 290 /* ShorthandPropertyAssignment */) { + else if (p.kind === 292 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 291 /* SpreadAssignment */) { + else if (p.kind === 293 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -42739,7 +43707,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 75 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -42863,7 +43831,7 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 62 /* EqualsToken */ && node.left.kind === 203 /* ElementAccessExpression */) { + if (operator === 63 /* EqualsToken */ && node.left.kind === 205 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -42891,7 +43859,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 202 /* PropertyAccessExpression */) { + if (node.expression.kind === 204 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -42947,16 +43915,20 @@ var ts; } } function bindJSDocTypeAlias(node) { - ts.setParent(node.tagName, node); - if (node.kind !== 329 /* JSDocEnumTag */ && node.fullName) { + bind(node.tagName); + if (node.kind !== 334 /* JSDocEnumTag */ && node.fullName) { + // don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); } + if (typeof node.comment !== "string") { + bindEach(node.comment); + } } function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 166 /* MethodDeclaration */) { + if (host && host.kind !== 167 /* MethodDeclaration */) { addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } } @@ -42969,15 +43941,15 @@ var ts; } function bindOptionalChainRest(node) { switch (node.kind) { - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 204 /* CallExpression */: + case 206 /* CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -43042,19 +44014,19 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 209 /* FunctionExpression */ || expr.kind === 210 /* ArrowFunction */) { + if (expr.kind === 211 /* FunctionExpression */ || expr.kind === 212 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 202 /* PropertyAccessExpression */) { + if (node.expression.kind === 204 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -43063,54 +44035,55 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 222 /* ClassExpression */: - case 253 /* ClassDeclaration */: - case 256 /* EnumDeclaration */: - case 201 /* ObjectLiteralExpression */: - case 178 /* TypeLiteral */: - case 314 /* JSDocTypeLiteral */: - case 282 /* JsxAttributes */: + case 224 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 258 /* EnumDeclaration */: + case 203 /* ObjectLiteralExpression */: + case 180 /* TypeLiteral */: + case 317 /* JSDocTypeLiteral */: + case 284 /* JsxAttributes */: return 1 /* IsContainer */; - case 254 /* InterfaceDeclaration */: + case 256 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 257 /* ModuleDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 191 /* MappedType */: + case 259 /* ModuleDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 193 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 298 /* SourceFile */: + case 300 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 167 /* Constructor */: - case 252 /* FunctionDeclaration */: - case 165 /* MethodSignature */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 170 /* CallSignature */: - case 315 /* JSDocSignature */: - case 309 /* JSDocFunctionType */: - case 175 /* FunctionType */: - case 171 /* ConstructSignature */: - case 172 /* IndexSignature */: - case 176 /* ConstructorType */: + case 169 /* Constructor */: + case 254 /* FunctionDeclaration */: + case 166 /* MethodSignature */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 172 /* CallSignature */: + case 318 /* JSDocSignature */: + case 312 /* JSDocFunctionType */: + case 177 /* FunctionType */: + case 173 /* ConstructSignature */: + case 174 /* IndexSignature */: + case 178 /* ConstructorType */: + case 168 /* ClassStaticBlockDeclaration */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 258 /* ModuleBlock */: + case 260 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 288 /* CatchClause */: - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 259 /* CaseBlock */: + case 290 /* CatchClause */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 261 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 231 /* Block */: + case 233 /* 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. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -43127,7 +44100,7 @@ var ts; // By not creating a new block-scoped-container here, we ensure that both 'var x' // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. - return ts.isFunctionLike(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; } return 0 /* None */; } @@ -43143,45 +44116,46 @@ 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 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 298 /* SourceFile */: + case 300 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 222 /* ClassExpression */: - case 253 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 255 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 178 /* TypeLiteral */: - case 314 /* JSDocTypeLiteral */: - case 201 /* ObjectLiteralExpression */: - case 254 /* InterfaceDeclaration */: - case 282 /* JsxAttributes */: + case 180 /* TypeLiteral */: + case 317 /* JSDocTypeLiteral */: + case 203 /* ObjectLiteralExpression */: + case 256 /* InterfaceDeclaration */: + case 284 /* JsxAttributes */: // 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 175 /* FunctionType */: - case 176 /* ConstructorType */: - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 315 /* JSDocSignature */: - case 172 /* IndexSignature */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 309 /* JSDocFunctionType */: - case 335 /* JSDocTypedefTag */: - case 328 /* JSDocCallbackTag */: - case 255 /* TypeAliasDeclaration */: - case 191 /* MappedType */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 318 /* JSDocSignature */: + case 174 /* IndexSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 312 /* JSDocFunctionType */: + case 340 /* JSDocTypedefTag */: + case 333 /* JSDocCallbackTag */: + case 168 /* ClassStaticBlockDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 193 /* MappedType */: // 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 @@ -43192,7 +44166,7 @@ var ts; } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return ts.hasSyntacticModifier(node, 32 /* Static */) + return ts.isStatic(node) ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -43228,15 +44202,13 @@ var ts; var pattern = void 0; if (node.name.kind === 10 /* StringLiteral */) { var text = node.name.text; - if (ts.hasZeroOrOneAsteriskCharacter(text)) { - pattern = ts.tryParsePattern(text); - } - else { + pattern = ts.tryParsePattern(text); + if (pattern === undefined) { errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); } } var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */); - file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol }); + file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { @@ -43282,7 +44254,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 291 /* SpreadAssignment */ || prop.name.kind !== 78 /* Identifier */) { + if (prop.kind === 293 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { continue; } var identifier = prop.name; @@ -43294,7 +44266,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 === 289 /* PropertyAssignment */ || prop.kind === 290 /* ShorthandPropertyAssignment */ || prop.kind === 166 /* MethodDeclaration */ + var currentKind = prop.kind === 291 /* PropertyAssignment */ || prop.kind === 292 /* ShorthandPropertyAssignment */ || prop.kind === 167 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -43326,10 +44298,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 298 /* SourceFile */: + case 300 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -43397,7 +44369,7 @@ var ts; container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 78 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } @@ -43422,11 +44394,11 @@ var ts; !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 124 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 130 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 131 /* AwaitKeyword */) { if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); } @@ -43434,7 +44406,7 @@ var ts; file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } - else if (node.originalKeywordKind === 124 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -43476,7 +44448,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 78 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* 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); @@ -43487,7 +44459,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 78 /* Identifier */) { + if (name && name.kind === 79 /* 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 @@ -43501,7 +44473,7 @@ var ts; // Provide specialized messages to help the user understand why we think they're in // strict mode. if (ts.getContainingClass(node)) { - return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; + return ts.Diagnostics.Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode; } if (file.externalModuleIndicator) { return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; @@ -43528,9 +44500,9 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 298 /* SourceFile */ && - blockScopeContainer.kind !== 257 /* ModuleDeclaration */ && - !ts.isFunctionLike(blockScopeContainer)) { + if (blockScopeContainer.kind !== 300 /* SourceFile */ && + blockScopeContainer.kind !== 259 /* ModuleDeclaration */ && + !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. var errorSpan = ts.getErrorSpanForNode(file, node); @@ -43624,7 +44596,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 157 /* LastToken */) { + if (node.kind > 158 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -43686,7 +44658,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 78 /* Identifier */: + case 79 /* Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -43699,24 +44671,24 @@ var ts; break; } // falls through - case 107 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 290 /* ShorthandPropertyAssignment */)) { + case 108 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 292 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 158 /* QualifiedName */: - if (currentFlow && parent.kind === 177 /* TypeQuery */) { + case 159 /* QualifiedName */: + if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 227 /* MetaProperty */: - case 105 /* SuperKeyword */: + case 229 /* MetaProperty */: + case 106 /* SuperKeyword */: node.flowNode = currentFlow; break; - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return checkPrivateIdentifier(node); - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -43731,7 +44703,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -43767,78 +44739,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 288 /* CatchClause */: + case 290 /* CatchClause */: return checkStrictModeCatchClause(node); - case 211 /* DeleteExpression */: + case 213 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 216 /* PostfixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 244 /* WithStatement */: + case 246 /* WithStatement */: return checkStrictModeWithStatement(node); - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 188 /* ThisType */: + case 190 /* ThisType */: seenThisKeyword = true; return; - case 173 /* TypePredicate */: + case 175 /* TypePredicate */: break; // Binding the children will handle everything - case 160 /* TypeParameter */: + case 161 /* TypeParameter */: return bindTypeParameter(node); - case 161 /* Parameter */: + case 162 /* Parameter */: return bindParameter(node); - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 199 /* BindingElement */: + case 201 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return bindPropertyWorker(node); - case 289 /* PropertyAssignment */: - case 290 /* ShorthandPropertyAssignment */: + case 291 /* PropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 292 /* EnumMember */: + case 294 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 172 /* IndexSignature */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 174 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* 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 ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 167 /* Constructor */: + case 169 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 168 /* GetAccessor */: + case 170 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 169 /* SetAccessor */: + case 171 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 175 /* FunctionType */: - case 309 /* JSDocFunctionType */: - case 315 /* JSDocSignature */: - case 176 /* ConstructorType */: + case 177 /* FunctionType */: + case 312 /* JSDocFunctionType */: + case 318 /* JSDocSignature */: + case 178 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 178 /* TypeLiteral */: - case 314 /* JSDocTypeLiteral */: - case 191 /* MappedType */: + case 180 /* TypeLiteral */: + case 317 /* JSDocTypeLiteral */: + case 193 /* MappedType */: return bindAnonymousTypeWorker(node); - case 322 /* JSDocClassTag */: + case 327 /* JSDocClassTag */: return bindJSDocClassTag(node); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: return bindFunctionExpression(node); - case 204 /* CallExpression */: + case 206 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -43857,65 +44829,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 222 /* ClassExpression */: - case 253 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 255 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 254 /* InterfaceDeclaration */: + case 256 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 255 /* TypeAliasDeclaration */: + case 257 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 282 /* JsxAttributes */: + case 284 /* JsxAttributes */: return bindJsxAttributes(node); - case 281 /* JsxAttribute */: + case 283 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 261 /* ImportEqualsDeclaration */: - case 264 /* NamespaceImport */: - case 266 /* ImportSpecifier */: - case 271 /* ExportSpecifier */: + case 263 /* ImportEqualsDeclaration */: + case 266 /* NamespaceImport */: + case 268 /* ImportSpecifier */: + case 273 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 260 /* NamespaceExportDeclaration */: + case 262 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 263 /* ImportClause */: + case 265 /* ImportClause */: return bindImportClause(node); - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: return bindExportDeclaration(node); - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: return bindExportAssignment(node); - case 298 /* SourceFile */: + case 300 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 231 /* Block */: - if (!ts.isFunctionLike(node.parent)) { + case 233 /* Block */: + if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 258 /* ModuleBlock */: + case 260 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 330 /* JSDocParameterTag */: - if (node.parent.kind === 315 /* JSDocSignature */) { + case 335 /* JSDocParameterTag */: + if (node.parent.kind === 318 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 314 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 317 /* JSDocTypeLiteral */) { break; } // falls through - case 337 /* JSDocPropertyTag */: + case 342 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 308 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 311 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 335 /* JSDocTypedefTag */: - case 328 /* JSDocCallbackTag */: - case 329 /* JSDocEnumTag */: + case 340 /* JSDocTypedefTag */: + case 333 /* JSDocCallbackTag */: + case 334 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -44078,11 +45050,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -44093,7 +45065,7 @@ var ts; constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur if (ts.hasDynamicName(node)) { - bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); } else { declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); @@ -44101,23 +45073,23 @@ var ts; addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 167 /* Constructor */: - case 164 /* PropertyDeclaration */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 169 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; - var symbolTable = ts.hasSyntacticModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; + var symbolTable = ts.isStatic(thisContainer) ? containingClass.symbol.exports : containingClass.symbol.members; if (ts.hasDynamicName(node)) { - bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); } else { declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); } break; - case 298 /* SourceFile */: + case 300 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; @@ -44133,8 +45105,8 @@ var ts; ts.Debug.failBadSyntaxKind(thisContainer); } } - function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { - bindAnonymousDeclaration(node, 4 /* Property */, "__computed" /* Computed */); + function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) { + declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); addLateBoundAssignmentDeclarationToSymbol(node, symbol); } function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { @@ -44143,10 +45115,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 107 /* ThisKeyword */) { + if (node.expression.kind === 108 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 298 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 300 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -44186,7 +45158,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 298 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 300 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -44295,8 +45267,8 @@ var ts; } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 298 /* SourceFile */ - : propertyAccess.parent.parent.kind === 298 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 300 /* SourceFile */ + : propertyAccess.parent.parent.kind === 300 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -44375,7 +45347,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 253 /* ClassDeclaration */) { + if (node.kind === 255 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -44441,7 +45413,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 330 /* JSDocParameterTag */ && container.kind !== 315 /* JSDocSignature */) { + if (node.kind === 335 /* JSDocParameterTag */ && container.kind !== 318 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { @@ -44518,7 +45490,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 186 /* InferType */) { + else if (node.parent.kind === 188 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -44546,11 +45518,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 232 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 234 /* EmptyStatement */) || // report error on class declarations - node.kind === 253 /* ClassDeclaration */ || + node.kind === 255 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 257 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 259 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -44594,12 +45566,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: return true; - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: return ts.hasSyntacticModifier(s, 2048 /* Const */); default: return false; @@ -44643,7 +45615,7 @@ var ts; /** @internal */ var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -44758,22 +45730,22 @@ var ts; visitType(interfaceT.thisType); } function visitObjectType(type) { - var stringIndexType = getIndexTypeOfStructuredType(type, 0 /* String */); - visitType(stringIndexType); - var numberIndexType = getIndexTypeOfStructuredType(type, 1 /* Number */); - visitType(numberIndexType); - // The two checks above *should* have already resolved the type (if needed), so this should be cached var resolved = resolveStructuredTypeMembers(type); - for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { - var signature = _a[_i]; - visitSignature(signature); + for (var _i = 0, _a = resolved.indexInfos; _i < _a.length; _i++) { + var info = _a[_i]; + visitType(info.keyType); + visitType(info.type); } - for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { + for (var _b = 0, _c = resolved.callSignatures; _b < _c.length; _b++) { var signature = _c[_b]; visitSignature(signature); } - for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { - var p = _e[_d]; + for (var _d = 0, _e = resolved.constructSignatures; _d < _e.length; _d++) { + var signature = _e[_d]; + visitSignature(signature); + } + for (var _f = 0, _g = resolved.properties; _f < _g.length; _f++) { + var p = _g[_f]; visitSymbol(p); } } @@ -44799,7 +45771,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 177 /* TypeQuery */) { + if (d.type && d.type.kind === 179 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -44969,15 +45941,6 @@ var ts; CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; })(CheckMode || (CheckMode = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - AccessFlags[AccessFlags["ExpressionPosition"] = 16] = "ExpressionPosition"; - })(AccessFlags || (AccessFlags = {})); var SignatureCheckMode; (function (SignatureCheckMode) { SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback"; @@ -45131,8 +46094,10 @@ var ts; var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization"); var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); + var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16384 /* FreshLiteral */; + var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); @@ -45171,6 +46136,7 @@ var ts; getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getRecursionIdentity: getRecursionIdentity, + getUnmatchedProperties: getUnmatchedProperties, getTypeOfSymbolAtLocation: function (symbol, locationIn) { var location = ts.getParseTreeNode(locationIn); return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType; @@ -45194,9 +46160,10 @@ var ts; return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined; }, getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, - getIndexInfoOfType: getIndexInfoOfType, + getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexInfosOfType: getIndexInfosOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: getIndexTypeOfType, + getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); }, getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, getWidenedType: getWidenedType, @@ -45205,6 +46172,7 @@ var ts; return node ? getTypeFromTypeNode(node) : errorType; }, getParameterType: getTypeAtPosition, + getParameterIdentifierNameAtPosition: getParameterIdentifierNameAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getAwaitedType: function (type) { return getAwaitedType(type); }, getReturnTypeOfSignature: getReturnTypeOfSignature, @@ -45230,6 +46198,10 @@ var ts; // set ignoreErrors: true because any lookups invoked by the API shouldn't cause any new errors return node ? getSymbolAtLocation(node, /*ignoreErrors*/ true) : undefined; }, + getIndexInfosAtLocation: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn); + return node ? getIndexInfosAtLocation(node) : undefined; + }, getShorthandAssignmentValueSymbol: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn); return node ? getShorthandAssignmentValueSymbol(node) : undefined; @@ -45329,6 +46301,7 @@ var ts; }, getExpandedParameters: getExpandedParameters, hasEffectiveRestParameter: hasEffectiveRestParameter, + containsArgumentsReference: containsArgumentsReference, getConstantValue: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; @@ -45354,7 +46327,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments), + forEachExportAndPropertyOfModule: forEachExportAndPropertyOfModule, + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -45404,6 +46378,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestedSymbolForNonexistentModule: getSuggestedSymbolForNonexistentModule, getSuggestionForNonexistentExport: getSuggestionForNonexistentExport, + getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember, getBaseConstraintOfType: getBaseConstraintOfType, getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { @@ -45477,7 +46452,10 @@ var ts; var tupleTypes = new ts.Map(); var unionTypes = new ts.Map(); var intersectionTypes = new ts.Map(); - var literalTypes = new ts.Map(); + var stringLiteralTypes = new ts.Map(); + var numberLiteralTypes = new ts.Map(); + var bigIntLiteralTypes = new ts.Map(); + var enumLiteralTypes = new ts.Map(); var indexedAccessTypes = new ts.Map(); var templateLiteralTypes = new ts.Map(); var stringMappingTypes = new ts.Map(); @@ -45497,6 +46475,7 @@ var ts; var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 131072 /* ContainsWideningType */); var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); + var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; var nullType = createIntrinsicType(65536 /* Null */, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 131072 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); @@ -45514,12 +46493,7 @@ var ts; falseType.freshType = falseType; regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; - var booleanType = createBooleanType([regularFalseType, regularTrueType]); - // Also mark all combinations of fresh/regular booleans as "Boolean" so they print as `boolean` instead of `true | false` - // (The union is cached, so simply doing the marking here is sufficient) - createBooleanType([regularFalseType, trueType]); - createBooleanType([falseType, regularTrueType]); - createBooleanType([falseType, trueType]); + var booleanType = getUnionType([regularFalseType, regularTrueType]); var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol"); var voidType = createIntrinsicType(16384 /* Void */, "void"); var neverType = createIntrinsicType(131072 /* Never */, "never"); @@ -45528,27 +46502,28 @@ var ts; var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); + var stringOrNumberType = getUnionType([stringType, numberType]); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); - var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); + var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); - var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); + var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); emptyGenericType.instantiations = new ts.Map(); - var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. anyFunctionType.objectFlags |= 524288 /* NonInferrableType */; - var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); + var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); + var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var markerSuperType = createTypeParameter(); var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; @@ -45558,7 +46533,7 @@ var ts; var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); + var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true); var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances var noIterationTypes = { get yieldType() { return ts.Debug.fail("Not supported"); }, @@ -45644,6 +46619,7 @@ var ts; var deferredGlobalAsyncGeneratorType; var deferredGlobalTemplateStringsArrayType; var deferredGlobalImportMetaType; + var deferredGlobalImportMetaExpressionType; var deferredGlobalExtractSymbol; var deferredGlobalOmitSymbol; var deferredGlobalBigIntType; @@ -45656,9 +46632,9 @@ var ts; var lastFlowNode; var lastFlowNodeReachable; var flowTypeCache; - var emptyStringType = getLiteralType(""); - var zeroType = getLiteralType(0); - var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); + var emptyStringType = getStringLiteralType(""); + var zeroType = getNumberLiteralType(0); + var zeroBigIntType = getBigIntLiteralType({ negative: false, base10Value: "0" }); var resolutionTargets = []; var resolutionResults = []; var resolutionPropertyNames = []; @@ -45678,6 +46654,7 @@ var ts; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var potentialWeakMapSetCollisions = []; + var potentialReflectCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var suggestionDiagnostics = ts.createDiagnosticCollection(); @@ -45788,10 +46765,13 @@ var ts; diagnostic.skippedOn = key; return diagnostic; } - function error(location, message, arg0, arg1, arg2, arg3) { - var diagnostic = location + function createError(location, message, arg0, arg1, arg2, arg3) { + return location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + } + function error(location, message, arg0, arg1, arg2, arg3) { + var diagnostic = createError(location, message, arg0, arg1, arg2, arg3); diagnostics.add(diagnostic); return diagnostic; } @@ -45845,7 +46825,7 @@ var ts; } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = (new Symbol(flags | 33554432 /* Transient */, name)); + var symbol = new Symbol(flags | 33554432 /* Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } @@ -46124,7 +47104,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 298 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 300 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -46183,17 +47163,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 199 /* BindingElement */) { + if (declaration.kind === 201 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 199 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 201 /* BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 250 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 252 /* VariableDeclaration */), usage); } - else if (declaration.kind === 250 /* VariableDeclaration */) { + else if (declaration.kind === 252 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -46223,12 +47203,12 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 271 /* ExportSpecifier */ || (usage.parent.kind === 267 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 273 /* ExportSpecifier */ || (usage.parent.kind === 269 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 267 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 269 /* ExportAssignment */ && usage.isExportEquals) { return true; } if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { @@ -46250,9 +47230,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 233 /* VariableStatement */: - case 238 /* ForStatement */: - case 240 /* ForOfStatement */: + case 235 /* VariableStatement */: + case 240 /* ForStatement */: + case 242 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -46272,19 +47252,33 @@ var ts; if (ts.isFunctionLike(current)) { return true; } - var initializerOfProperty = current.parent && - current.parent.kind === 164 /* PropertyDeclaration */ && - current.parent.initializer === current; - if (initializerOfProperty) { - if (ts.hasSyntacticModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 166 /* MethodDeclaration */) { - return true; + if (ts.isClassStaticBlockDeclaration(current)) { + return declaration.pos < usage.pos; + } + var propertyDeclaration = ts.tryCast(current.parent, ts.isPropertyDeclaration); + if (propertyDeclaration) { + var initializerOfProperty = propertyDeclaration.initializer === current; + if (initializerOfProperty) { + if (ts.isStatic(current.parent)) { + if (declaration.kind === 167 /* MethodDeclaration */) { + return true; + } + if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { + var propName = declaration.name; + if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) { + var type = getTypeOfSymbol(getSymbolOfNode(declaration)); + var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); + if (isPropertyInitializedInStaticBlocks(propName, type, staticBlocks, declaration.parent.pos, current.pos)) { + return true; + } + } + } } - } - else { - var isDeclarationInstanceProperty = declaration.kind === 164 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); - if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { - return true; + else { + var isDeclarationInstanceProperty = declaration.kind === 165 /* PropertyDeclaration */ && !ts.isStatic(declaration); + if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { + return true; + } } } } @@ -46304,19 +47298,19 @@ var ts; return "quit"; } switch (node.kind) { - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return true; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 231 /* Block */: + case 233 /* Block */: switch (node.parent.kind) { - case 168 /* GetAccessor */: - case 166 /* MethodDeclaration */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 167 /* MethodDeclaration */: + case 171 /* SetAccessor */: return true; default: return false; @@ -46356,18 +47350,18 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 210 /* ArrowFunction */: - case 209 /* FunctionExpression */: - case 252 /* FunctionDeclaration */: - case 167 /* Constructor */: + case 212 /* ArrowFunction */: + case 211 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: + case 169 /* Constructor */: // do not descend into these return false; - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 289 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 291 /* PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { return target < 99 /* ESNext */ || !useDefineForClassFields; @@ -46394,11 +47388,11 @@ var ts; * * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters. */ - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, suggestedNameNotFoundMessage) { + function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, issueSuggestions) { if (excludeGlobals === void 0) { excludeGlobals = false; } - return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage); + return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, issueSuggestions); } - function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) { + function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, issueSuggestions) { var _a; var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location var result; @@ -46422,12 +47416,12 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 312 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 315 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 161 /* Parameter */ || - lastLocation.kind === 160 /* TypeParameter */ + lastLocation.kind === 162 /* Parameter */ || + lastLocation.kind === 161 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -46442,13 +47436,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 161 /* Parameter */ || + lastLocation.kind === 162 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 185 /* ConditionalType */) { + else if (location.kind === 187 /* ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -46463,14 +47457,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 298 /* SourceFile */: + case 300 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports || emptySymbols; - if (location.kind === 298 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 300 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -46494,7 +47488,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 271 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 270 /* NamespaceExport */))) { + (ts.getDeclarationOfKind(moduleExport, 273 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 272 /* NamespaceExport */))) { break; } } @@ -46508,19 +47502,19 @@ var ts; } } break; - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // 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 // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (!ts.hasSyntacticModifier(location, 32 /* Static */)) { + if (!ts.isStatic(location)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { @@ -46530,9 +47524,9 @@ var ts; } } break; - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! @@ -46542,7 +47536,7 @@ var ts; result = undefined; break; } - if (lastLocation && ts.hasSyntacticModifier(lastLocation, 32 /* Static */)) { + if (lastLocation && ts.isStatic(lastLocation)) { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type // parameter list is associated, with the exception of static member declarations in classes. @@ -46551,7 +47545,7 @@ var ts; } break loop; } - if (location.kind === 222 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 224 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -46559,9 +47553,9 @@ var ts; } } break; - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 93 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { @@ -46579,9 +47573,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 254 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 256 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -46589,24 +47583,24 @@ var ts; } } break; - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 166 /* MethodDeclaration */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 252 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 254 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 209 /* FunctionExpression */: + case 211 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -46619,7 +47613,7 @@ var ts; } } break; - case 162 /* Decorator */: + case 163 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -46628,7 +47622,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 === 161 /* Parameter */) { + if (location.parent && location.parent.kind === 162 /* Parameter */) { location = location.parent; } // @@ -46643,20 +47637,20 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 253 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 255 /* ClassDeclaration */)) { location = location.parent; } break; - case 335 /* JSDocTypedefTag */: - case 328 /* JSDocCallbackTag */: - case 329 /* JSDocEnumTag */: + case 340 /* JSDocTypedefTag */: + case 333 /* JSDocCallbackTag */: + case 334 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 161 /* Parameter */: + case 162 /* Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -46664,7 +47658,7 @@ var ts; } } break; - case 199 /* BindingElement */: + case 201 /* BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -46672,7 +47666,7 @@ var ts; } } break; - case 186 /* InferType */: + case 188 /* InferType */: if (meaning & 262144 /* TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { @@ -46696,7 +47690,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 298 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 300 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -46723,15 +47717,18 @@ var ts; !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { var suggestion = void 0; - if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { + if (issueSuggestions && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); - var isGlobalScopeAugmentationDeclaration = suggestion && suggestion.valueDeclaration && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); + var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); if (isGlobalScopeAugmentationDeclaration) { suggestion = undefined; } if (suggestion) { var suggestionName = symbolToString(suggestion); - var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName); + var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false); + var message = isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1; + var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName); + addErrorOrSuggestion(!isUncheckedJS, diagnostic); if (suggestion.valueDeclaration) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName)); } @@ -46825,10 +47822,10 @@ var ts; } } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 210 /* ArrowFunction */ && location.kind !== 209 /* FunctionExpression */) { + if (location.kind !== 212 /* ArrowFunction */ && location.kind !== 211 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 164 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 165 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -46841,12 +47838,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 252 /* FunctionDeclaration */: - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 256 /* EnumDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 257 /* ModuleDeclaration */: // For `namespace N { N; }` + case 254 /* FunctionDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 258 /* EnumDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 259 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -46859,7 +47856,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 160 /* TypeParameter */) { + if (decl.kind === 161 /* TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -46889,7 +47886,7 @@ var ts; } // No static member is present. // Check if we're in an instance method and look for a relevant instance member. - if (location === container && !ts.hasSyntacticModifier(location, 32 /* Static */)) { + if (location === container && !ts.isStatic(location)) { var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; // TODO: GH#18217 if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg)); @@ -46915,10 +47912,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 78 /* Identifier */: - case 202 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 204 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -46962,7 +47959,7 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 271 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 273 /* ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } @@ -47038,7 +48035,7 @@ var ts; return; } // Block-scoped variables cannot be used before their definition - var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 256 /* EnumDeclaration */); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 258 /* EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -47073,13 +48070,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return node; - case 263 /* ImportClause */: + case 265 /* ImportClause */: return node.parent; - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: return node.parent.parent; - case 266 /* ImportSpecifier */: + case 268 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -47104,22 +48101,22 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 261 /* ImportEqualsDeclaration */ - || node.kind === 260 /* NamespaceExportDeclaration */ - || node.kind === 263 /* ImportClause */ && !!node.name - || node.kind === 264 /* NamespaceImport */ - || node.kind === 270 /* NamespaceExport */ - || node.kind === 266 /* ImportSpecifier */ - || node.kind === 271 /* ExportSpecifier */ - || node.kind === 267 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + return node.kind === 263 /* ImportEqualsDeclaration */ + || node.kind === 262 /* NamespaceExportDeclaration */ + || node.kind === 265 /* ImportClause */ && !!node.name + || node.kind === 266 /* NamespaceImport */ + || node.kind === 272 /* NamespaceExport */ + || node.kind === 268 /* ImportSpecifier */ + || node.kind === 273 /* ExportSpecifier */ + || node.kind === 269 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 62 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 290 /* ShorthandPropertyAssignment */ - || node.kind === 289 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 292 /* ShorthandPropertyAssignment */ + || node.kind === 291 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) || ts.isRequireVariableDeclaration(node); } function isAliasableOrJsExpression(e) { @@ -47133,7 +48130,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 273 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 275 /* ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -47399,7 +48396,7 @@ var ts; if (localSymbol.declarations) { ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); - }))); + }), false)); } } } @@ -47479,7 +48476,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -47487,31 +48484,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 261 /* ImportEqualsDeclaration */: - case 250 /* VariableDeclaration */: + case 263 /* ImportEqualsDeclaration */: + case 252 /* VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 263 /* ImportClause */: + case 265 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 270 /* NamespaceExport */: + case 272 /* NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 266 /* ImportSpecifier */: - case 199 /* BindingElement */: + case 268 /* ImportSpecifier */: + case 201 /* BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 271 /* ExportSpecifier */: + case 273 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 267 /* ExportAssignment */: - case 217 /* BinaryExpression */: + case 269 /* ExportAssignment */: + case 219 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 260 /* NamespaceExportDeclaration */: + case 262 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 203 /* ElementAccessExpression */: - case 202 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -47659,17 +48656,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 78 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 78 /* Identifier */ || entityName.parent.kind === 158 /* QualifiedName */) { + if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 159 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 261 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 263 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -47685,7 +48682,7 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true)); @@ -47693,9 +48690,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 158 /* QualifiedName */ || name.kind === 202 /* PropertyAccessExpression */) { - var left = name.kind === 158 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 158 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 159 /* QualifiedName */ || name.kind === 204 /* PropertyAccessExpression */) { + var left = name.kind === 159 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 159 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -47734,7 +48731,7 @@ var ts; throw ts.Debug.assertNever(name, "Unknown entity name kind."); } ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 267 /* ExportAssignment */)) { + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 269 /* ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -47971,7 +48968,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 298 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 300 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -48004,7 +49001,7 @@ var ts; if (symbol.exports) result.exports = new ts.Map(symbol.exports); var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above - result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.stringIndexInfo, resolvedModuleType.numberIndexInfo); + result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos); return result; } } @@ -48029,6 +49026,23 @@ var ts; } return exports; } + function forEachExportAndPropertyOfModule(moduleSymbol, cb) { + var exports = getExportsOfModule(moduleSymbol); + exports.forEach(function (symbol, key) { + if (!isReservedMemberName(key)) { + cb(symbol, key); + } + }); + var exportEquals = resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) { + var type = getTypeOfSymbol(exportEquals); + if (shouldTreatPropertiesOfExternalModuleAsExports(type)) { + getPropertiesOfType(type).forEach(function (symbol) { + cb(symbol, symbol.escapedName); + }); + } + } + } function tryGetMemberInModuleExports(memberName, moduleSymbol) { var symbolTable = getExportsOfModule(moduleSymbol); if (symbolTable) { @@ -48217,7 +49231,7 @@ var ts; } }); }) : undefined; - var res = firstVariableMatch ? __spreadArray(__spreadArray([firstVariableMatch], additionalContainers), [container]) : __spreadArray(__spreadArray([], additionalContainers), [container]); + var res = firstVariableMatch ? __spreadArray(__spreadArray([firstVariableMatch], additionalContainers, true), [container], false) : __spreadArray(__spreadArray([], additionalContainers, true), [container], false); res = ts.append(res, objectLiteralContainer); res = ts.addRange(res, reexportContainers); return res; @@ -48226,7 +49240,7 @@ var ts; if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { return getSymbolOfNode(d.parent); } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { return getSymbolOfNode(ts.getSourceFileOfNode(d)); } @@ -48298,7 +49312,7 @@ var ts; var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 167 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 169 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -48322,12 +49336,6 @@ var ts; type.objectFlags = objectFlags; return type; } - function createBooleanType(trueFalseTypes) { - var type = getUnionType(trueFalseTypes); - type.flags |= 16 /* Boolean */; - type.intrinsicName = "boolean"; - return type; - } function createObjectType(objectFlags, symbol) { var type = createType(524288 /* Object */); type.objectFlags = objectFlags; @@ -48336,12 +49344,11 @@ var ts; type.properties = undefined; type.callSignatures = undefined; type.constructSignatures = undefined; - type.stringIndexInfo = undefined; - type.numberIndexInfo = undefined; + type.indexInfos = undefined; return type; } function createTypeofType() { - return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getLiteralType)); + return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { var type = createType(262144 /* TypeParameter */); @@ -48374,21 +49381,20 @@ var ts; var index = getIndexSymbolFromSymbolTable(members); return index ? ts.concatenate(result, [index]) : result; } - function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { + function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos) { var resolved = type; resolved.members = members; resolved.properties = ts.emptyArray; resolved.callSignatures = callSignatures; resolved.constructSignatures = constructSignatures; - resolved.stringIndexInfo = stringIndexInfo; - resolved.numberIndexInfo = numberIndexInfo; + resolved.indexInfos = indexInfos; // This can loop back to getPropertyOfType() which would crash if `callSignatures` & `constructSignatures` are not initialized. if (members !== emptySymbols) resolved.properties = getNamedMembers(members); return resolved; } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) { + return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); } function getResolvedTypeWithoutAbstractConstructSignatures(type) { if (type.constructSignatures.length === 0) @@ -48398,7 +49404,7 @@ var ts; var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); }); if (type.constructSignatures === constructSignatures) return type; - var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.stringIndexInfo, type.numberIndexInfo); + var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos); type.objectTypeWithoutAbstractConstructSignatures = typeCopy; typeCopy.objectTypeWithoutAbstractConstructSignatures = typeCopy; return typeCopy; @@ -48408,28 +49414,28 @@ var ts; var _loop_8 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { - if (result = callback(location.locals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true)) { + if (result = callback(location.locals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } } switch (location.kind) { - case 298 /* SourceFile */: + case 300 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred // to one another anyway) - if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true)) { + if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } break; - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -48444,7 +49450,7 @@ var ts; (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); - if (table_1 && (result = callback(table_1))) { + if (table_1 && (result = callback(table_1, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ false, location))) { return { value: result }; } break; @@ -48466,12 +49472,22 @@ var ts; if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { return undefined; } + var links = getSymbolLinks(symbol); + var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); + // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more + var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); + var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + if (cache.has(key)) { + return cache.get(key); + } var id = getSymbolId(symbol); var visitedSymbolTables = visitedSymbolTablesMap.get(id); if (!visitedSymbolTables) { visitedSymbolTablesMap.set(id, visitedSymbolTables = []); } - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + var result = forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + cache.set(key, result); + return result; /** * @param {ignoreQualification} boolean Set when a symbol is being looked for through the exports of another symbol (meaning we have a route to qualify it already) */ @@ -48514,7 +49530,7 @@ var ts; && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 271 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 273 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -48558,7 +49574,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 271 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 273 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -48573,10 +49589,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 164 /* PropertyDeclaration */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: continue; default: return false; @@ -48706,14 +49722,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 298 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 300 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 298 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 300 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 78 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -48765,14 +49781,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 177 /* TypeQuery */ || + if (entityName.parent.kind === 179 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 159 /* ComputedPropertyName */) { + entityName.parent.kind === 160 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 158 /* QualifiedName */ || entityName.kind === 202 /* PropertyAccessExpression */ || - entityName.parent.kind === 261 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 159 /* QualifiedName */ || entityName.kind === 204 /* PropertyAccessExpression */ || + entityName.parent.kind === 263 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -48813,7 +49829,7 @@ var ts; function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 298 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 300 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; @@ -48825,10 +49841,10 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 176 /* ConstructorType */ : 175 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 178 /* ConstructorType */ : 177 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 171 /* ConstructSignature */ : 170 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 173 /* ConstructSignature */ : 172 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -48882,8 +49898,8 @@ var ts; typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); }); }, - indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) { - return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, /*typeNode*/ undefined); }); + indexInfoToIndexSignatureDeclaration: function (indexInfo, enclosingDeclaration, flags, tracker) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, context, /*typeNode*/ undefined); }); }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); }); @@ -48914,9 +49930,8 @@ var ts; enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, - getSourceFiles: function () { return host.getSourceFiles(); }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache), useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), @@ -48927,17 +49942,46 @@ var ts; getFileIncludeReasons: function () { return host.getFileIncludeReasons(); }, } : undefined }, encounteredError: false, + reportedDiagnostic: false, visitedTypes: undefined, symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); if (context.truncating && context.flags & 1 /* NoTruncation */) { (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); } return context.encounteredError ? undefined : resultingNode; } + function wrapSymbolTrackerToReportForContext(context, tracker) { + var oldTrackSymbol = tracker.trackSymbol; + return __assign(__assign({}, tracker), { reportCyclicStructureError: wrapReportedDiagnostic(tracker.reportCyclicStructureError), reportInaccessibleThisError: wrapReportedDiagnostic(tracker.reportInaccessibleThisError), reportInaccessibleUniqueSymbolError: wrapReportedDiagnostic(tracker.reportInaccessibleUniqueSymbolError), reportLikelyUnsafeImportRequiredError: wrapReportedDiagnostic(tracker.reportLikelyUnsafeImportRequiredError), reportNonlocalAugmentation: wrapReportedDiagnostic(tracker.reportNonlocalAugmentation), reportPrivateInBaseOfClassExpression: wrapReportedDiagnostic(tracker.reportPrivateInBaseOfClassExpression), reportNonSerializableProperty: wrapReportedDiagnostic(tracker.reportNonSerializableProperty), trackSymbol: oldTrackSymbol && (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = oldTrackSymbol.apply(void 0, args); + if (result) { + context.reportedDiagnostic = true; + } + return result; + }) }); + function wrapReportedDiagnostic(method) { + if (!method) { + return method; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + context.reportedDiagnostic = true; + return method.apply(void 0, args); + }); + } + } function checkTruncationLength(context) { if (context.truncating) return context.truncating; @@ -48955,33 +49999,33 @@ var ts; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (!(context.flags & 536870912 /* NoTypeReduction */)) { type = getReducedType(type); } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 136 /* IntrinsicKeyword */ : 128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 137 /* IntrinsicKeyword */ : 129 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(148 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(144 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(145 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(155 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(156 /* BigIntKeyword */); } - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(131 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(132 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -49035,15 +50079,15 @@ var ts; } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(151 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(152 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(113 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; @@ -49051,15 +50095,15 @@ var ts; } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(141 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(142 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(145 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(146 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -49129,7 +50173,7 @@ var ts; var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, indexTypeNode); } if (type.flags & 134217728 /* TemplateLiteral */) { var texts_1 = type.texts; @@ -49150,6 +50194,13 @@ var ts; return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } if (type.flags & 16777216 /* Conditional */) { + return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); }); + } + if (type.flags & 33554432 /* Substitution */) { + return typeToTypeNodeHelper(type.baseType, context); + } + return ts.Debug.fail("Should be unreachable."); + function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -49160,10 +50211,6 @@ var ts; context.approximateLength += 15; return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 33554432 /* Substitution */) { - return typeToTypeNodeHelper(type.baseType, context); - } - return ts.Debug.fail("Should be unreachable."); function typeToTypeNodeOrCircularityElision(type) { var _a, _b, _c; if (type.flags & 1048576 /* Union */) { @@ -49186,14 +50233,14 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; - var templateTypeNode = typeToTypeNodeHelper(getTemplateTypeFromMappedType(type), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode); context.approximateLength += 10; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); @@ -49211,7 +50258,7 @@ var ts; // Always use 'typeof T' for type of class, enum, and module objects else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 222 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 224 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); @@ -49238,11 +50285,11 @@ var ts; function shouldWriteTypeOfFunctionSymbol() { var _a; var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method - ts.some(symbol.declarations, function (declaration) { return ts.hasSyntacticModifier(declaration, 32 /* Static */); }); + ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); }); var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 298 /* SourceFile */ || declaration.parent.kind === 258 /* ModuleBlock */; + return declaration.parent.kind === 300 /* SourceFile */ || declaration.parent.kind === 260 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -49252,11 +50299,13 @@ var ts; } } function visitAndTransformType(type, transform) { + var _a, _b; var typeId = type.id; var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : - type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : - undefined; + type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead // of types allows us to catch circular references to instantiations of the same anonymous type if (!context.visitedTypes) { @@ -49265,6 +50314,19 @@ var ts; if (id && !context.symbolDepth) { context.symbolDepth = new ts.Map(); } + var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); + var key = getTypeId(type) + "|" + context.flags; + if (links) { + links.serializedTypes || (links.serializedTypes = new ts.Map()); + } + var cachedResult = (_a = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _a === void 0 ? void 0 : _a.get(key); + if (cachedResult) { + if (cachedResult.truncating) { + context.truncating = true; + } + context.approximateLength += cachedResult.addedLength; + return deepCloneOrReuseNode(cachedResult); + } var depth; if (id) { depth = context.symbolDepth.get(id) || 0; @@ -49274,31 +50336,46 @@ var ts; context.symbolDepth.set(id, depth + 1); } context.visitedTypes.add(typeId); + var startLength = context.approximateLength; var result = transform(type); + var addedLength = context.approximateLength - startLength; + if (!context.reportedDiagnostic && !context.encounteredError) { + if (context.truncating) { + result.truncating = true; + } + result.addedLength = addedLength; + (_b = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _b === void 0 ? void 0 : _b.set(key, result); + } context.visitedTypes.delete(typeId); if (id) { context.symbolDepth.set(id, depth); } return result; + function deepCloneOrReuseNode(node) { + if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) { + return node; + } + return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node); + } } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type) || type.containsError) { return createMappedTypeNodeFromType(type); } var resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { context.approximateLength += 2; return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 175 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 177 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 176 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 178 /* ConstructorType */, context); return signatureNode; } } @@ -49308,8 +50385,7 @@ var ts; // count the number of type elements excluding abstract constructors var typeElementCount = resolved.callSignatures.length + (resolved.constructSignatures.length - abstractSignatures.length) + - (resolved.stringIndexInfo ? 1 : 0) + - (resolved.numberIndexInfo ? 1 : 0) + + resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per // the logic in `createTypeNodesFromResolvedType`. (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? @@ -49342,9 +50418,10 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(143 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -49366,12 +50443,12 @@ var ts; } } var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -49478,34 +50555,25 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 170 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 172 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; if (signature.flags & 4 /* Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 171 /* ConstructSignature */, context)); - } - if (resolvedType.stringIndexInfo) { - var indexSignature = void 0; - if (resolvedType.objectFlags & 1024 /* ReverseMapped */) { - indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0 /* String */, context, createElidedInformationPlaceholder(context)); - } - else { - indexSignature = indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0 /* String */, context, /*typeNode*/ undefined); - } - typeElements.push(indexSignature); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 173 /* ConstructSignature */, context)); } - if (resolvedType.numberIndexInfo) { - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1 /* Number */, context, /*typeNode*/ undefined)); + for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { + var info = _e[_d]; + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); } var properties = resolvedType.properties; if (!properties) { return typeElements; } var i = 0; - for (var _d = 0, properties_1 = properties; _d < properties_1.length; _d++) { - var propertySymbol = properties_1[_d]; + for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) { + var propertySymbol = properties_1[_f]; i++; if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) { if (propertySymbol.flags & 4194304 /* Prototype */) { @@ -49530,7 +50598,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -49546,27 +50614,32 @@ var ts; && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { - var _a; + var _a, _b; var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? - anyType : getTypeOfSymbol(propertySymbol); + anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { - var decl = ts.first(propertySymbol.declarations); - if (propertySymbol.declarations && hasLateBindableName(decl)) { - if (ts.isBinaryExpression(decl)) { - var name = ts.getNameOfDeclaration(decl); - if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { - trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + if (propertySymbol.declarations) { + var decl = ts.first(propertySymbol.declarations); + if (hasLateBindableName(decl)) { + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); } - } - else { - trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); } } + else if ((_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportNonSerializableProperty) { + context.tracker.reportNonSerializableProperty(symbolToString(propertySymbol)); + } } - context.enclosingDeclaration = propertySymbol.valueDeclaration || ((_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) || saveEnclosingDeclaration; + context.enclosingDeclaration = propertySymbol.valueDeclaration || ((_b = propertySymbol.declarations) === null || _b === void 0 ? void 0 : _b[0]) || saveEnclosingDeclaration; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); @@ -49575,7 +50648,7 @@ var ts; var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 165 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 166 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -49589,12 +50662,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -49603,8 +50676,8 @@ var ts; } function preserveCommentsOn(node) { var _a; - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 337 /* JSDocPropertyTag */; })) { - var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 337 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 342 /* JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 342 /* JSDocPropertyTag */; }); var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); @@ -49688,9 +50761,9 @@ var ts; || !!a.symbol && a.symbol === b.symbol || !!a.aliasSymbol && a.aliasSymbol === b.aliasSymbol; } - function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, typeNode) { + function indexInfoToIndexSignatureDeclarationHelper(indexInfo, context, typeNode) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 147 /* StringKeyword */ : 144 /* NumberKeyword */); + var indexerTypeNode = typeToTypeNodeHelper(indexInfo.keyType, context); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -49705,13 +50778,14 @@ var ts; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; if (suppressAny) context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s + context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum var typeParameters; var typeArguments; if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { @@ -49722,7 +50796,7 @@ var ts; } var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; // If the expanded parameter list had a variadic in a non-trailing position, don't expand it - var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 167 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 169 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -49731,7 +50805,7 @@ var ts; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(127 /* AssertsKeyword */) : + ts.factory.createToken(128 /* AssertsKeyword */) : undefined; var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : @@ -49745,29 +50819,28 @@ var ts; returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); } else if (!suppressAny) { - returnTypeNode = ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 176 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 178 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { var flags = ts.modifiersToFlags(modifiers); modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); } - context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum - var node = kind === 170 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 171 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 165 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 166 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 167 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 168 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 169 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 172 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 309 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 175 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 176 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 252 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 209 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 210 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + var node = kind === 172 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 173 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 166 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 167 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 169 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 170 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 171 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 174 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 312 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 177 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 178 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 254 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 211 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 212 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -49789,9 +50862,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 161 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 162 /* Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 330 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 335 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -49805,8 +50878,8 @@ var ts; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 78 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 158 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 159 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -49971,11 +51044,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context) { var _a; - var file = ts.getDeclarationOfKind(symbol, 298 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 300 /* SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 298 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 300 /* SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -50127,7 +51200,7 @@ var ts; return false; } function typeParameterToName(type, context) { - var _a; + var _a, _b; if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { @@ -50135,22 +51208,25 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 78 /* Identifier */)) { + if (!(result.kind & 79 /* Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; - var i = 0; + var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; - while (((_a = context.typeParameterNamesByText) === null || _a === void 0 ? void 0 : _a.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { + while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; text = rawtext + "_" + i; } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); } + // avoiding iterations of the above loop turns out to be worth it when `i` starts to get large, so we cache the max + // `i` we've used thus far, to save work later + (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = new ts.Map())).set(rawtext, i); (context.typeParameterNames || (context.typeParameterNames = new ts.Map())).set(getTypeId(type), result); - (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(result.escapedText); + (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(rawtext); } return result; } @@ -50289,6 +51365,7 @@ var ts; if (initial.typeParameterSymbolList) { initial.typeParameterSymbolList = new ts.Set(initial.typeParameterSymbolList); } + initial.tracker = wrapSymbolTrackerToReportForContext(initial, initial.tracker); return initial; } function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { @@ -50378,17 +51455,17 @@ var ts; return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 311 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 314 /* JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -50402,11 +51479,11 @@ var ts; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; return ts.factory.createPropertySignature( - /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(128 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -50423,13 +51500,13 @@ var ts; return ts.factory.createConstructorTypeNode(node.modifiers, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } } if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { @@ -50497,8 +51574,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 166 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 165 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 167 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 166 /* MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -50519,9 +51596,11 @@ var ts; } } else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { - oldcontext.tracker.trackSymbol(sym, decl, meaning); + return oldcontext.tracker.trackSymbol(sym, decl, meaning); } + return false; } }) }); + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); ts.forEachEntry(symbolTable, function (symbol, name) { var baseName = ts.unescapeLeadingUnderscores(name); void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` @@ -50536,7 +51615,7 @@ var ts; visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 78 /* Identifier */; + return !!node && node.kind === 79 /* Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -50557,12 +51636,12 @@ var ts; var name_2 = ns.name; var body = ns.body; if (ts.length(excessExports)) { - ns = ts.factory.updateModuleDeclaration(ns, ns.decorators, ns.modifiers, ns.name, body = ts.factory.updateModuleBlock(body, ts.factory.createNodeArray(__spreadArray(__spreadArray([], ns.body.statements), [ts.factory.createExportDeclaration( + ns = ts.factory.updateModuleDeclaration(ns, ns.decorators, ns.modifiers, ns.name, body = ts.factory.updateModuleBlock(body, ts.factory.createNodeArray(__spreadArray(__spreadArray([], ns.body.statements, true), [ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.factory.createExportSpecifier(/*alias*/ undefined, id); })), - /*moduleSpecifier*/ undefined)])))); - statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, nsIndex)), [ns]), statements.slice(nsIndex + 1)); + /*moduleSpecifier*/ undefined)], false)))); + statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, nsIndex), true), [ns], false), statements.slice(nsIndex + 1), true); } // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, name_2); })) { @@ -50573,7 +51652,7 @@ var ts; ts.forEach(body.statements, function (s) { addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag }); - statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; })), results); + statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true); } } return statements; @@ -50583,11 +51662,11 @@ var ts; var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); }); if (ts.length(exports) > 1) { var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); - statements = __spreadArray(__spreadArray([], nonExports), [ts.factory.createExportDeclaration( + statements = __spreadArray(__spreadArray([], nonExports, true), [ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.flatMap(exports, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), - /*moduleSpecifier*/ undefined)]); + /*moduleSpecifier*/ undefined)], false); } // Pass 2b: Also combine all `export {} from "..."` declarations as needed var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); }); @@ -50597,12 +51676,12 @@ var ts; var _loop_9 = function (group_1) { if (group_1.length > 1) { // remove group members from statements and then merge group members and add back to statements - statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; })), [ + statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), true), [ ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.flatMap(group_1, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), group_1[0].moduleSpecifier) - ]); + ], false); } }; for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { @@ -50705,6 +51784,9 @@ var ts; var oldContext = context; context = cloneNodeBuilderContext(context); var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + if (context.reportedDiagnostic) { + oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context + } context = oldContext; return result; } @@ -50953,13 +52035,13 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 170 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 171 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 172 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 173 /* ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures), constructSignatures), callSignatures), members)), modifierFlags); + /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); } function getNamespaceMembersForSerialization(symbol) { return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); @@ -51023,7 +52105,7 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 252 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 254 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports @@ -51097,7 +52179,7 @@ var ts; } function isNamespaceMember(p) { return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.getEffectiveModifierFlags(p.valueDeclaration) & 32 /* Static */ && ts.isClassLike(p.valueDeclaration.parent)); + !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); } function sanitizeJSDocImplements(clauses) { var result = ts.mapDefined(clauses, function (e) { @@ -51146,7 +52228,7 @@ var ts; var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(116 /* ImplementsKeyword */, implementsExpressions)]); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from @@ -51183,12 +52265,12 @@ var ts; !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 167 /* Constructor */); + serializeSignatures(1 /* Construct */, staticType, staticBaseType, 169 /* Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures), staticMembers), constructors), publicProperties), privateProperties)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), staticMembers, true), constructors, true), publicProperties, true), privateProperties, true)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); } function serializeAsAlias(symbol, localName, modifierFlags) { var _a, _b, _c, _d, _e; @@ -51210,8 +52292,8 @@ var ts; var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 199 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 250 /* VariableDeclaration */) { + case 201 /* BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 252 /* VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -51223,13 +52305,13 @@ var ts; // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 290 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 217 /* BinaryExpression */) { + case 292 /* ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 219 /* BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -51249,7 +52331,7 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: // This _specifically_ only exists to handle json declarations - where we make aliases, but since // we emit no declarations for the json document, must not refer to it in the declarations if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { @@ -51266,13 +52348,13 @@ var ts; ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); break; - case 260 /* NamespaceExportDeclaration */: + case 262 /* NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); break; - case 263 /* ImportClause */: + case 265 /* ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -51281,18 +52363,18 @@ var ts; // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 270 /* NamespaceExport */: + case 272 /* NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 266 /* ImportSpecifier */: + case 268 /* ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -51301,7 +52383,7 @@ var ts; ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 271 /* ExportSpecifier */: + case 273 /* ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -51309,12 +52391,12 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 217 /* BinaryExpression */: - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 219 /* BinaryExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier @@ -51369,7 +52451,7 @@ var ts; // a visibility error here (as they're not visible within any scope), but we want to hoist them // into the containing scope anyway, so we want to skip the visibility checks. var oldTrack = context.tracker.trackSymbol; - context.tracker.trackSymbol = ts.noop; + context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, @@ -51435,8 +52517,7 @@ var ts; // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && - !getIndexInfoOfType(typeToSerialize, 0 /* String */) && - !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && + !ts.length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK @@ -51574,20 +52655,17 @@ var ts; } function serializeIndexSignatures(input, baseType) { var results = []; - for (var _i = 0, _a = [0 /* String */, 1 /* Number */]; _i < _a.length; _i++) { - var type = _a[_i]; - var info = getIndexInfoOfType(input, type); - if (info) { - if (baseType) { - var baseInfo = getIndexInfoOfType(baseType, type); - if (baseInfo) { - if (isTypeIdenticalTo(info.type, baseInfo.type)) { - continue; // elide identical index signatures - } + for (var _i = 0, _a = getIndexInfosOfType(input); _i < _a.length; _i++) { + var info = _a[_i]; + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, info.keyType); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures } } - results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context, /*typeNode*/ undefined)); } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, context, /*typeNode*/ undefined)); } return results; } @@ -51684,7 +52762,7 @@ var ts; if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(127 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); @@ -51731,7 +52809,7 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 255 /* TypeAliasDeclaration */) { + if (node.kind === 257 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -51739,11 +52817,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 258 /* ModuleBlock */ && + node.parent.kind === 260 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 298 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 300 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; @@ -51802,17 +52880,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 250 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 252 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 222 /* ClassExpression */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 224 /* ClassExpression */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 222 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 224 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -51829,28 +52907,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 328 /* JSDocCallbackTag */: - case 335 /* JSDocTypedefTag */: - case 329 /* JSDocEnumTag */: + case 333 /* JSDocCallbackTag */: + case 340 /* JSDocTypedefTag */: + case 334 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 199 /* BindingElement */: + case 201 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 257 /* ModuleDeclaration */: - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 252 /* FunctionDeclaration */: - case 256 /* EnumDeclaration */: - case 261 /* ImportEqualsDeclaration */: + case 259 /* ModuleDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 254 /* FunctionDeclaration */: + case 258 /* EnumDeclaration */: + case 263 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -51858,55 +52936,55 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 261 /* ImportEqualsDeclaration */ && parent.kind !== 298 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { + !(node.kind !== 263 /* ImportEqualsDeclaration */ && parent.kind !== 300 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 167 /* Constructor */: - case 171 /* ConstructSignature */: - case 170 /* CallSignature */: - case 172 /* IndexSignature */: - case 161 /* Parameter */: - case 258 /* ModuleBlock */: - case 175 /* FunctionType */: - case 176 /* ConstructorType */: - case 178 /* TypeLiteral */: - case 174 /* TypeReference */: - case 179 /* ArrayType */: - case 180 /* TupleType */: - case 183 /* UnionType */: - case 184 /* IntersectionType */: - case 187 /* ParenthesizedType */: - case 193 /* NamedTupleMember */: + case 169 /* Constructor */: + case 173 /* ConstructSignature */: + case 172 /* CallSignature */: + case 174 /* IndexSignature */: + case 162 /* Parameter */: + case 260 /* ModuleBlock */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: + case 180 /* TypeLiteral */: + case 176 /* TypeReference */: + case 181 /* ArrayType */: + case 182 /* TupleType */: + case 185 /* UnionType */: + case 186 /* IntersectionType */: + case 189 /* ParenthesizedType */: + case 195 /* NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 263 /* ImportClause */: - case 264 /* NamespaceImport */: - case 266 /* ImportSpecifier */: + case 265 /* ImportClause */: + case 266 /* NamespaceImport */: + case 268 /* ImportSpecifier */: return false; // Type parameters are always visible - case 160 /* TypeParameter */: + case 161 /* TypeParameter */: // Source file and namespace export are always visible // falls through - case 298 /* SourceFile */: - case 260 /* NamespaceExportDeclaration */: + case 300 /* SourceFile */: + case 262 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: return false; default: return false; @@ -51915,10 +52993,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 267 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 269 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 271 /* ExportSpecifier */) { + else if (node.parent.kind === 273 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -52023,12 +53101,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 250 /* VariableDeclaration */: - case 251 /* VariableDeclarationList */: - case 266 /* ImportSpecifier */: - case 265 /* NamedImports */: - case 264 /* NamespaceImport */: - case 263 /* ImportClause */: + case 252 /* VariableDeclaration */: + case 253 /* VariableDeclarationList */: + case 268 /* ImportSpecifier */: + case 267 /* NamedImports */: + case 266 /* NamespaceImport */: + case 265 /* ImportClause */: return false; default: return true; @@ -52049,7 +53127,8 @@ var ts; return prop ? getTypeOfSymbol(prop) : undefined; } function getTypeOfPropertyOrIndexSignature(type, name) { - return getTypeOfPropertyOfType(type, name) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1 /* Number */) || getIndexTypeOfType(type, 0 /* String */) || unknownType; + var _a; + return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType; } function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; @@ -52088,9 +53167,7 @@ var ts; members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false)); } } - var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); - var numberIndexInfo = getIndexInfoOfType(source, 1 /* Number */); - var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); + var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source)); result.objectFlags |= 8388608 /* ObjectRestType */; return result; } @@ -52135,23 +53212,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 199 /* BindingElement */: - case 289 /* PropertyAssignment */: + case 201 /* BindingElement */: + case 291 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return ancestor.initializer; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 199 /* BindingElement */ && parent.kind === 197 /* ObjectBindingPattern */) { + if (node.kind === 201 /* BindingElement */ && parent.kind === 199 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 289 /* PropertyAssignment */ || node.kind === 290 /* ShorthandPropertyAssignment */) { + if (node.kind === 291 /* PropertyAssignment */ || node.kind === 292 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -52177,7 +53254,7 @@ var ts; parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); } var type; - if (pattern.kind === 197 /* ObjectBindingPattern */) { + if (pattern.kind === 199 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { @@ -52197,7 +53274,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getIndexedAccessType(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -52216,9 +53293,9 @@ var ts; createArrayType(elementType); } else if (isArrayLikeType(parentType)) { - var indexType = getLiteralType(index_2); - var accessFlags = hasDefaultValue(declaration) ? 8 /* NoTupleBoundsCheck */ : 0; - var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, declaration.name, accessFlags | 16 /* ExpressionPosition */) || errorType; + var indexType = getNumberLiteralType(index_2); + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } else { @@ -52244,25 +53321,26 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 103 /* NullKeyword */ || expr.kind === 78 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 200 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 202 /* ArrayLiteralExpression */ && expr.elements.length === 0; } - function addOptionality(type, optional) { - if (optional === void 0) { optional = true; } - return strictNullChecks && optional ? getOptionalType(type) : type; + function addOptionality(type, isProperty, isOptional) { + if (isProperty === void 0) { isProperty = false; } + if (isOptional === void 0) { isOptional = true; } + return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 240 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* 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, @@ -52273,13 +53351,14 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } - var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration) - || isOptionalJSDocPropertyLikeTag(declaration) - || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken); + var isProperty = ts.isPropertyDeclaration(declaration) || ts.isPropertySignature(declaration); + var isOptional = includeOptionality && (isProperty && !!declaration.questionToken || + ts.isParameter(declaration) && (!!declaration.questionToken || isJSDocOptionalParameter(declaration)) || + isOptionalJSDocPropertyLikeTag(declaration)); // Use type from type annotation if one is present var declaredType = tryGetTypeFromEffectiveTypeNode(declaration); if (declaredType) { - return addOptionality(declaredType, isOptional); + return addOptionality(declaredType, isProperty, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && @@ -52299,8 +53378,8 @@ var ts; if (ts.isParameter(declaration)) { 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 === 169 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 168 /* GetAccessor */); + if (func.kind === 171 /* SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 170 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -52323,7 +53402,7 @@ var ts; // Use contextual parameter type if one is available var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { - return addOptionality(type, isOptional); + return addOptionality(type, /*isProperty*/ false, isOptional); } } // Use the type of the initializer expression if one is present and the declaration is @@ -52336,16 +53415,25 @@ var ts; } } var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); - return addOptionality(type, isOptional); + return addOptionality(type, isProperty, isOptional); } - if (ts.isPropertyDeclaration(declaration) && !ts.hasStaticModifier(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { + if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. - // Use control flow analysis of this.xxx assignments in the constructor to determine the type of the property. - var constructor = findConstructorDeclaration(declaration.parent); - var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : - undefined; - return type && addOptionality(type, isOptional); + // Use control flow analysis of this.xxx assignments in the constructor or static block to determine the type of the property. + if (!ts.hasStaticModifier(declaration)) { + var constructor = findConstructorDeclaration(declaration.parent); + var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : + ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + undefined; + return type && addOptionality(type, /*isProperty*/ true, isOptional); + } + else { + var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); + var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : + ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + undefined; + return type && addOptionality(type, /*isProperty*/ true, isOptional); + } } if (ts.isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. @@ -52371,7 +53459,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 203 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 205 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -52393,7 +53481,7 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); - if (container && (container.kind === 167 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 169 /* Constructor */ || isJSConstructor(container))) { return container; } } @@ -52415,6 +53503,27 @@ var ts; reference.flowNode = file.endFlowNode; return getFlowTypeOfReference(reference, autoType, undefinedType); } + function getFlowTypeInStaticBlocks(symbol, staticBlocks) { + var accessName = ts.startsWith(symbol.escapedName, "__#") + ? ts.factory.createPrivateIdentifier(symbol.escapedName.split("@")[1]) + : ts.unescapeLeadingUnderscores(symbol.escapedName); + for (var _i = 0, staticBlocks_1 = staticBlocks; _i < staticBlocks_1.length; _i++) { + var staticBlock = staticBlocks_1[_i]; + var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), accessName); + ts.setParent(reference.expression, reference); + ts.setParent(reference, staticBlock); + reference.flowNode = staticBlock.returnFlowNode; + var flowType = getFlowTypeOfProperty(reference, symbol); + if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) { + error(symbol.valueDeclaration, ts.Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); + } + // We don't infer a type if assignments are only null or undefined. + if (everyType(flowType, isNullableType)) { + continue; + } + return convertAutoToAny(flowType); + } + } function getFlowTypeInConstructor(symbol, constructor) { var accessName = ts.startsWith(symbol.escapedName, "__#") ? ts.factory.createPrivateIdentifier(symbol.escapedName.split("@")[1]) @@ -52505,7 +53614,7 @@ var ts; type = getUnionType(sourceTypes, 2 /* Subtype */); } } - var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); + var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; @@ -52529,7 +53638,7 @@ var ts; if ((_b = s === null || s === void 0 ? void 0 : s.exports) === null || _b === void 0 ? void 0 : _b.size) { mergeSymbolTable(exports, s.exports); } - var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); type.objectFlags |= 8192 /* JSLiteral */; return type; } @@ -52548,7 +53657,10 @@ var ts; if ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) { var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration); if (typeNode_2) { - return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + var annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + if (annotationSymbol) { + return getNonMissingTypeOfSymbol(annotationSymbol); + } } } return declaredType; @@ -52630,7 +53742,7 @@ var ts; } }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type - members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); + members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos); result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type @@ -52645,16 +53757,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 107 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* ThisKeyword */ && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 167 /* Constructor */ || - thisContainer.kind === 252 /* FunctionDeclaration */ || - (thisContainer.kind === 209 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 169 /* Constructor */ || + thisContainer.kind === 254 /* FunctionDeclaration */ || + (thisContainer.kind === 211 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -52696,7 +53808,7 @@ var ts; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { - stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + stringIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false); return; } var exprType = getLiteralTypeFromPropertyName(name); @@ -52712,7 +53824,7 @@ var ts; symbol.bindingElement = e; members.set(symbol.escapedName, symbol); }); - var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); + var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo ? [stringIndexInfo] : ts.emptyArray); result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; @@ -52724,7 +53836,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 199 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 201 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -52749,7 +53861,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 197 /* ObjectBindingPattern */ + return pattern.kind === 199 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -52797,7 +53909,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 161 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 162 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -52842,7 +53954,7 @@ var ts; result.exports = new ts.Map(fileSymbol.exports); var members = ts.createSymbolTable(); members.set("exports", result); - return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined); + return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); } // Handle catch clause variables ts.Debug.assertIsDefined(symbol.valueDeclaration); @@ -52850,7 +53962,7 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); if (typeNode === undefined) { - return anyType; + return useUnknownInCatchVariables ? unknownType : anyType; } var type_1 = getTypeOfNode(typeNode); // an errorType will make `checkTryStatement` issue an error @@ -52872,7 +53984,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 267 /* ExportAssignment */) { + if (declaration.kind === 269 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -52943,7 +54055,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 168 /* GetAccessor */) { + if (accessor.kind === 170 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -52982,7 +54094,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 168 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 170 /* GetAccessor */); error(getter, 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)); } } @@ -52990,8 +54102,8 @@ var ts; } function resolveTypeOfAccessors(symbol, writing) { if (writing === void 0) { writing = false; } - var getter = ts.getDeclarationOfKind(symbol, 168 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 169 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 170 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 171 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); // For write operations, prioritize type annotations on the setter if (writing && setterType) { @@ -53068,9 +54180,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 217 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 219 /* BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 217 /* BinaryExpression */)) { + declaration.parent.kind === 219 /* BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -53139,7 +54251,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 161 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 162 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -53196,6 +54308,9 @@ var ts; } return errorType; } + function getNonMissingTypeOfSymbol(symbol) { + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + } function isReferenceToType(type, target) { return type !== undefined && target !== undefined @@ -53247,46 +54362,46 @@ var ts; return undefined; } switch (node.kind) { - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 165 /* MethodSignature */: - case 175 /* FunctionType */: - case 176 /* ConstructorType */: - case 309 /* JSDocFunctionType */: - case 252 /* FunctionDeclaration */: - case 166 /* MethodDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 255 /* TypeAliasDeclaration */: - case 334 /* JSDocTemplateTag */: - case 335 /* JSDocTypedefTag */: - case 329 /* JSDocEnumTag */: - case 328 /* JSDocCallbackTag */: - case 191 /* MappedType */: - case 185 /* ConditionalType */: { + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: + case 312 /* JSDocFunctionType */: + case 254 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 257 /* TypeAliasDeclaration */: + case 339 /* JSDocTemplateTag */: + case 340 /* JSDocTypedefTag */: + case 334 /* JSDocEnumTag */: + case 333 /* JSDocCallbackTag */: + case 193 /* MappedType */: + case 187 /* ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 191 /* MappedType */) { + if (node.kind === 193 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 185 /* ConditionalType */) { + else if (node.kind === 187 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 253 /* ClassDeclaration */ || node.kind === 222 /* ClassExpression */ || node.kind === 254 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 255 /* ClassDeclaration */ || node.kind === 224 /* ClassExpression */ || node.kind === 256 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 330 /* JSDocParameterTag */: + case 335 /* JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 312 /* JSDocComment */: { + case 315 /* JSDocComment */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -53297,7 +54412,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, 254 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 256 /* InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -53310,9 +54425,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 254 /* InterfaceDeclaration */ || - node.kind === 253 /* ClassDeclaration */ || - node.kind === 222 /* ClassExpression */ || + if (node.kind === 256 /* InterfaceDeclaration */ || + node.kind === 255 /* ClassDeclaration */ || + node.kind === 224 /* ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -53463,7 +54578,7 @@ var ts; if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 253 /* ClassDeclaration */ || declaration.kind === 254 /* InterfaceDeclaration */) { + if (declaration.kind === 255 /* ClassDeclaration */ || declaration.kind === 256 /* InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -53559,7 +54674,7 @@ var ts; if (type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 254 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 256 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -53599,7 +54714,7 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 254 /* InterfaceDeclaration */) { + if (declaration.kind === 256 /* InterfaceDeclaration */) { if (declaration.flags & 128 /* ContainsThis */) { return false; } @@ -53678,7 +54793,12 @@ var ts; } else { type = errorType; - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + if (declaration.kind === 334 /* JSDocEnumTag */) { + error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + } + else { + error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + } } links.declaredType = type; } @@ -53688,7 +54808,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 217 /* BinaryExpression */) { + else if (expr.kind === 219 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -53703,12 +54823,12 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -53723,7 +54843,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 256 /* EnumDeclaration */) { + if (declaration.kind === 258 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { @@ -53752,11 +54872,11 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 256 /* EnumDeclaration */) { + if (declaration.kind === 258 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); - var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); + var memberType = getFreshTypeOfLiteralType(getEnumLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; memberTypeList.push(getRegularTypeOfLiteralType(memberType)); } @@ -53825,22 +54945,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 192 /* LiteralType */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 194 /* LiteralType */: return true; - case 179 /* ArrayType */: + case 181 /* ArrayType */: return isThislessType(node.elementType); - case 174 /* TypeReference */: + case 176 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -53866,7 +54986,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 167 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 169 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -53882,14 +55002,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -53915,7 +55035,7 @@ var ts; } } function isStaticPrivateIdentifierProperty(s) { - return !!s.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); + return !!s.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(s.valueDeclaration) && ts.isStatic(s.valueDeclaration); } function resolveDeclaredMembers(type) { if (!type.declaredProperties) { @@ -53925,10 +55045,10 @@ var ts; // Start with signatures at empty array in case of recursive types type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; + type.declaredIndexInfos = ts.emptyArray; type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); - type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); + type.declaredIndexInfos = getIndexInfosOfSymbol(symbol); } return type; } @@ -54002,7 +55122,7 @@ var ts; if (!symbol.declarations) { symbol.declarations = [member]; } - else { + else if (!member.symbol.isReplaceableByMethod) { symbol.declarations.push(member); } if (symbolFlags & 111551 /* Value */) { @@ -54084,8 +55204,8 @@ var ts; function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) { var links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - var isStatic = resolutionKind === "resolvedExports" /* resolvedExports */; - var earlySymbols = !isStatic ? symbol.members : + var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */; + var earlySymbols = !isStatic_1 ? symbol.members : symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) : symbol.exports; // In the event we recursively resolve the members/exports of the symbol, we @@ -54100,7 +55220,7 @@ var ts; if (members) { for (var _b = 0, members_5 = members; _b < members_5.length; _b++) { var member = members_5[_b]; - if (isStatic === ts.hasStaticModifier(member) && hasLateBindableName(member)) { + if (isStatic_1 === ts.hasStaticModifier(member) && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } } @@ -54116,7 +55236,7 @@ var ts; || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name - if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } } @@ -54178,29 +55298,26 @@ var ts; var members; var callSignatures; var constructSignatures; - var stringIndexInfo; - var numberIndexInfo; + var indexInfos; if (ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { members = source.symbol ? getMembersOfSymbol(source.symbol) : ts.createSymbolTable(source.declaredProperties); callSignatures = source.declaredCallSignatures; constructSignatures = source.declaredConstructSignatures; - stringIndexInfo = source.declaredStringIndexInfo; - numberIndexInfo = source.declaredNumberIndexInfo; + indexInfos = source.declaredIndexInfos; } else { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper); constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper); - stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper); - numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper); + indexInfos = instantiateIndexInfos(source.declaredIndexInfos, mapper); } var baseTypes = getBaseTypes(source); if (baseTypes.length) { if (source.symbol && members === getMembersOfSymbol(source.symbol)) { members = ts.createSymbolTable(source.declaredProperties); } - setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos); var thisArgument = ts.lastOrUndefined(typeArguments); for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { var baseType = baseTypes_1[_i]; @@ -54208,15 +55325,11 @@ var ts; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - if (!stringIndexInfo) { - stringIndexInfo = instantiatedBaseType === anyType ? - createIndexInfo(anyType, /*isReadonly*/ false) : - getIndexInfoOfType(instantiatedBaseType, 0 /* String */); - } - numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1 /* Number */); + var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)]; + indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); })); } } - setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos); } function resolveClassOrInterfaceMembers(type) { resolveObjectTypeMembers(type, resolveDeclaredMembers(type), ts.emptyArray, ts.emptyArray); @@ -54526,38 +55639,35 @@ var ts; } return result; } - function getUnionIndexInfo(types, kind) { - var indexTypes = []; - var isAnyReadonly = false; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; - var indexInfo = getIndexInfoOfType(getApparentType(type), kind); - if (!indexInfo) { - return undefined; + function getUnionIndexInfos(types) { + var sourceInfos = getIndexInfosOfType(types[0]); + if (sourceInfos) { + var result = []; + var _loop_11 = function (info) { + var indexType = info.keyType; + if (ts.every(types, function (t) { return !!getIndexInfoOfType(t, indexType); })) { + result.push(createIndexInfo(indexType, getUnionType(ts.map(types, function (t) { return getIndexTypeOfType(t, indexType); })), ts.some(types, function (t) { return getIndexInfoOfType(t, indexType).isReadonly; }))); + } + }; + for (var _i = 0, sourceInfos_1 = sourceInfos; _i < sourceInfos_1.length; _i++) { + var info = sourceInfos_1[_i]; + _loop_11(info); } - indexTypes.push(indexInfo.type); - isAnyReadonly = isAnyReadonly || indexInfo.isReadonly; + return result; } - return createIndexInfo(getUnionType(indexTypes, 2 /* Subtype */), isAnyReadonly); + return ts.emptyArray; } function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); })); var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); - var stringIndexInfo = getUnionIndexInfo(type.types, 0 /* String */); - var numberIndexInfo = getUnionIndexInfo(type.types, 1 /* Number */); - setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + var indexInfos = getUnionIndexInfos(type.types); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos); } function intersectTypes(type1, type2) { return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } - function intersectIndexInfos(info1, info2) { - return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly); - } - function unionSpreadIndexInfos(info1, info2) { - return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); - } function findMixins(types) { var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; }); var mixinFlags = ts.map(types, isMixinConstructorType); @@ -54584,12 +55694,11 @@ var ts; // intersection type use getPropertiesOfType (only the language service uses this). var callSignatures; var constructSignatures; - var stringIndexInfo; - var numberIndexInfo; + var indexInfos; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_11 = function (i) { + var _loop_12 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -54608,54 +55717,62 @@ var ts; constructSignatures = appendSignatures(constructSignatures, signatures); } callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */)); - stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0 /* String */)); - numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); + indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos); }; for (var i = 0; i < types.length; i++) { - _loop_11(i); + _loop_12(i); } - setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, indexInfos || ts.emptyArray); } function appendSignatures(signatures, newSignatures) { - var _loop_12 = function (sig) { + var _loop_13 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_12(sig); + _loop_13(sig); } return signatures; } + function appendIndexInfo(indexInfos, newInfo, union) { + if (indexInfos) { + for (var i = 0; i < indexInfos.length; i++) { + var info = indexInfos[i]; + if (info.keyType === newInfo.keyType) { + indexInfos[i] = createIndexInfo(info.keyType, union ? getUnionType([info.type, newInfo.type]) : getIntersectionType([info.type, newInfo.type]), union ? info.isReadonly || newInfo.isReadonly : info.isReadonly && newInfo.isReadonly); + return indexInfos; + } + } + } + return ts.append(indexInfos, newInfo); + } /** * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { var symbol = getMergedSymbol(type.symbol); if (type.target) { - setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); - var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0 /* String */), type.mapper); - var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1 /* Number */), type.mapper); - setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + var indexInfos = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos); } else if (symbol.flags & 2048 /* TypeLiteral */) { - setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members = getMembersOfSymbol(symbol); var callSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); var constructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); - var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); - var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); - setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + var indexInfos = getIndexInfosOfSymbol(symbol); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos); } else { // Combinations of function, class, enum and module var members = emptySymbols; - var stringIndexInfo = void 0; - var numberIndexInfo = void 0; + var indexInfos = void 0; if (symbol.exports) { members = getExportsOfSymbol(symbol); if (symbol === globalThisSymbol) { @@ -54669,7 +55786,7 @@ var ts; } } var baseConstructorIndexInfo = void 0; - setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined); + setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); @@ -54678,22 +55795,23 @@ var ts; addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } else if (baseConstructorType === anyType) { - baseConstructorIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false); } } var indexSymbol = getIndexSymbolFromSymbolTable(members); if (indexSymbol) { - stringIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 0 /* String */); - numberIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 1 /* Number */); + indexInfos = getIndexInfosOfIndexSymbol(indexSymbol); } else { - stringIndexInfo = baseConstructorIndexInfo; + if (baseConstructorIndexInfo) { + indexInfos = ts.append(indexInfos, baseConstructorIndexInfo); + } if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { - numberIndexInfo = enumNumberIndexInfo; + indexInfos = ts.append(indexInfos, enumNumberIndexInfo); } } - setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, indexInfos || ts.emptyArray); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list @@ -54721,20 +55839,14 @@ var ts; // map type.indexType to 0 // map type.objectType to `[TReplacement]` // thus making the indexed access `[TReplacement][0]` or `TReplacement` - return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getLiteralType(0), createTupleType([replacement])])); - } - function getIndexInfoOfIndexSymbol(indexSymbol, indexKind) { - var declaration = getIndexDeclarationOfIndexSymbol(indexSymbol, indexKind); - if (!declaration) - return undefined; - return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration); + return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getNumberLiteralType(0), createTupleType([replacement])])); } function resolveReverseMappedTypeMembers(type) { - var indexInfo = getIndexInfoOfType(type.source, 0 /* String */); + var indexInfo = getIndexInfoOfType(type.source, stringType); var modifiers = getMappedTypeModifiers(type.mappedType); var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; - var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly); + var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; @@ -54760,7 +55872,7 @@ var ts; } members.set(prop.escapedName, inferredProp); } - setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); + setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, indexInfos); } // Return the lower bound of the key type in a mapped type. Intuitively, the lower // bound includes those keys that are known to always be present, for example because @@ -54794,10 +55906,9 @@ var ts; /** Resolve the members of a mapped type { [P in K]: T } */ function resolveMappedTypeMembers(type) { var members = ts.createSymbolTable(); - var stringIndexInfo; - var numberIndexInfo; + var indexInfos; // Resolve upfront such that recursive references see an empty object type. - setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // In { [P in K]: T }, we refer to P as the type parameter type, K as the constraint type, // and T as the template type. var typeParameter = getTypeParameterFromMappedType(type); @@ -54813,17 +55924,22 @@ var ts; var prop = _a[_i]; addMemberForKeyType(getLiteralTypeFromProperty(prop, include)); } - if (modifiersType.flags & 1 /* Any */ || getIndexInfoOfType(modifiersType, 0 /* String */)) { + if (modifiersType.flags & 1 /* Any */) { addMemberForKeyType(stringType); } - if (!keyofStringsOnly && getIndexInfoOfType(modifiersType, 1 /* Number */)) { - addMemberForKeyType(numberType); + else { + for (var _b = 0, _c = getIndexInfosOfType(modifiersType); _b < _c.length; _b++) { + var info = _c[_b]; + if (!keyofStringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + addMemberForKeyType(info.keyType); + } + } } } else { forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType); } - setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, indexInfos || ts.emptyArray); function addMemberForKeyType(keyType) { var propNameType = nameType ? instantiateType(nameType, appendTypeMapping(type.mapper, typeParameter, keyType)) : keyType; forEachType(propNameType, function (t) { return addMemberForKeyTypeWorker(keyType, t); }); @@ -54855,19 +55971,20 @@ var ts; prop.keyType = keyType; if (modifiersProp) { prop.syntheticOrigin = modifiersProp; - prop.declarations = modifiersProp.declarations; + // If the mapped type has an `as XXX` clause, the property name likely won't match the declaration name and + // multiple properties may map to the same name. Thus, we attach no declarations to the symbol. + prop.declarations = nameType ? undefined : modifiersProp.declarations; } members.set(propName, prop); } } - else if (propNameType.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 32 /* Enum */)) { + else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) { + var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : + propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : + propNameType; var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); - if (propNameType.flags & (1 /* Any */ | 4 /* String */)) { - stringIndexInfo = createIndexInfo(stringIndexInfo ? getUnionType([stringIndexInfo.type, propType]) : propType, !!(templateModifiers & 1 /* IncludeReadonly */)); - } - else { - numberIndexInfo = createIndexInfo(numberIndexInfo ? getUnionType([numberIndexInfo.type, propType]) : propType, !!(templateModifiers & 1 /* IncludeReadonly */)); - } + var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true); } } } @@ -54884,8 +56001,8 @@ var ts; // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. - var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType) : - symbol.checkFlags & 524288 /* StripOptional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : + symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : propType; if (!popTypeResolution()) { error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); @@ -54911,7 +56028,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -54919,8 +56036,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 189 /* TypeOperator */ && - constraintDeclaration.operator === 138 /* KeyOfKeyword */; + return constraintDeclaration.kind === 191 /* TypeOperator */ && + constraintDeclaration.operator === 139 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -55025,7 +56142,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type without index signature - if (type.flags & 1048576 /* Union */ && !getIndexInfoOfType(current, 0 /* String */) && !getIndexInfoOfType(current, 1 /* Number */)) { + if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) { break; } } @@ -55054,8 +56171,8 @@ var ts; return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var memberType = types_5[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var memberType = types_4[_i]; for (var _a = 0, _b = getAugmentedPropertiesOfType(memberType); _a < _b.length; _a++) { var escapedName = _b[_a].escapedName; if (!props.has(escapedName)) { @@ -55087,14 +56204,14 @@ var ts; function getConstraintFromIndexedAccess(type) { var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType); if (indexConstraint && indexConstraint !== type.indexType) { - var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.noUncheckedIndexedAccessCandidate); + var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags); if (indexedAccess) { return indexedAccess; } } var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType); if (objectConstraint && objectConstraint !== type.objectType) { - return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.noUncheckedIndexedAccessCandidate); + return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.accessFlags); } return undefined; } @@ -55143,8 +56260,8 @@ var ts; function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var t = types_6[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var t = types_5[_i]; if (t.flags & 465829888 /* Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). @@ -55169,8 +56286,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _a = 0, types_7 = types; _a < types_7.length; _a++) { - var t = types_7[_a]; + for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { + var t = types_6[_a]; if (t.flags & 469892092 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -55256,8 +56373,8 @@ var ts; var types = t.types; var baseTypes = []; var different = false; - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type_3 = types_8[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type_3 = types_7[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { if (baseType !== type_3) { @@ -55291,7 +56408,7 @@ var ts; if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); - var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.noUncheckedIndexedAccessCandidate); + var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } if (t.flags & 16777216 /* Conditional */) { @@ -55448,7 +56565,7 @@ var ts; } } else if (isUnion) { - var indexInfo = !isLateBoundName(name) && (isNumericLiteralName(name) && getIndexInfoOfType(type, 1 /* Number */) || getIndexInfoOfType(type, 0 /* String */)); + var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name); if (indexInfo) { checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); @@ -55568,15 +56685,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 67108864 /* ContainsIntersections */) { + if (type.flags & 1048576 /* Union */ && type.objectFlags & 33554432 /* ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 67108864 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 67108864 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 134217728 /* IsNeverIntersection */ : 0); + if (!(type.objectFlags & 33554432 /* IsNeverIntersectionComputed */)) { + type.objectFlags |= 33554432 /* IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 67108864 /* IsNeverIntersection */ : 0); } - return type.objectFlags & 134217728 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 67108864 /* IsNeverIntersection */ ? neverType : type; } return type; } @@ -55606,7 +56723,7 @@ var ts; return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 134217728 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 67108864 /* IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); @@ -55667,44 +56784,72 @@ var ts; function getSignaturesOfType(type, kind) { return getSignaturesOfStructuredType(getReducedApparentType(type), kind); } - function getIndexInfoOfStructuredType(type, kind) { + function findIndexInfo(indexInfos, keyType) { + return ts.find(indexInfos, function (info) { return info.keyType === keyType; }); + } + function findApplicableIndexInfo(indexInfos, keyType) { + // Index signatures for type 'string' are considered only when no other index signatures apply. + var stringIndexInfo; + var applicableInfo; + var applicableInfos; + for (var _i = 0, indexInfos_1 = indexInfos; _i < indexInfos_1.length; _i++) { + var info = indexInfos_1[_i]; + if (info.keyType === stringType) { + stringIndexInfo = info; + } + else if (isApplicableIndexType(keyType, info.keyType)) { + if (!applicableInfo) { + applicableInfo = info; + } + else { + (applicableInfos || (applicableInfos = [applicableInfo])).push(info); + } + } + } + // When more than one index signature is applicable we create a synthetic IndexInfo. Instead of computing + // the intersected key type, we just use unknownType for the key type as nothing actually depends on the + // keyType property of the returned IndexInfo. + return applicableInfos ? createIndexInfo(unknownType, getIntersectionType(ts.map(applicableInfos, function (info) { return info.type; })), ts.reduceLeft(applicableInfos, function (isReadonly, info) { return isReadonly && info.isReadonly; }, /*initial*/ true)) : + applicableInfo ? applicableInfo : + stringIndexInfo && isApplicableIndexType(keyType, stringType) ? stringIndexInfo : + undefined; + } + function isApplicableIndexType(source, target) { + // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index + // signature applies to types assignable to 'number' and numeric string literal types. + return isTypeAssignableTo(source, target) || + target === stringType && isTypeAssignableTo(source, numberType) || + target === numberType && !!(source.flags & 128 /* StringLiteral */) && isNumericLiteralName(source.value); + } + function getIndexInfosOfStructuredType(type) { if (type.flags & 3670016 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; + return resolved.indexInfos; } + return ts.emptyArray; } - function getIndexTypeOfStructuredType(type, kind) { - var info = getIndexInfoOfStructuredType(type, kind); - return info && info.type; + function getIndexInfosOfType(type) { + return getIndexInfosOfStructuredType(getReducedApparentType(type)); } // Return the indexing info of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. - function getIndexInfoOfType(type, kind) { - return getIndexInfoOfStructuredType(getReducedApparentType(type), kind); + function getIndexInfoOfType(type, keyType) { + return findIndexInfo(getIndexInfosOfType(type), keyType); } // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. - function getIndexTypeOfType(type, kind) { - return getIndexTypeOfStructuredType(getReducedApparentType(type), kind); + function getIndexTypeOfType(type, keyType) { + var _a; + return (_a = getIndexInfoOfType(type, keyType)) === null || _a === void 0 ? void 0 : _a.type; } - function getImplicitIndexTypeOfType(type, kind) { - if (isObjectTypeWithInferableIndex(type)) { - var propTypes = []; - for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { - var prop = _a[_i]; - if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { - var propType = getTypeOfSymbol(prop); - propTypes.push(prop.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType); - } - } - if (kind === 0 /* String */) { - ts.append(propTypes, getIndexTypeOfType(type, 1 /* Number */)); - } - if (propTypes.length) { - return getUnionType(propTypes); - } - } - return undefined; + function getApplicableIndexInfos(type, keyType) { + return getIndexInfosOfType(type).filter(function (info) { return isApplicableIndexType(keyType, info.keyType); }); + } + function getApplicableIndexInfo(type, keyType) { + return findApplicableIndexInfo(getIndexInfosOfType(type), keyType); + } + function getApplicableIndexInfoForName(type, name) { + return getApplicableIndexInfo(type, isLateBoundName(name) ? esSymbolType : getStringLiteralType(ts.unescapeLeadingUnderscores(name))); } // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). @@ -55728,10 +56873,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 308 /* JSDocOptionalType */ + node.type && node.type.kind === 311 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 308 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 311 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -55771,7 +56916,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 308 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 311 /* JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -55853,12 +56998,12 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 192 /* LiteralType */) { + if (type && type.kind === 194 /* LiteralType */) { flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || - param.initializer || param.questionToken || param.dotDotDotToken || + param.initializer || param.questionToken || ts.isRestParameter(param) || iife && parameters.length > iife.arguments.length && !type || isJSDocOptionalParameter(param); if (!isOptionalParameter_1) { @@ -55866,16 +57011,16 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 168 /* GetAccessor */ || declaration.kind === 169 /* SetAccessor */) && + if ((declaration.kind === 170 /* GetAccessor */ || declaration.kind === 171 /* SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 168 /* GetAccessor */ ? 169 /* SetAccessor */ : 168 /* GetAccessor */; + var otherKind = declaration.kind === 170 /* GetAccessor */ ? 171 /* SetAccessor */ : 170 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 167 /* Constructor */ ? + var classType = declaration.kind === 169 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -55941,16 +57086,16 @@ var ts; if (!node) return false; switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol; - case 164 /* PropertyDeclaration */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - return node.name.kind === 159 /* ComputedPropertyName */ + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + return node.name.kind === 160 /* ComputedPropertyName */ && traverse(node.name); - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: return traverse(node.expression); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -56022,7 +57167,7 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 188 /* ThisType */ ? + return parameterName.kind === 190 /* ThisType */ ? createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } @@ -56068,7 +57213,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 167 /* Constructor */) { + if (declaration.kind === 169 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -56078,12 +57223,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 168 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 170 /* GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 169 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 171 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -56101,7 +57246,7 @@ var ts; if (signatureHasRestParameter(signature)) { var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType; - return restType && getIndexTypeOfType(restType, 1 /* Number */); + return restType && getIndexTypeOfType(restType, numberType); } return undefined; } @@ -56184,12 +57329,13 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 167 /* Constructor */ || kind === 171 /* ConstructSignature */ || kind === 176 /* ConstructorType */; + var isConstructor = kind === 169 /* Constructor */ || kind === 173 /* ConstructSignature */ || kind === 178 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; type.callSignatures = !isConstructor ? [signature] : ts.emptyArray; type.constructSignatures = isConstructor ? [signature] : ts.emptyArray; + type.indexInfos = ts.emptyArray; signature.isolatedSignatureType = type; } return signature.isolatedSignatureType; @@ -56200,39 +57346,39 @@ var ts; function getIndexSymbolFromSymbolTable(symbolTable) { return symbolTable.get("__index" /* Index */); } - function getIndexDeclarationOfSymbol(symbol, kind) { - var indexSymbol = symbol && getIndexSymbol(symbol); - return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); - } - function getIndexDeclarationOfSymbolTable(symbolTable, kind) { - var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable); - return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); - } - function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */; - if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { - for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var node = ts.cast(decl, ts.isIndexSignatureDeclaration); - if (node.parameters.length === 1) { - var parameter = node.parameters[0]; - if (parameter.type && parameter.type.kind === syntaxKind) { - return node; + function createIndexInfo(keyType, type, isReadonly, declaration) { + return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration }; + } + function getIndexInfosOfSymbol(symbol) { + var indexSymbol = getIndexSymbol(symbol); + return indexSymbol ? getIndexInfosOfIndexSymbol(indexSymbol) : ts.emptyArray; + } + function getIndexInfosOfIndexSymbol(indexSymbol) { + if (indexSymbol.declarations) { + var indexInfos_2 = []; + var _loop_14 = function (declaration) { + if (declaration.parameters.length === 1) { + var parameter = declaration.parameters[0]; + if (parameter.type) { + forEachType(getTypeFromTypeNode(parameter.type), function (keyType) { + if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_2, keyType)) { + indexInfos_2.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + } + }); } } + }; + for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + _loop_14(declaration); } + return indexInfos_2; } - return undefined; - } - function createIndexInfo(type, isReadonly, declaration) { - return { type: type, isReadonly: isReadonly, declaration: declaration }; + return ts.emptyArray; } - function getIndexInfoOfSymbol(symbol, kind) { - var declaration = getIndexDeclarationOfSymbol(symbol, kind); - if (declaration) { - return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration); - } - return undefined; + function isValidIndexKeyType(type) { + return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || + !!(type.flags & 2097152 /* Intersection */) && !isGenericIndexType(type) && !isGenericObjectType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -56243,13 +57389,13 @@ var ts; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (declaration.parent.kind === 186 /* InferType */) { + if (declaration.parent.kind === 188 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; - if (grandParent.kind === 174 /* TypeReference */) { + if (grandParent.kind === 176 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -56274,27 +57420,27 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 161 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 182 /* RestType */ || - grandParent.kind === 193 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 162 /* Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 184 /* RestType */ || + grandParent.kind === 195 /* NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' // constraint. - else if (grandParent.kind === 195 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 197 /* TemplateLiteralTypeSpan */) { inferences = ts.append(inferences, stringType); } // When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any' // constraint. - else if (grandParent.kind === 160 /* TypeParameter */ && grandParent.parent.kind === 191 /* MappedType */) { + else if (grandParent.kind === 161 /* TypeParameter */ && grandParent.parent.kind === 193 /* MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template // of the check type's mapped type - else if (grandParent.kind === 191 /* MappedType */ && grandParent.type && - ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 185 /* ConditionalType */ && - grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 191 /* MappedType */ && + else if (grandParent.kind === 193 /* MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 187 /* ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 193 /* MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); @@ -56322,7 +57468,7 @@ var ts; if (type.flags & 1 /* Any */ && type !== errorType) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 191 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 193 /* MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -56331,7 +57477,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 160 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 161 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -56367,8 +57513,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var type = types_9[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -56417,8 +57563,8 @@ var ts; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 174 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 179 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 176 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 181 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -56460,7 +57606,7 @@ var ts; return errorType; } } - if (node.kind === 174 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 176 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -56519,9 +57665,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 174 /* TypeReference */: + case 176 /* TypeReference */: return node.typeName; - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -56577,7 +57723,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 196 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 198 /* ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); @@ -56603,7 +57749,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 180 /* TupleType */ && node.elements.length === 1; + return node.kind === 182 /* TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -56613,16 +57759,16 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 312 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 315 /* JSDocComment */) { var parent = node.parent; // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax - if (parent.kind === 161 /* Parameter */) { + if (parent.kind === 162 /* Parameter */) { covariant = !covariant; } // Always substitute on type parameters, regardless of variance, since even // in contravariant positions, they may rely on substituted constraints to be valid - if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 185 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 187 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -56633,7 +57779,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 174 /* TypeReference */ || node.kind === 196 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 176 /* TypeReference */ || node.kind === 198 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -56677,8 +57823,8 @@ var ts; if (ts.isJSDocIndexSignature(node)) { var indexed = getTypeFromTypeNode(typeArgs[0]); var target = getTypeFromTypeNode(typeArgs[1]); - var index = createIndexInfo(target, /*isReadonly*/ false); - return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined); + var indexInfo = indexed === stringType || indexed === numberType ? [createIndexInfo(indexed, target, /*isReadonly*/ false)] : ts.emptyArray; + return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexInfo); } return anyType; } @@ -56736,7 +57882,8 @@ var ts; // The expression is processed as an identifier expression (section 4.3) // or property access expression(section 4.10), // the widened type(section 3.9) of which becomes the result. - links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(checkExpression(node.exprName))); + var type = ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName); + links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(type)); } return links.resolvedType; } @@ -56747,9 +57894,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 256 /* EnumDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 258 /* EnumDeclaration */: return declaration; } } @@ -56792,6 +57939,20 @@ var ts; function getGlobalImportMetaType() { return deferredGlobalImportMetaType || (deferredGlobalImportMetaType = getGlobalType("ImportMeta", /*arity*/ 0, /*reportErrors*/ true)) || emptyObjectType; } + function getGlobalImportMetaExpressionType() { + if (!deferredGlobalImportMetaExpressionType) { + // Create a synthetic type `ImportMetaExpression { meta: MetaProperty }` + var symbol = createSymbol(0 /* None */, "ImportMetaExpression"); + var importMetaType = getGlobalImportMetaType(); + var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */); + metaPropertySymbol.parent = symbol; + metaPropertySymbol.type = importMetaType; + var members = ts.createSymbolTable([metaPropertySymbol]); + symbol.members = members; + deferredGlobalImportMetaExpressionType = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); + } + return deferredGlobalImportMetaExpressionType; + } function getGlobalESSymbolConstructorSymbol(reportErrors) { return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); } @@ -56874,11 +58035,11 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 181 /* OptionalType */: + case 183 /* OptionalType */: return 2 /* Optional */; - case 182 /* RestType */: + case 184 /* RestType */: return getRestTypeElementFlags(node); - case 193 /* NamedTupleMember */: + case 195 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; @@ -56896,14 +58057,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 193 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 195 /* NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 179 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 180 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 181 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 182 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -56912,18 +58073,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 187 /* ParenthesizedType */: - case 193 /* NamedTupleMember */: - case 174 /* TypeReference */: - case 183 /* UnionType */: - case 184 /* IntersectionType */: - case 190 /* IndexedAccessType */: - case 185 /* ConditionalType */: - case 189 /* TypeOperator */: - case 179 /* ArrayType */: - case 180 /* TupleType */: + case 189 /* ParenthesizedType */: + case 195 /* NamedTupleMember */: + case 176 /* TypeReference */: + case 185 /* UnionType */: + case 186 /* IntersectionType */: + case 192 /* IndexedAccessType */: + case 187 /* ConditionalType */: + case 191 /* TypeOperator */: + case 181 /* ArrayType */: + case 182 /* TupleType */: return isResolvedByTypeAlias(parent); - case 255 /* TypeAliasDeclaration */: + case 257 /* TypeAliasDeclaration */: return true; } return false; @@ -56932,28 +58093,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 174 /* TypeReference */: + case 176 /* TypeReference */: return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 177 /* TypeQuery */: + case 179 /* TypeQuery */: return true; - case 189 /* TypeOperator */: - return node.operator !== 151 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 187 /* ParenthesizedType */: - case 181 /* OptionalType */: - case 193 /* NamedTupleMember */: - case 308 /* JSDocOptionalType */: - case 306 /* JSDocNullableType */: - case 307 /* JSDocNonNullableType */: - case 302 /* JSDocTypeExpression */: + case 191 /* TypeOperator */: + return node.operator !== 152 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 189 /* ParenthesizedType */: + case 183 /* OptionalType */: + case 195 /* NamedTupleMember */: + case 311 /* JSDocOptionalType */: + case 309 /* JSDocNullableType */: + case 310 /* JSDocNonNullableType */: + case 304 /* JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 182 /* RestType */: - return node.type.kind !== 179 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 183 /* UnionType */: - case 184 /* IntersectionType */: + case 184 /* RestType */: + return node.type.kind !== 181 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 185 /* UnionType */: + case 186 /* IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 190 /* IndexedAccessType */: + case 192 /* IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 185 /* ConditionalType */: + case 187 /* ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -56966,19 +58127,19 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 180 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 180 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 182 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 182 /* TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 179 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 181 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 142 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 143 /* ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } @@ -57034,10 +58195,10 @@ var ts; lengthSymbol.type = numberType; } else { - var literalTypes_1 = []; + var literalTypes = []; for (var i = minLength; i <= arity; i++) - literalTypes_1.push(getLiteralType(i)); - lengthSymbol.type = getUnionType(literalTypes_1); + literalTypes.push(getNumberLiteralType(i)); + lengthSymbol.type = getUnionType(literalTypes); } properties.push(lengthSymbol); var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); @@ -57054,8 +58215,7 @@ var ts; type.declaredProperties = properties; type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; - type.declaredStringIndexInfo = undefined; - type.declaredNumberIndexInfo = undefined; + type.declaredIndexInfos = ts.emptyArray; type.elementFlags = elementFlags; type.minLength = minLength; type.fixedLength = fixedLength; @@ -57094,7 +58254,7 @@ var ts; var lastRequiredIndex = -1; var firstRestIndex = -1; var lastOptionalOrRestIndex = -1; - var _loop_13 = function (i) { + var _loop_15 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; if (flags & 8 /* Variadic */) { @@ -57115,7 +58275,7 @@ var ts; } else { // Treat everything else as an array type and create a rest element. - addElement(isArrayLikeType(type) && getIndexTypeOfType(type, 1 /* Number */) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); + addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); } } else { @@ -57124,7 +58284,7 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - var state_4 = _loop_13(i); + var state_4 = _loop_15(i); if (typeof state_4 === "object") return state_4.value; } @@ -57173,7 +58333,7 @@ var ts; /*readonly*/ false, target.labeledElementDeclarations && target.labeledElementDeclarations.slice(index, endIndex)); } function getKnownKeysOfTupleType(type) { - return getUnionType(ts.append(ts.arrayOf(type.target.fixedLength, function (i) { return getLiteralType("" + i); }), getIndexType(type.target.readonly ? globalReadonlyArrayType : globalArrayType))); + return getUnionType(ts.append(ts.arrayOf(type.target.fixedLength, function (i) { return getStringLiteralType("" + i); }), getIndexType(type.target.readonly ? globalReadonlyArrayType : globalArrayType))); } // Return count of starting consecutive tuple elements of the given kind(s) function getStartElementCount(type, flags) { @@ -57185,8 +58345,7 @@ var ts; return type.elementFlags.length - ts.findLastIndex(type.elementFlags, function (f) { return !(f & flags); }) - 1; } function getTypeFromOptionalTypeNode(node) { - var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getOptionalType(type) : type; + return addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true); } function getTypeId(type) { return type.id; @@ -57231,8 +58390,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var type = types_10[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -57261,8 +58420,8 @@ var ts; ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : undefined; var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var target = types_11[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var target = types_10[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -57302,7 +58461,7 @@ var ts; i--; var t = types[i]; var flags = t.flags; - var remove = flags & 128 /* StringLiteral */ && includes & 4 /* String */ || + var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || @@ -57317,7 +58476,7 @@ var ts; var templates = ts.filter(types, isPatternLiteralType); if (templates.length) { var i = types.length; - var _loop_14 = function () { + var _loop_16 = function () { i--; var t = types[i]; if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeSubtypeOf(t, template); })) { @@ -57325,7 +58484,7 @@ var ts; } }; while (i > 0) { - _loop_14(); + _loop_16(); } } } @@ -57333,8 +58492,8 @@ var ts; return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin)); } function addNamedUnions(namedUnions, types) { - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; if (t.flags & 1048576 /* Union */) { var origin = t.origin; if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { @@ -57372,7 +58531,13 @@ var ts; if (includes & 3 /* AnyOrUnknown */) { return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : unknownType; } - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { + if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { + var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); + if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { + ts.orderedRemoveItemAt(typeSet, missingIndex); + } + } + if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); } if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { @@ -57394,14 +58559,14 @@ var ts; var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; - var _loop_15 = function (t) { + var _loop_17 = function (t) { if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) { reducedTypes.push(t); } }; for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) { var t = typeSet_1[_i]; - _loop_15(t); + _loop_17(t); } if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) { return namedUnions[0]; @@ -57418,7 +58583,7 @@ var ts; } } var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 67108864 /* ContainsIntersections */ : 0); + (includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } function getUnionOrIntersectionTypePredicate(signatures, kind) { @@ -57456,15 +58621,6 @@ var ts; function typePredicateKindsMatch(a, b) { return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } - function createUnionType(types, aliasSymbol, aliasTypeArguments, origin) { - var result = createType(1048576 /* Union */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); - result.types = types; - result.origin = origin; - result.aliasSymbol = aliasSymbol; - result.aliasTypeArguments = aliasTypeArguments; - return result; - } // This function assumes the constituent type list is sorted and deduplicated. function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments, origin) { if (types.length === 0) { @@ -57480,8 +58636,16 @@ var ts; var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { - type = createUnionType(types, aliasSymbol, aliasTypeArguments, origin); - type.objectFlags |= objectFlags; + type = createType(1048576 /* Union */); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type.types = types; + type.origin = origin; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = aliasTypeArguments; + if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) { + type.flags |= 16 /* Boolean */; + type.intrinsicName = "boolean"; + } unionTypes.set(id, type); } return type; @@ -57525,8 +58689,8 @@ var ts; // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var type = types_13[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var type = types_12[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -57675,8 +58839,10 @@ var ts; // a symbol-like type and a type known to be non-symbol-like, or // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. - if (includes & 131072 /* Never */ || - strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || + if (includes & 131072 /* Never */) { + return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; + } + if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || @@ -57816,40 +58982,37 @@ var ts; constraint; } // Ordinarily we reduce a keyof M, where M is a mapped type { [P in K as N

]: X }, to simply N. This however presumes - // that N distributes over union types, i.e. that N is equivalent to N | N | N. That presumption may not - // be true when N is a non-distributive conditional type or an instantiable type with a non-distributive conditional type as - // a constituent. In those cases, we cannot reduce keyof M and need to preserve it as is. - function maybeNonDistributiveNameType(type) { - return !!(type && (type.flags & 16777216 /* Conditional */ && (!type.root.isDistributive || maybeNonDistributiveNameType(type.checkType)) || - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && ts.some(type.types, maybeNonDistributiveNameType) || - type.flags & (4194304 /* Index */ | 268435456 /* StringMapping */) && maybeNonDistributiveNameType(type.type) || - type.flags & 8388608 /* IndexedAccess */ && maybeNonDistributiveNameType(type.indexType) || - type.flags & 33554432 /* Substitution */ && maybeNonDistributiveNameType(type.substitute))); + // that N distributes over union types, i.e. that N is equivalent to N | N | N. Specifically, we only + // want to perform the reduction when the name type of a mapped type is distributive with respect to the type variable + // introduced by the 'in' clause of the mapped type. Note that non-generic types are considered to be distributive because + // they're the same type regardless of what's being distributed over. + function hasDistributiveNameType(mappedType) { + var typeVariable = getTypeParameterFromMappedType(mappedType); + return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); + function isDistributive(type) { + return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true : + type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) : + type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) : + false; + } } function getLiteralTypeFromPropertyName(name) { if (ts.isPrivateIdentifier(name)) { return neverType; } - return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) : + return ts.isIdentifier(name) ? getStringLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) : getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); } - function getBigIntLiteralType(node) { - return getLiteralType({ - negative: false, - base10Value: ts.parsePseudoBigInt(node.text) - }); - } - function getLiteralTypeFromProperty(prop, include) { - if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + function getLiteralTypeFromProperty(prop, include, includeNonPublic) { + if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { - if (prop.escapedName === "default" /* Default */) { - type = getLiteralType("default"); - } - else { - var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getLiteralType(ts.symbolName(prop)) : undefined); - } + var name = ts.getNameOfDeclaration(prop.valueDeclaration); + type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") : + name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined); } if (type && type.flags & include) { return type; @@ -57859,28 +59022,23 @@ var ts; } function getLiteralTypeFromProperties(type, include, includeOrigin) { var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; - return getUnionType(ts.map(getPropertiesOfType(type), function (p) { return getLiteralTypeFromProperty(p, include); }), 1 /* Literal */, + var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); }); + var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && info.keyType.flags & include ? + info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); + return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); } - function getNonEnumNumberIndexInfo(type) { - var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); - return numberIndexInfo !== enumNumberIndexInfo ? numberIndexInfo : undefined; - } function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - var includeOrigin = stringsOnly === keyofStringsOnly && !noIndexSignatures; type = getReducedType(type); return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && maybeNonDistributiveNameType(getNameTypeFromMappedType(type)) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, noIndexSignatures) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : - stringsOnly ? !noIndexSignatures && getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromProperties(type, 128 /* StringLiteral */, includeOrigin) : - !noIndexSignatures && getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192 /* UniqueESSymbol */, includeOrigin)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 /* StringLiteral */ | 8192 /* UniqueESSymbol */, includeOrigin)]) : - getLiteralTypeFromProperties(type, 8576 /* StringOrNumberLiteralOrUnique */, includeOrigin); + getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -57897,15 +59055,15 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 138 /* KeyOfKeyword */: + case 139 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 151 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 148 /* SymbolKeyword */ + case 152 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 149 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -57917,7 +59075,7 @@ var ts; function getTypeFromTemplateTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getTemplateLiteralType(__spreadArray([node.head.text], ts.map(node.templateSpans, function (span) { return span.literal.text; })), ts.map(node.templateSpans, function (span) { return getTypeFromTypeNode(span.type); })); + links.resolvedType = getTemplateLiteralType(__spreadArray([node.head.text], ts.map(node.templateSpans, function (span) { return span.literal.text; }), true), ts.map(node.templateSpans, function (span) { return getTypeFromTypeNode(span.type); })); } return links.resolvedType; } @@ -57938,7 +59096,7 @@ var ts; return stringType; } if (newTypes.length === 0) { - return getLiteralType(text); + return getStringLiteralType(text); } newTexts.push(text); if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) { @@ -57991,7 +59149,7 @@ var ts; function getStringMappingType(symbol, type) { return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : - type.flags & 128 /* StringLiteral */ ? getLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : type; } function applyStringMapping(symbol, str) { @@ -58017,13 +59175,13 @@ var ts; result.type = type; return result; } - function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined) { + function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; + type.accessFlags = accessFlags; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - type.noUncheckedIndexedAccessCandidate = shouldIncludeUndefined; return type; } /** @@ -58072,14 +59230,17 @@ var ts; } return true; } - function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, noUncheckedIndexedAccessCandidate, reportDeprecated) { + function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 203 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 205 /* ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { + if (accessFlags & 256 /* Contextual */) { + return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; + } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (reportDeprecated && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } @@ -58089,7 +59250,7 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 4 /* CacheSymbol */) { + if (accessFlags & 8 /* CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -58102,7 +59263,7 @@ var ts; propType; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8 /* NoTupleBoundsCheck */)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -58111,10 +59272,10 @@ var ts; error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } } - errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */)); + errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return noUncheckedIndexedAccessCandidate ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; }); } } @@ -58122,22 +59283,23 @@ var ts; if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { return objectType; } - var stringIndexInfo = getIndexInfoOfType(objectType, 0 /* String */); - var indexInfo = isTypeAssignableToKind(indexType, 296 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || stringIndexInfo; + // If no index signature is applicable, we default to the string index signature. In effect, this means the string + // index signature applies even when accessing with a symbol-like type. + var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType); if (indexInfo) { - if (accessFlags & 1 /* NoIndexSignatures */ && indexInfo === stringIndexInfo) { + if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } return undefined; } - if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } if (indexType.flags & 131072 /* Never */) { return neverType; @@ -58161,12 +59323,12 @@ var ts; if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { var typeName = typeToString(objectType); error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]"); } - else if (getIndexTypeOfType(objectType, 1 /* Number */)) { + else if (getIndexTypeOfType(objectType, numberType)) { error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } else { @@ -58234,9 +59396,9 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 203 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 190 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 159 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 205 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 192 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 160 /* ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { @@ -58245,39 +59407,32 @@ var ts; function isPatternLiteralType(type) { return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); } + function isGenericType(type) { + return !!getGenericObjectFlags(type); + } function isGenericObjectType(type) { - if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 4194304 /* IsGenericObjectTypeComputed */)) { - type.objectFlags |= 4194304 /* IsGenericObjectTypeComputed */ | - (ts.some(type.types, isGenericObjectType) ? 8388608 /* IsGenericObjectType */ : 0); - } - return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); - } - if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 4194304 /* IsGenericObjectTypeComputed */)) { - type.objectFlags |= 4194304 /* IsGenericObjectTypeComputed */ | - (isGenericObjectType(type.substitute) || isGenericObjectType(type.baseType) ? 8388608 /* IsGenericObjectType */ : 0); - } - return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); - } - return !!(type.flags & 58982400 /* InstantiableNonPrimitive */) || isGenericMappedType(type) || isGenericTupleType(type); + return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericObjectType */); } function isGenericIndexType(type) { + return !!(getGenericObjectFlags(type) & 16777216 /* IsGenericIndexType */); + } + function getGenericObjectFlags(type) { if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 16777216 /* IsGenericIndexTypeComputed */)) { - type.objectFlags |= 16777216 /* IsGenericIndexTypeComputed */ | - (ts.some(type.types, isGenericIndexType) ? 33554432 /* IsGenericIndexType */ : 0); + if (!(type.objectFlags & 4194304 /* IsGenericTypeComputed */)) { + type.objectFlags |= 4194304 /* IsGenericTypeComputed */ | + ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0); } - return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); + return type.objectFlags & 25165824 /* IsGenericType */; } if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 16777216 /* IsGenericIndexTypeComputed */)) { - type.objectFlags |= 16777216 /* IsGenericIndexTypeComputed */ | - (isGenericIndexType(type.substitute) || isGenericIndexType(type.baseType) ? 33554432 /* IsGenericIndexType */ : 0); + if (!(type.objectFlags & 4194304 /* IsGenericTypeComputed */)) { + type.objectFlags |= 4194304 /* IsGenericTypeComputed */ | + getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType); } - return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); + return type.objectFlags & 25165824 /* IsGenericType */; } - return !!(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type); + return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 8388608 /* IsGenericObjectType */ : 0) | + (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 16777216 /* IsGenericIndexType */ : 0); } function isThisTypeParameter(type) { return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); @@ -58393,9 +59548,9 @@ var ts; var templateMapper = combineTypeMappers(objectType.mapper, mapper); return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } - function getIndexedAccessType(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, aliasSymbol, aliasTypeArguments, accessFlags) { + function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } - return getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); + return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { @@ -58409,36 +59564,38 @@ var ts; return false; }); } - function getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) { + function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - var shouldIncludeUndefined = noUncheckedIndexedAccessCandidate || - (!!compilerOptions.noUncheckedIndexedAccess && - (accessFlags & (2 /* Writing */ | 16 /* ExpressionPosition */)) === 16 /* ExpressionPosition */); // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { indexType = stringType; } + // In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to + // an index signature have 'undefined' included in their type. + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) + accessFlags |= 1 /* IncludeUndefined */; // If the index type is generic, or if the object type is generic and doesn't originate in an expression and // the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing // a higher-order index access where we cannot meaningfully access the properties of the object type. Note that // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 190 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 192 /* IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "") + getAliasId(aliasSymbol, aliasTypeArguments); + var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { - indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined)); + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments)); } return type; } @@ -58451,7 +59608,7 @@ var ts; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags, shouldIncludeUndefined); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -58467,11 +59624,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 2 /* Writing */ + return accessFlags & 4 /* Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */, shouldIncludeUndefined, /* reportDeprecated */ true); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -58479,7 +59636,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? @@ -58512,11 +59669,10 @@ var ts; return type; } function isTypicalNondistributiveConditional(root) { - return !root.isDistributive - && root.node.checkType.kind === 180 /* TupleType */ - && ts.length(root.node.checkType.elements) === 1 - && root.node.extendsType.kind === 180 /* TupleType */ - && ts.length(root.node.extendsType.elements) === 1; + return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType); + } + function isSingletonTupleType(node) { + return ts.isTupleTypeNode(node) && ts.length(node.elements) === 1 && !ts.isOptionalTypeNode(node.elements[0]) && !ts.isRestTypeNode(node.elements[0]); } /** * We syntactually check for common nondistributive conditional shapes and unwrap them into @@ -58531,11 +59687,11 @@ var ts; var extraTypes; // We loop here for an immediately nested conditional type in the false position, effectively treating // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for - // purposes of resolution. This means such types aren't subject to the instatiation depth limiter. + // purposes of resolution. This means such types aren't subject to the instantiation depth limiter. while (true) { var isUnwrapped = isTypicalNondistributiveConditional(root); var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper); - var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType); + var checkTypeInstantiable = isGenericType(checkType); var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper); if (checkType === wildcardType || extendsType === wildcardType) { return wildcardType; @@ -58557,7 +59713,7 @@ var ts; // Instantiate the extends type including inferences for 'infer T' type parameters var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType; // We attempt to resolve the conditional type only when the check and extends types are non-generic - if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) { + if (!checkTypeInstantiable && !isGenericType(inferredExtendsType)) { // Return falseType for a definitely false extends check. We check an instantiations of the two // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, @@ -58757,7 +59913,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 142 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 143 /* ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -58772,16 +59928,19 @@ var ts; return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { + if (!(type.flags & 1048576 /* Union */)) { + return type; + } if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { return ts.find(type.types, isEmptyObjectType) || emptyObjectType; } var firstType = ts.find(type.types, function (t) { return !isEmptyObjectTypeOrSpreadsIntoEmptyObject(t); }); if (!firstType) { - return undefined; + return type; } - var secondType = firstType && ts.find(type.types, function (t) { return t !== firstType && !isEmptyObjectTypeOrSpreadsIntoEmptyObject(t); }); + var secondType = ts.find(type.types, function (t) { return t !== firstType && !isEmptyObjectTypeOrSpreadsIntoEmptyObject(t); }); if (secondType) { - return undefined; + return type; } return getAnonymousPartialType(firstType); function getAnonymousPartialType(type) { @@ -58796,14 +59955,14 @@ var ts; var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); var flags = 4 /* Property */ | 16777216 /* Optional */; var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); - result.type = isSetonlyAccessor ? undefinedType : getUnionType([getTypeOfSymbol(prop), undefinedType]); + result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; result.syntheticOrigin = prop; members.set(prop.escapedName, result); } } - var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0 /* String */), getIndexInfoOfType(type, 1 /* Number */)); + var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return spread; } @@ -58826,20 +59985,14 @@ var ts; if (right.flags & 131072 /* Never */) { return left; } + left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); if (left.flags & 1048576 /* Union */) { - var merged = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); - if (merged) { - return getSpreadType(merged, right, symbol, objectFlags, readonly); - } return checkCrossProductUnion([left, right]) ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) : errorType; } + right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); if (right.flags & 1048576 /* Union */) { - var merged = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); - if (merged) { - return getSpreadType(left, merged, symbol, objectFlags, readonly); - } return checkCrossProductUnion([left, right]) ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) : errorType; @@ -58865,17 +60018,7 @@ var ts; } var members = ts.createSymbolTable(); var skippedPrivateMembers = new ts.Set(); - var stringIndexInfo; - var numberIndexInfo; - if (left === emptyObjectType) { - // for the first spread element, left === emptyObjectType, so take the right's string indexer - stringIndexInfo = getIndexInfoOfType(right, 0 /* String */); - numberIndexInfo = getIndexInfoOfType(right, 1 /* Number */); - } - else { - stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0 /* String */), getIndexInfoOfType(right, 0 /* String */)); - numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1 /* Number */), getIndexInfoOfType(right, 1 /* Number */)); - } + var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { @@ -58897,7 +60040,7 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288 /* NEUndefined */)]); + result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -58909,7 +60052,7 @@ var ts; members.set(leftProp.escapedName, getSpreadSymbol(leftProp, readonly)); } } - var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly)); + var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); })); spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */ | 4194304 /* ContainsSpread */ | objectFlags; return spread; } @@ -58934,19 +60077,19 @@ var ts; return result; } function getIndexInfoWithReadonly(info, readonly) { - return info && info.isReadonly !== readonly ? createIndexInfo(info.type, readonly, info.declaration) : info; + return info.isReadonly !== readonly ? createIndexInfo(info.keyType, info.type, readonly, info.declaration) : info; } - function createLiteralType(flags, value, symbol) { + function createLiteralType(flags, value, symbol, regularType) { var type = createType(flags); type.symbol = symbol; type.value = value; + type.regularType = regularType || type; return type; } function getFreshTypeOfLiteralType(type) { if (type.flags & 2944 /* Literal */) { if (!type.freshType) { - var freshType = createLiteralType(type.flags, type.value, type.symbol); - freshType.regularType = type; + var freshType = createLiteralType(type.flags, type.value, type.symbol, type); freshType.freshType = freshType; type.freshType = freshType; } @@ -58962,25 +60105,32 @@ var ts; function isFreshLiteralType(type) { return !!(type.flags & 2944 /* Literal */) && type.freshType === type; } - function getLiteralType(value, enumId, symbol) { - // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', - // where NNN is the text representation of a numeric literal and SSS are the characters - // of a string literal. For literal enum members we use 'EEE#NNN' and 'EEE@SSS', where - // EEE is a unique id for the containing enum type. - var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n"; - var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value); - var type = literalTypes.get(key); - if (!type) { - var flags = (typeof value === "number" ? 256 /* NumberLiteral */ : - typeof value === "string" ? 128 /* StringLiteral */ : 2048 /* BigIntLiteral */) | - (enumId ? 1024 /* EnumLiteral */ : 0); - literalTypes.set(key, type = createLiteralType(flags, value, symbol)); - type.regularType = type; - } - return type; + function getStringLiteralType(value) { + var type; + return stringLiteralTypes.get(value) || + (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type); + } + function getNumberLiteralType(value) { + var type; + return numberLiteralTypes.get(value) || + (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type); + } + function getBigIntLiteralType(value) { + var type; + var key = ts.pseudoBigIntToString(value); + return bigIntLiteralTypes.get(key) || + (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type); + } + function getEnumLiteralType(value, enumId, symbol) { + var type; + var qualifier = typeof value === "string" ? "@" : "#"; + var key = enumId + qualifier + value; + var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */); + return enumLiteralTypes.get(key) || + (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type); } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 103 /* NullKeyword */) { + if (node.literal.kind === 104 /* NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -59006,8 +60156,8 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 254 /* InterfaceDeclaration */)) { - if (!ts.hasSyntacticModifier(container, 32 /* Static */) && + if (parent && (ts.isClassLike(parent) || parent.kind === 256 /* InterfaceDeclaration */)) { + if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } @@ -59041,17 +60191,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 187 /* ParenthesizedType */: + case 189 /* ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 180 /* TupleType */: + case 182 /* TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 182 /* RestType */ || node.kind === 193 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 184 /* RestType */ || node.kind === 195 /* NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 179 /* ArrayType */: + case 181 /* ArrayType */: return node.elementType; } return undefined; @@ -59060,107 +60210,106 @@ var ts; var links = getNodeLinks(node); return links.resolvedType || (links.resolvedType = node.dotDotDotToken ? getTypeFromRestTypeNode(node) : - node.questionToken && strictNullChecks ? getOptionalType(getTypeFromTypeNode(node.type)) : - getTypeFromTypeNode(node.type)); + addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true, !!node.questionToken)); } function getTypeFromTypeNode(node) { return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node); } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 304 /* JSDocAllType */: - case 305 /* JSDocUnknownType */: + case 129 /* AnyKeyword */: + case 307 /* JSDocAllType */: + case 308 /* JSDocUnknownType */: return anyType; - case 152 /* UnknownKeyword */: + case 153 /* UnknownKeyword */: return unknownType; - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return stringType; - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return numberType; - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return bigintType; - case 131 /* BooleanKeyword */: + case 132 /* BooleanKeyword */: return booleanType; - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return esSymbolType; - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return voidType; - case 150 /* UndefinedKeyword */: + case 151 /* UndefinedKeyword */: return undefinedType; - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 141 /* NeverKeyword */: + case 142 /* NeverKeyword */: return neverType; - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 136 /* IntrinsicKeyword */: + case 137 /* IntrinsicKeyword */: return intrinsicMarkerType; - case 188 /* ThisType */: - case 107 /* ThisKeyword */: + case 190 /* ThisType */: + case 108 /* ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 192 /* LiteralType */: + case 194 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 174 /* TypeReference */: + case 176 /* TypeReference */: return getTypeFromTypeReference(node); - case 173 /* TypePredicate */: + case 175 /* TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 177 /* TypeQuery */: + case 179 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 179 /* ArrayType */: - case 180 /* TupleType */: + case 181 /* ArrayType */: + case 182 /* TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 181 /* OptionalType */: + case 183 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 183 /* UnionType */: + case 185 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 184 /* IntersectionType */: + case 186 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 306 /* JSDocNullableType */: + case 309 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 308 /* JSDocOptionalType */: + case 311 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 193 /* NamedTupleMember */: + case 195 /* NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 187 /* ParenthesizedType */: - case 307 /* JSDocNonNullableType */: - case 302 /* JSDocTypeExpression */: + case 189 /* ParenthesizedType */: + case 310 /* JSDocNonNullableType */: + case 304 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 182 /* RestType */: + case 184 /* RestType */: return getTypeFromRestTypeNode(node); - case 310 /* JSDocVariadicType */: + case 313 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 175 /* FunctionType */: - case 176 /* ConstructorType */: - case 178 /* TypeLiteral */: - case 314 /* JSDocTypeLiteral */: - case 309 /* JSDocFunctionType */: - case 315 /* JSDocSignature */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: + case 180 /* TypeLiteral */: + case 317 /* JSDocTypeLiteral */: + case 312 /* JSDocFunctionType */: + case 318 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 189 /* TypeOperator */: + case 191 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 190 /* IndexedAccessType */: + case 192 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 191 /* MappedType */: + case 193 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 185 /* ConditionalType */: + case 187 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 186 /* InferType */: + case 188 /* InferType */: return getTypeFromInferTypeNode(node); - case 194 /* TemplateLiteralType */: + case 196 /* TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 196 /* ImportType */: + case 198 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 78 /* Identifier */: - case 158 /* QualifiedName */: - case 202 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: + case 204 /* PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -59190,6 +60339,9 @@ var ts; function instantiateSignatures(signatures, mapper) { return instantiateList(signatures, mapper, instantiateSignature); } + function instantiateIndexInfos(indexInfos, mapper) { + return instantiateList(indexInfos, mapper, instantiateIndexInfo); + } function createTypeMapper(sources, targets) { return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : makeArrayTypeMapper(sources, targets); } @@ -59362,9 +60514,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 /* QualifiedName */ || - node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 176 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 198 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -59373,7 +60524,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 231 /* Block */ || n.kind === 185 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 233 /* Block */ || n.kind === 187 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -59382,16 +60533,19 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 188 /* ThisType */: + case 190 /* ThisType */: return !!tp.isThisType; - case 78 /* Identifier */: + case 79 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 177 /* TypeQuery */: + case 179 /* TypeQuery */: return true; - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -59470,7 +60624,7 @@ var ts; function instantiateMappedTupleType(tupleType, mappedType, mapper) { var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { - return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); + return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); }); var modifiers = getMappedTypeModifiers(mappedType); var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) : @@ -59484,7 +60638,7 @@ var ts; var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType) : + return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } @@ -59603,7 +60757,7 @@ var ts; if (flags & 8388608 /* IndexedAccess */) { var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); } if (flags & 16777216 /* Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); @@ -59659,40 +60813,40 @@ var ts; return type.restrictiveInstantiation; } function instantiateIndexInfo(info, mapper) { - return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); + return createIndexInfo(info.keyType, instantiateType(info.type, mapper), info.isReadonly, info.declaration); } // 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 !== 166 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 166 /* MethodDeclaration */: - case 252 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 254 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 282 /* JsxAttributes */: + case 284 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 281 /* JsxAttribute */: { + case 283 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 284 /* JsxExpression */: { + case 286 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g

) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -59702,29 +60856,11 @@ var ts; } function isContextSensitiveFunctionLikeDeclaration(node) { return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) && - (hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node)); - } - function hasContextSensitiveParameters(node) { - // Functions with type parameters are not context sensitive. - if (!node.typeParameters) { - // Functions with any parameters that lack type annotations are context sensitive. - if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { - return true; - } - if (node.kind !== 210 /* ArrowFunction */) { - // If the first parameter is not an explicit 'this' parameter, then the function has - // an implicit 'this' parameter which is subject to contextual typing. - var parameter = ts.firstOrUndefined(node.parameters); - if (!(parameter && ts.parameterIsThisKeyword(parameter))) { - return true; - } - } - } - return false; + (ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node)); } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 231 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 233 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -59739,6 +60875,7 @@ var ts; result.properties = resolved.properties; result.callSignatures = ts.emptyArray; result.constructSignatures = ts.emptyArray; + result.indexInfos = ts.emptyArray; return result; } } @@ -59827,23 +60964,23 @@ var ts; return true; } switch (node.kind) { - case 284 /* JsxExpression */: - case 208 /* ParenthesizedExpression */: + case 286 /* JsxExpression */: + case 210 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 282 /* JsxAttributes */: + case 284 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -59944,7 +61081,14 @@ var ts; if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); - if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { + if (!sourcePropType) + continue; + var propName = getPropertyNameFromIndex(nameType, /*accessNode*/ undefined); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + targetPropType = removeMissingType(targetPropType, targetIsOptional); + sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); + if (!checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, /*headMessage*/ undefined, containingMessageChain, errorOutputContainer); if (elaborated) { reportedError = true; @@ -59965,9 +61109,7 @@ var ts; var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; var issuedElaboration = false; if (!targetProp) { - var indexInfo = isTypeAssignableToKind(nameType, 296 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || - getIndexInfoOfType(target, 0 /* String */) || - undefined; + var indexInfo = getApplicableIndexInfo(target, nameType); if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) { issuedElaboration = true; ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature)); @@ -59998,9 +61140,9 @@ var ts; case 1: if (!(_i < _a.length)) return [3 /*break*/, 4]; prop = _a[_i]; - if (ts.isJsxSpreadAttribute(prop)) + if (ts.isJsxSpreadAttribute(prop) || isHyphenatedJsxName(ts.idText(prop.name))) return [3 /*break*/, 3]; - return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }]; + return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getStringLiteralType(ts.idText(prop.name)) }]; case 2: _b.sent(); _b.label = 3; @@ -60024,7 +61166,7 @@ var ts; case 1: if (!(i < node.children.length)) return [3 /*break*/, 5]; child = node.children[i]; - nameType = getLiteralType(i - memberOffset); + nameType = getNumberLiteralType(i - memberOffset); elem = getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic); if (!elem) return [3 /*break*/, 3]; return [4 /*yield*/, elem]; @@ -60043,7 +61185,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 284 /* JsxExpression */: + case 286 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -60052,9 +61194,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 274 /* JsxElement */: - case 275 /* JsxSelfClosingElement */: - case 278 /* JsxFragment */: + case 276 /* JsxElement */: + case 277 /* JsxSelfClosingElement */: + case 280 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -60068,7 +61210,7 @@ var ts; var containingElement = node.parent.parent; var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); - var childrenNameType = getLiteralType(childrenPropName); + var childrenNameType = getStringLiteralType(childrenPropName); var childrenTargetType = getIndexedAccessType(target, childrenNameType); var validChildren = ts.getSemanticJsxChildren(containingElement.children); if (!ts.length(validChildren)) { @@ -60123,7 +61265,7 @@ var ts; var tagNameText = ts.getTextOfNode(node.parent.tagName); var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); - var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); + var childrenTargetType = getIndexedAccessType(target, getStringLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } @@ -60148,7 +61290,7 @@ var ts; elem = node.elements[i]; if (ts.isOmittedExpression(elem)) return [3 /*break*/, 3]; - nameType = getLiteralType(i); + nameType = getNumberLiteralType(i); return [4 /*yield*/, { errorNode: elem, innerExpression: elem, nameType: nameType }]; case 2: _a.sent(); @@ -60202,11 +61344,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 169 /* SetAccessor */: return [3 /*break*/, 2]; - case 168 /* GetAccessor */: return [3 /*break*/, 2]; - case 166 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 290 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 289 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 171 /* SetAccessor */: return [3 /*break*/, 2]; + case 170 /* GetAccessor */: return [3 /*break*/, 2]; + case 167 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 292 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 291 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -60283,8 +61425,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 166 /* MethodDeclaration */ && - kind !== 165 /* MethodSignature */ && kind !== 167 /* Constructor */; + var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 167 /* MethodDeclaration */ && + kind !== 166 /* MethodSignature */ && kind !== 169 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -60418,8 +61560,7 @@ var ts; t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && - !t.stringIndexInfo && - !t.numberIndexInfo; + t.indexInfos.length === 0; } function isEmptyObjectType(type) { return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : @@ -60433,7 +61574,7 @@ var ts; type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); } function isStringIndexSignatureOnlyType(type) { - return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfoOfType(type, 0 /* String */) && !getIndexInfoOfType(type, 1 /* Number */) || + return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || false; } @@ -60538,9 +61679,10 @@ var ts; } } else { - if (!(source.flags & 3145728 /* UnionOrIntersection */) && !(target.flags & 3145728 /* UnionOrIntersection */) && - source.flags !== target.flags && !(source.flags & 469237760 /* Substructure */)) + if (source.flags !== target.flags) return false; + if (source.flags & 67358815 /* Singleton */) + return true; } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, 0 /* None */, relation)); @@ -60554,7 +61696,7 @@ var ts; return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { @@ -60631,7 +61773,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInfo, false)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -60674,7 +61816,7 @@ var ts; reportError.apply(void 0, stack[0]); if (info) { // Actually do the last relation error - reportRelationError.apply(void 0, __spreadArray([/*headMessage*/ undefined], info)); + reportRelationError.apply(void 0, __spreadArray([/*headMessage*/ undefined], info, false)); } return; } @@ -60763,12 +61905,12 @@ var ts; var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); var originalValue = msg.elidedInCompatabilityPyramid; msg.elidedInCompatabilityPyramid = false; // Temporarily override elision to ensure error is reported - reportError.apply(void 0, __spreadArray([msg], args)); + reportError.apply(void 0, __spreadArray([msg], args, false)); msg.elidedInCompatabilityPyramid = originalValue; } if (info) { // Actually do the last relation error - reportRelationError.apply(void 0, __spreadArray([/*headMessage*/ undefined], info)); + reportRelationError.apply(void 0, __spreadArray([/*headMessage*/ undefined], info, false)); } } function reportError(message, arg0, arg1, arg2, arg3) { @@ -61089,12 +62231,12 @@ var ts; } } function isIdenticalTo(source, target) { - var flags = source.flags & target.flags; - if (!(flags & 469237760 /* Substructure */)) { + if (source.flags !== target.flags) return 0 /* False */; - } + if (source.flags & 67358815 /* Singleton */) + return -1 /* True */; traceUnionsOrIntersectionsTooLarge(source, target); - if (flags & 3145728 /* UnionOrIntersection */) { + if (source.flags & 3145728 /* UnionOrIntersection */) { var result_7 = eachTypeRelatedToSomeType(source, target); if (result_7) { result_7 &= eachTypeRelatedToSomeType(target, source); @@ -61105,9 +62247,10 @@ var ts; } function getTypeOfPropertyInTypes(types, name) { var appendPropType = function (propTypes, type) { + var _a; type = getApparentType(type); var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); - var propType = prop && getTypeOfSymbol(prop) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1 /* Number */) || getIndexTypeOfType(type, 0 /* String */) || undefinedType; + var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType; return ts.append(propTypes, propType); }; return getUnionType(ts.reduceLeft(types, appendPropType, /*initial*/ undefined) || ts.emptyArray); @@ -61128,7 +62271,7 @@ var ts; reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; } - var _loop_16 = function (prop) { + var _loop_18 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { @@ -61191,7 +62334,7 @@ var ts; }; for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { var prop = _b[_i]; - var state_5 = _loop_16(prop); + var state_5 = _loop_18(prop); if (typeof state_5 === "object") return state_5.value; } @@ -61503,7 +62646,7 @@ var ts; // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't // appear to be comparable to '2'. if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { - var constraints = ts.sameMap(source.types, function (t) { return t.flags & 131068 /* Primitive */ ? t : getBaseConstraintOfType(t) || unknownType; }); + var constraints = ts.sameMap(source.types, getBaseConstraintOrType); if (constraints !== source.types) { source = getIntersectionType(constraints); if (!(source.flags & 2097152 /* Intersection */)) { @@ -61647,8 +62790,8 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 2 /* Writing */ | (baseObjectType !== objectType ? 1 /* NoIndexSignatures */ : 0); - var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, target.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, accessFlags); + var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0); + var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); if (constraint) { if (reportErrors && originalErrorInfo) { // create a new chain for the constraint error @@ -61872,7 +63015,7 @@ var ts; return 0 /* False */; } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && - !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) { + !isTupleType(source) && !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) { // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. @@ -61890,7 +63033,7 @@ var ts; } else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { - return isRelatedTo(getIndexTypeOfType(source, 1 /* Number */) || anyType, getIndexTypeOfType(target, 1 /* Number */) || anyType, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple @@ -61917,10 +63060,7 @@ var ts; if (result) { result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); if (result) { - result &= indexTypesRelatedTo(source, target, 0 /* String */, sourceIsPrimitive, reportStructuralErrors, intersectionState); - if (result) { - result &= indexTypesRelatedTo(source, target, 1 /* Number */, sourceIsPrimitive, reportStructuralErrors, intersectionState); - } + result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState); } } } @@ -62046,7 +63186,7 @@ var ts; var numCombinations = 1; for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) { var sourceProperty = sourcePropertiesFiltered_1[_i]; - numCombinations *= countTypes(getTypeOfSymbol(sourceProperty)); + numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); @@ -62058,7 +63198,7 @@ var ts; var excludedProperties = new ts.Set(); for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; - var sourcePropertyType = getTypeOfSymbol(sourceProperty); + var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ ? sourcePropertyType.types : [sourcePropertyType]; @@ -62068,11 +63208,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_17 = function (combination) { + var _loop_19 = function (combination) { var hasMatch = false; outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) { var type = _d[_c]; - var _loop_18 = function (i) { + var _loop_20 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfType(type, sourceProperty.escapedName); if (!targetProperty) @@ -62088,7 +63228,7 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_7 = _loop_18(i); + var state_7 = _loop_20(i); switch (state_7) { case "continue-outer": continue outer; } @@ -62102,7 +63242,7 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_6 = _loop_17(combination); + var state_6 = _loop_19(combination); if (typeof state_6 === "object") return state_6.value; } @@ -62115,15 +63255,12 @@ var ts; result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); if (result) { result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false); - if (result) { - result &= indexTypesRelatedTo(source, type, 0 /* String */, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); + if (result && !(isTupleType(source) && isTupleType(type))) { // Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the // element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems // with index type assignability as the types for the excluded discriminants are still included // in the index type. - if (result && !(isTupleType(source) && isTupleType(type))) { - result &= indexTypesRelatedTo(source, type, 1 /* Number */, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); - } + result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); } } } @@ -62151,46 +63288,9 @@ var ts; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); - var source = getTypeOfSourceProperty(sourceProp); - if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { - // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes - var links = getSymbolLinks(targetProp); - ts.Debug.assertIsDefined(links.deferralParent); - ts.Debug.assertIsDefined(links.deferralConstituents); - var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); - var result_12 = unionParent ? 0 /* False */ : -1 /* True */; - var targetTypes = links.deferralConstituents; - for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { - var targetType = targetTypes_3[_i]; - var related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, unionParent ? 0 : 2 /* Target */); - if (!unionParent) { - if (!related) { - // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - result_12 &= related; - } - else { - if (related) { - return related; - } - } - } - if (unionParent && !result_12 && targetIsOptional) { - result_12 = isRelatedTo(source, undefinedType); - } - if (unionParent && !result_12 && reportErrors) { - // The easiest way to get the right errors here is to un-defer (which may be costly) - // If it turns out this is too costly too often, we can replicate the error handling logic within - // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union - // type on which to hand discriminable properties, which we are expressly trying to avoid here) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - return result_12; - } - else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState); - } + var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); + var effectiveSource = getTypeOfSourceProperty(sourceProp); + return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); @@ -62270,7 +63370,7 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, __spreadArray([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArray([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target), false)); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } @@ -62319,7 +63419,7 @@ var ts; } return 0 /* False */; } - if (!targetRestFlag && sourceRestFlag) { + if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { if (sourceMinLength < targetMinLength) { reportError(ts.Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, targetMinLength); @@ -62367,13 +63467,14 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? sourceTypeArguments[sourceIndex] : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : targetType; + var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); var related = isRelatedTo(sourceType, targetCheckType, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - if (reportErrors) { + if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { reportIncompatibleError(ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target, sourceIndex, i); } @@ -62404,7 +63505,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { + if (!(sourceType.flags & 32768 /* Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -62423,7 +63524,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { return 0 /* False */; } @@ -62517,7 +63618,7 @@ var ts; var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 167 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 167 /* Constructor */)) { + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 169 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 169 /* Constructor */)) { var constructSignatureToString = function (signature) { return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); }; @@ -62583,8 +63684,9 @@ var ts; } return result; } - function eachPropertyRelatedTo(source, target, kind, reportErrors) { + function membersRelatedToIndexInfo(source, targetInfo, reportErrors) { var result = -1 /* True */; + var keyType = targetInfo.keyType; var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { var prop = props_2[_i]; @@ -62592,16 +63694,12 @@ var ts; if (isIgnoredJsxProperty(source, prop)) { continue; } - var nameType = getSymbolLinks(prop).nameType; - if (nameType && nameType.flags & 8192 /* UniqueESSymbol */) { - continue; - } - if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { - var propType = getTypeOfSymbol(prop); - var type = propType.flags & 32768 /* Undefined */ || !(kind === 0 /* String */ && prop.flags & 16777216 /* Optional */) + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) { + var propType = getNonMissingTypeOfSymbol(prop); + var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) ? propType : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, target, reportErrors); + var related = isRelatedTo(type, targetInfo.type, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); @@ -62611,67 +63709,77 @@ var ts; result &= related; } } + for (var _a = 0, _b = getIndexInfosOfType(source); _a < _b.length; _a++) { + var info = _b[_a]; + if (isApplicableIndexType(info.keyType, keyType)) { + var related = indexInfoRelatedTo(info, targetInfo, reportErrors); + if (!related) { + return 0 /* False */; + } + result &= related; + } + } return result; } - function indexTypeRelatedTo(sourceType, targetType, reportErrors) { - var related = isRelatedTo(sourceType, targetType, reportErrors); + function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { + var related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors); if (!related && reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); + if (sourceInfo.keyType === targetInfo.keyType) { + reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); + } + else { + reportError(ts.Diagnostics._0_and_1_index_signatures_are_incompatible, typeToString(sourceInfo.keyType), typeToString(targetInfo.keyType)); + } } return related; } - function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors, intersectionState) { + function indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportErrors, intersectionState) { if (relation === identityRelation) { - return indexTypesIdenticalTo(source, target, kind); + return indexSignaturesIdenticalTo(source, target); } - var targetType = getIndexTypeOfType(target, kind); - if (!targetType) { - return -1 /* True */; - } - if (targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { - // An index signature of type `any` permits assignment from everything but primitives, - // provided that there is also a `string` index signature of type `any`. - var stringIndexType = kind === 0 /* String */ ? targetType : getIndexTypeOfType(target, 0 /* String */); - if (stringIndexType && stringIndexType.flags & 1 /* Any */) { - return -1 /* True */; + var indexInfos = getIndexInfosOfType(target); + var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; }); + var result = -1 /* True */; + for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) { + var targetInfo = indexInfos_3[_i]; + var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : + typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); + if (!related) { + return 0 /* False */; } + result &= related; } - if (isGenericMappedType(source)) { - // A generic mapped type { [P in K]: T } is related to a type with an index signature - // { [x: string]: U }, and optionally with an index signature { [x: number]: V }, - // if T is related to U and V. - return getIndexTypeOfType(target, 0 /* String */) ? isRelatedTo(getTemplateTypeFromMappedType(source), targetType, reportErrors) : 0 /* False */; - } - var indexType = getIndexTypeOfType(source, kind) || kind === 1 /* Number */ && getIndexTypeOfType(source, 0 /* String */); - if (indexType) { - return indexTypeRelatedTo(indexType, targetType, reportErrors); + return result; + } + function typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState) { + var sourceInfo = getApplicableIndexInfo(source, targetInfo.keyType); + if (sourceInfo) { + return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) { // Intersection constituents are never considered to have an inferred index signature - var related = eachPropertyRelatedTo(source, targetType, kind, reportErrors); - if (related && kind === 0 /* String */) { - var numberIndexType = getIndexTypeOfType(source, 1 /* Number */); - if (numberIndexType) { - related &= indexTypeRelatedTo(numberIndexType, targetType, reportErrors); - } - } - return related; + return membersRelatedToIndexInfo(source, targetInfo, reportErrors); } if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source)); } return 0 /* False */; } - function indexTypesIdenticalTo(source, target, indexKind) { - var targetInfo = getIndexInfoOfType(target, indexKind); - var sourceInfo = getIndexInfoOfType(source, indexKind); - if (!sourceInfo && !targetInfo) { - return -1 /* True */; + function indexSignaturesIdenticalTo(source, target) { + var sourceInfos = getIndexInfosOfType(source); + var targetInfos = getIndexInfosOfType(target); + if (sourceInfos.length !== targetInfos.length) { + return 0 /* False */; } - if (sourceInfo && targetInfo && sourceInfo.isReadonly === targetInfo.isReadonly) { - return isRelatedTo(sourceInfo.type, targetInfo.type); + for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) { + var targetInfo = targetInfos_1[_i]; + var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType); + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type) && sourceInfo.isReadonly === targetInfo.isReadonly)) { + return 0 /* False */; + } } - return 0 /* False */; + return -1 /* True */; } function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { if (!sourceSignature.declaration || !targetSignature.declaration) { @@ -62767,10 +63875,8 @@ var ts; function isWeakType(type) { if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && - !resolved.stringIndexInfo && !resolved.numberIndexInfo && - resolved.properties.length > 0 && - ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); + return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && + resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); } if (type.flags & 2097152 /* Intersection */) { return ts.every(type.types, isWeakType); @@ -62815,7 +63921,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_19 = function (tp) { + var _loop_21 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -62847,7 +63953,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_19(tp); + _loop_21(tp); } cache.variances = variances; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -63157,8 +64263,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -63219,6 +64325,14 @@ var ts; } type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; var target = type.target; + if (ts.getObjectFlags(target) & 1 /* Class */) { + var baseTypeNode = getBaseTypeNodeOfClass(target); + // A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only + // check for base types specified as simple qualified names. + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 204 /* PropertyAccessExpression */) { + return undefined; + } + } var bases = getBaseTypes(target); if (bases.length !== 1) { return undefined; @@ -63233,9 +64347,12 @@ var ts; type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; return type.cachedEquivalentBaseType = instantiatedBase; } + function isEmptyLiteralType(type) { + return strictNullChecks ? type === implicitNeverType : type === undefinedWideningType; + } function isEmptyArrayLiteralType(type) { var elementType = getElementTypeOfArrayType(type); - return strictNullChecks ? elementType === implicitNeverType : elementType === undefinedWideningType; + return !!elementType && isEmptyLiteralType(elementType); } function isTupleLikeType(type) { return isTupleType(type) || !!getPropertyOfType(type, "0"); @@ -63362,8 +64479,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getFalsyFlags(t); } return result; @@ -63411,9 +64528,10 @@ var ts; missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } - function getOptionalType(type) { + function getOptionalType(type, isProperty) { + if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates @@ -63434,11 +64552,8 @@ var ts; function addOptionalTypeMarker(type) { return strictNullChecks ? getUnionType([type, optionalType]) : type; } - function isNotOptionalTypeMarker(type) { - return type !== optionalType; - } function removeOptionalTypeMarker(type) { - return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type; + return strictNullChecks ? removeType(type, optionalType) : type; } function propagateOptionalTypeMarker(type, node, wasOptional) { return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type; @@ -63448,6 +64563,15 @@ var ts; ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : exprType; } + function removeMissingType(type, isOptional) { + return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type; + } + function containsMissingType(type) { + return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + } + function removeMissingOrUndefinedType(type) { + return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */); + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -63521,7 +64645,7 @@ var ts; } var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); - var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); + var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos); regularNew.flags = resolved.flags; regularNew.objectFlags |= resolved.objectFlags & ~16384 /* FreshLiteral */; type.regularType = regularNew; @@ -63580,7 +64704,7 @@ var ts; if (cached) { return cached; } - var result = createSymbolWithType(prop, undefinedType); + var result = createSymbolWithType(prop, missingType); result.flags |= 16777216 /* Optional */; undefinedProperties.set(prop.escapedName, result); return result; @@ -63599,9 +64723,7 @@ var ts; } } } - var stringIndexInfo = getIndexInfoOfType(type, 0 /* String */); - var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); - var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); + var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); })); result.objectFlags |= (ts.getObjectFlags(type) & (8192 /* JSLiteral */ | 524288 /* NonInferrableType */)); // Retain js literal flag through widening return result; } @@ -63699,12 +64821,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 217 /* BinaryExpression */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: + case 219 /* BinaryExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 161 /* Parameter */: + case 162 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -63719,23 +64841,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 199 /* BindingElement */: + case 201 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 309 /* JSDocFunctionType */: + case 312 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 252 /* FunctionDeclaration */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 254 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 3 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -63749,7 +64871,7 @@ var ts; wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 191 /* MappedType */: + case 193 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -63891,8 +65013,8 @@ var ts; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 255 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 298 /* SourceFile */ ? true : n.kind === 257 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 257 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 300 /* SourceFile */ ? true : n.kind === 259 /* ModuleDeclaration */ ? false : "quit"; })); } return false; } @@ -63917,8 +65039,8 @@ var ts; } members.set(name, literalProp); }); - var indexInfo = type.flags & 4 /* String */ ? createIndexInfo(emptyObjectType, /*isReadonly*/ false) : undefined; - return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined); + var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; + return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos); } /** * Infer a suitable input type for a homomorphic mapped type { [P in keyof T]: X }. We construct @@ -63952,7 +65074,7 @@ var ts; function createReverseMappedType(source, target, constraint) { // We consider a source type reverse mappable if it has a string index signature or if // it has one or more properties and is of a partially inferable type. - if (!(getIndexInfoOfType(source, 0 /* String */) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) { + if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) { return undefined; } // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been @@ -64166,8 +65288,8 @@ var ts; } function addMatch(s, p) { var matchType = s === seg ? - getLiteralType(getSourceText(s).slice(pos, p)) : - getTemplateLiteralType(__spreadArray(__spreadArray([sourceTexts[seg].slice(pos)], sourceTexts.slice(seg + 1, s)), [getSourceText(s).slice(0, p)]), sourceTypes.slice(seg, s)); + getStringLiteralType(getSourceText(s).slice(pos, p)) : + getTemplateLiteralType(__spreadArray(__spreadArray([sourceTexts[seg].slice(pos)], sourceTexts.slice(seg + 1, s), true), [getSourceText(s).slice(0, p)], false), sourceTypes.slice(seg, s)); matches.push(matchType); seg = s; pos = p; @@ -64486,8 +65608,8 @@ var ts; } function getSingleTypeVariableFromIntersectionTypes(types) { var typeVariable; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var type = types_16[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var type = types_15[_i]; var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; @@ -64617,10 +65739,8 @@ var ts; // If no inferences can be made to K's constraint, infer from a union of the property types // in the source to the template type X. var propTypes = ts.map(getPropertiesOfType(source), getTypeOfSymbol); - var stringIndexType = getIndexTypeOfType(source, 0 /* String */); - var numberIndexInfo = getNonEnumNumberIndexInfo(source); - var numberIndexType = numberIndexInfo && numberIndexInfo.type; - inferFromTypes(getUnionType(ts.append(ts.append(propTypes, stringIndexType), numberIndexType)), getTemplateTypeFromMappedType(target)); + var indexTypes = ts.map(getIndexInfosOfType(source), function (info) { return info !== enumNumberIndexInfo ? info.type : neverType; }); + inferFromTypes(getUnionType(ts.concatenate(propTypes, indexTypes)), getTemplateTypeFromMappedType(target)); return true; } return false; @@ -64767,34 +65887,50 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 166 /* MethodDeclaration */ || kind === 165 /* MethodSignature */ || kind === 167 /* Constructor */; + bivariant = bivariant || kind === 167 /* MethodDeclaration */ || kind === 166 /* MethodSignature */ || kind === 169 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { - var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); - if (targetStringIndexType) { - var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || - getImplicitIndexTypeOfType(source, 0 /* String */); - if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; + var indexInfos = getIndexInfosOfType(target); + if (isObjectTypeWithInferableIndex(source)) { + for (var _i = 0, indexInfos_4 = indexInfos; _i < indexInfos_4.length; _i++) { + var targetInfo = indexInfos_4[_i]; + var propTypes = []; + for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { + var prop = _b[_a]; + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { + var propType = getTypeOfSymbol(prop); + propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType); + } + } + for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) { + var info = _d[_c]; + if (isApplicableIndexType(info.keyType, targetInfo.keyType)) { + propTypes.push(info.type); + } + } + if (propTypes.length) { + inferWithPriority(getUnionType(propTypes), targetInfo.type, priority); + } } } - var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); - if (targetNumberIndexType) { - var sourceIndexType = getIndexTypeOfType(source, 1 /* Number */) || - getIndexTypeOfType(source, 0 /* String */) || - getImplicitIndexTypeOfType(source, 1 /* Number */); - if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + for (var _e = 0, indexInfos_5 = indexInfos; _e < indexInfos_5.length; _e++) { + var targetInfo = indexInfos_5[_e]; + var sourceInfo = getApplicableIndexInfo(source, targetInfo.keyType); + if (sourceInfo) { + inferWithPriority(sourceInfo.type, targetInfo.type, priority); } } } } function isTypeOrBaseIdenticalTo(s, t) { - return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); + return exactOptionalPropertyTypes && t === missingType ? s === t : + (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */)); } function isTypeCloselyMatchedBy(s, t) { return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || @@ -64947,7 +66083,7 @@ var ts; case "BigUint64Array": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later; default: - if (node.parent.kind === 290 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 292 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -64960,7 +66096,8 @@ var ts; if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), - /*excludeGlobals*/ false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; + /*excludeGlobals*/ false, + /*issueSuggestions*/ true) || unknownSymbol; } return links.resolvedSymbol; } @@ -64968,7 +66105,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 177 /* TypeQuery */ ? true : n.kind === 78 /* Identifier */ || n.kind === 158 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 179 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 159 /* QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -64976,16 +66113,19 @@ var ts; // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 226 /* NonNullExpression */: - case 208 /* ParenthesizedExpression */: + case 228 /* NonNullExpression */: + case 210 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 159 /* QualifiedName */: + var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); + return left && left + "." + node.right.escapedText; + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -64996,40 +66136,42 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 208 /* ParenthesizedExpression */: - case 226 /* NonNullExpression */: + case 210 /* ParenthesizedExpression */: + case 228 /* NonNullExpression */: return isMatchingReference(source, target.expression); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 227 /* MetaProperty */: - return target.kind === 227 /* MetaProperty */ + case 229 /* MetaProperty */: + return target.kind === 229 /* MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - return target.kind === 78 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 250 /* VariableDeclaration */ || target.kind === 199 /* BindingElement */) && - getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 107 /* ThisKeyword */: - return target.kind === 107 /* ThisKeyword */; - case 105 /* SuperKeyword */: - return target.kind === 105 /* SuperKeyword */; - case 226 /* NonNullExpression */: - case 208 /* ParenthesizedExpression */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + return ts.isThisInTypeQuery(source) ? + target.kind === 108 /* ThisKeyword */ : + target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 252 /* VariableDeclaration */ || target.kind === 201 /* BindingElement */) && + getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); + case 108 /* ThisKeyword */: + return target.kind === 108 /* ThisKeyword */; + case 106 /* SuperKeyword */: + return target.kind === 106 /* SuperKeyword */; + case 228 /* NonNullExpression */: + case 210 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); } return false; @@ -65037,13 +66179,38 @@ var ts; // Given a source x, check if target matches x or is an && operation with an operand that matches x. function containsTruthyCheck(source, target) { return isMatchingReference(source, target) || - (target.kind === 217 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && + (target.kind === 219 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right))); } + function getPropertyAccess(expr) { + if (ts.isAccessExpression(expr)) { + return expr; + } + if (ts.isIdentifier(expr)) { + var symbol = getResolvedSymbol(expr); + if (isConstVariable(symbol)) { + var declaration = symbol.valueDeclaration; + // Given 'const x = obj.kind', allow 'x' as an alias for 'obj.kind' + if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer)) { + return declaration.initializer; + } + // Given 'const { kind: x } = obj', allow 'x' as an alias for 'obj.kind' + if (ts.isBindingElement(declaration) && !declaration.initializer) { + var parent = declaration.parent.parent; + if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer))) { + return declaration; + } + } + } + } + return undefined; + } function getAccessedPropertyName(access) { - return access.kind === 202 /* PropertyAccessExpression */ ? access.name.escapedText : - ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : - undefined; + var propertyName; + return access.kind === 204 /* PropertyAccessExpression */ ? access.name.escapedText : + access.kind === 205 /* ElementAccessExpression */ && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + access.kind === 201 /* BindingElement */ && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) : + undefined; } function containsMatchingReference(source, target) { while (ts.isAccessExpression(source)) { @@ -65070,7 +66237,7 @@ var ts; if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && - !maybeTypeOfKind(getTypeOfSymbol(prop), 465829888 /* Instantiable */); + !maybeTypeOfKind(getTypeOfSymbol(prop), 465829888 /* Instantiable */ & ~134217728 /* TemplateLiteral */); } return !!prop.isDiscriminantProperty; } @@ -65098,7 +66265,7 @@ var ts; function mapTypesByKeyProperty(types, name) { var map = new ts.Map(); var count = 0; - var _loop_20 = function (type) { + var _loop_22 = function (type) { if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { @@ -65122,9 +66289,9 @@ var ts; } } }; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var type = types_17[_i]; - var state_8 = _loop_20(type); + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var type = types_16[_i]; + var state_8 = _loop_22(type); if (typeof state_8 === "object") return state_8.value; } @@ -65166,7 +66333,7 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 289 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 291 /* PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); var propType = propNode && getTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); @@ -65183,7 +66350,7 @@ var ts; } } } - if (expression.expression.kind === 202 /* PropertyAccessExpression */ && + if (expression.expression.kind === 204 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -65321,14 +66488,12 @@ var ts; type; } function getTypeOfDestructuredProperty(type, name) { + var _a; var nameType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(nameType)) return errorType; var text = getPropertyNameFromType(nameType); - return getTypeOfPropertyOfType(type, text) || - isNumericLiteralName(text) && includeUndefinedInIndexSignature(getIndexTypeOfType(type, 1 /* Number */)) || - includeUndefinedInIndexSignature(getIndexTypeOfType(type, 0 /* String */)) || - errorType; + return getTypeOfPropertyOfType(type, text) || includeUndefinedInIndexSignature((_a = getApplicableIndexInfoForName(type, text)) === null || _a === void 0 ? void 0 : _a.type) || errorType; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || @@ -65346,15 +66511,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 200 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 289 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 202 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 291 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 217 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 240 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 219 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 242 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -65371,21 +66536,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: return stringType; - case 240 /* ForOfStatement */: + case 242 /* ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 211 /* DeleteExpression */: + case 213 /* DeleteExpression */: return undefinedType; - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 221 /* SpreadElement */: + case 223 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -65393,7 +66558,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 197 /* ObjectBindingPattern */ ? + var type = pattern.kind === 199 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -65411,35 +66576,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 239 /* ForInStatement */) { + if (node.parent.parent.kind === 241 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 240 /* ForOfStatement */) { + if (node.parent.parent.kind === 242 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 250 /* VariableDeclaration */ ? + return node.kind === 252 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 250 /* VariableDeclaration */ && node.initializer && + return node.kind === 252 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 199 /* BindingElement */ && node.parent.kind === 217 /* BinaryExpression */ && + node.kind !== 201 /* BindingElement */ && node.parent.kind === 219 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -65449,13 +66614,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 208 /* ParenthesizedExpression */ || - parent.kind === 217 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || - parent.kind === 217 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 210 /* ParenthesizedExpression */ || + parent.kind === 219 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || + parent.kind === 219 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 285 /* CaseClause */) { + if (clause.kind === 287 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -65475,7 +66640,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 285 /* CaseClause */) { + if (clause.kind === 287 /* CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -65548,6 +66713,9 @@ var ts; } return type.flags & 131072 /* Never */ || f(type) ? type : neverType; } + function removeType(type, targetType) { + return filterType(type, function (t) { return t !== targetType; }); + } function countTypes(type) { return type.flags & 1048576 /* Union */ ? type.types.length : 1; } @@ -65562,8 +66730,8 @@ var ts; var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types; var mappedTypes; var changed = false; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { @@ -65650,8 +66818,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { - var t = types_19[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -65667,21 +66835,21 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 204 /* CallExpression */ + parent.parent.kind === 206 /* CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 203 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 205 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 217 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 62 /* EqualsToken */ && + parent.parent.kind === 219 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(declaration) { - return (declaration.kind === 250 /* VariableDeclaration */ || declaration.kind === 161 /* Parameter */ || - declaration.kind === 164 /* PropertyDeclaration */ || declaration.kind === 163 /* PropertySignature */) && + return (declaration.kind === 252 /* VariableDeclaration */ || declaration.kind === 162 /* Parameter */ || + declaration.kind === 165 /* PropertyDeclaration */ || declaration.kind === 164 /* PropertySignature */) && !!ts.getEffectiveTypeAnnotationNode(declaration); } function getExplicitTypeOfSymbol(symbol, diagnostic) { @@ -65700,7 +66868,7 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 240 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { @@ -65721,14 +66889,14 @@ var ts; function getTypeOfDottedName(node, diagnostic) { if (!(node.flags & 16777216 /* InWithStatement */)) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return getExplicitThisType(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 202 /* PropertyAccessExpression */: { + case 204 /* PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -65746,7 +66914,7 @@ var ts; } return undefined; } - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -65760,10 +66928,10 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 234 /* ExpressionStatement */) { + if (node.parent.kind === 236 /* ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 105 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -65804,7 +66972,7 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr); - return node.kind === 94 /* FalseKeyword */ || node.kind === 217 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + return node.kind === 95 /* FalseKeyword */ || node.kind === 219 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { @@ -65892,7 +67060,7 @@ var ts; flow = flow.antecedent; } else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 105 /* SuperKeyword */) { + if (flow.node.expression.kind === 106 /* SuperKeyword */) { return true; } flow = flow.antecedent; @@ -65919,15 +67087,28 @@ var ts; } } } - function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { + function isConstantReference(node) { + switch (node.kind) { + case 79 /* Identifier */: + var symbol = getResolvedSymbol(node); + return isConstVariable(symbol) || !!symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 162 /* Parameter */ && !isParameterAssigned(symbol); + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: + // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. + return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); + } + return false; + } + function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer) { if (initialType === void 0) { initialType = declaredType; } var key; var isKeySet = false; var flowDepth = 0; + var inlineLevel = 0; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 536624127 /* Narrowable */)) { + if (!reference.flowNode) { return declaredType; } flowInvocationCount++; @@ -65939,7 +67120,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 226 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 228 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -66023,9 +67204,9 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 202 /* PropertyAccessExpression */ && - reference.kind !== 203 /* ElementAccessExpression */ && - reference.kind !== 107 /* ThisKeyword */) { + reference.kind !== 204 /* PropertyAccessExpression */ && + reference.kind !== 205 /* ElementAccessExpression */ && + reference.kind !== 108 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -66049,7 +67230,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 250 /* VariableDeclaration */ || node.kind === 199 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 252 /* VariableDeclaration */ || node.kind === 201 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -66089,14 +67270,14 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 209 /* FunctionExpression */ || init.kind === 210 /* ArrowFunction */)) { + if (init && (init.kind === 211 /* FunctionExpression */ || init.kind === 212 /* ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 239 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 241 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -66104,10 +67285,10 @@ var ts; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr); - if (node.kind === 94 /* FalseKeyword */) { + if (node.kind === 95 /* FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 217 /* BinaryExpression */) { + if (node.kind === 219 /* BinaryExpression */) { if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } @@ -66138,7 +67319,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 204 /* CallExpression */ ? + var expr = node.kind === 206 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -66146,7 +67327,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 204 /* CallExpression */) { + if (node.kind === 206 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -66194,7 +67375,7 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 212 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 214 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { @@ -66202,12 +67383,13 @@ var ts; if (optionalChainContainsReference(expr, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); } - else if (expr.kind === 212 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + else if (expr.kind === 214 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); } } - if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeBySwitchOnDiscriminantProperty(type, expr, flow.switchStatement, flow.clauseStart, flow.clauseEnd); + var access = getDiscriminantPropertyAccess(expr, type); + if (access) { + type = narrowTypeBySwitchOnDiscriminantProperty(type, access, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } } return createFlowType(type, isIncomplete(flowType)); @@ -66362,16 +67544,13 @@ var ts; } return result; } - function isMatchingReferenceDiscriminant(expr, computedType) { + function getDiscriminantPropertyAccess(expr, computedType) { + var access, name; var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (!(type.flags & 1048576 /* Union */) || !ts.isAccessExpression(expr)) { - return false; - } - var name = getAccessedPropertyName(expr); - if (name === undefined) { - return false; - } - return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(type, name); + return type.flags & 1048576 /* Union */ && (access = getPropertyAccess(expr)) && (name = getAccessedPropertyName(access)) && + isMatchingReference(reference, ts.isAccessExpression(access) ? access.expression : access.parent.parent.initializer) && + isDiscriminantProperty(type, name) ? + access : undefined; } function narrowTypeByDiscriminant(type, access, narrowType) { var propName = getAccessedPropertyName(access); @@ -66394,10 +67573,10 @@ var ts; if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { var keyPropertyName = getKeyPropertyName(type); if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { - var candidate_2 = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); - if (candidate_2) { - return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate_2 : - isUnitType(getTypeOfPropertyOfType(candidate_2, keyPropertyName) || unknownType) ? filterType(type, function (t) { return t !== candidate_2; }) : + var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); + if (candidate) { + return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate : + isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) : type; } } @@ -66421,37 +67600,34 @@ var ts; if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, type)) { - return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); + var access = getDiscriminantPropertyAccess(expr, type); + if (access) { + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } return type; } function isTypePresencePossible(type, propName, assumeTrue) { - if (getIndexInfoOfType(type, 0 /* String */)) { - return true; - } var prop = getPropertyOfType(type, propName); if (prop) { return prop.flags & 16777216 /* Optional */ ? true : assumeTrue; } - return !assumeTrue; + return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue; } - function narrowByInKeyword(type, literal, assumeTrue) { + function narrowByInKeyword(type, name, assumeTrue) { if (type.flags & 1048576 /* Union */ || type.flags & 524288 /* Object */ && declaredType !== type || isThisTypeParameter(type) || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { - var propName_1 = ts.escapeLeadingUnderscores(literal.text); - return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); + return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); }); } return type; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: @@ -66460,10 +67636,10 @@ var ts; var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 212 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 214 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 212 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 214 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -66480,11 +67656,13 @@ var ts; type = narrowTypeByOptionalChainContainment(type, operator, left, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left, type)) { - return narrowTypeByDiscriminantProperty(type, left, operator, right, assumeTrue); + var leftAccess = getDiscriminantPropertyAccess(left, type); + if (leftAccess) { + return narrowTypeByDiscriminantProperty(type, leftAccess, operator, right, assumeTrue); } - if (isMatchingReferenceDiscriminant(right, type)) { - return narrowTypeByDiscriminantProperty(type, right, operator, left, assumeTrue); + var rightAccess = getDiscriminantPropertyAccess(right, type); + if (rightAccess) { + return narrowTypeByDiscriminantProperty(type, rightAccess, operator, left, assumeTrue); } if (isMatchingConstructorReference(left)) { return narrowTypeByConstructor(type, operator, right, assumeTrue); @@ -66493,16 +67671,35 @@ var ts; return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 100 /* InKeyword */: + case 101 /* InKeyword */: var target = getReferenceCandidate(expr.right); - if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { - return narrowByInKeyword(type, expr.left, assumeTrue); + var leftType = getTypeOfNode(expr.left); + if (leftType.flags & 128 /* StringLiteral */) { + var name = ts.escapeLeadingUnderscores(leftType.value); + if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && + getAccessedPropertyName(reference) === name) { + return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + } + if (isMatchingReference(reference, target)) { + return narrowByInKeyword(type, name, assumeTrue); + } } break; case 27 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); + // Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those + // expressions down to individual conditional control flows. However, we may encounter them when analyzing + // aliased conditional expressions. + case 55 /* AmpersandAmpersandToken */: + return assumeTrue ? + narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) : + getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]); + case 56 /* BarBarToken */: + return assumeTrue ? + getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) : + narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); } return type; } @@ -66582,7 +67779,7 @@ var ts; if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { // The pattern x && typeof x === 'object', where x is of type unknown, narrows x to type object. We don't // need to check for the reverse typeof x === 'object' && x since that already narrows correctly. - if (typeOfExpr.parent.parent.kind === 217 /* BinaryExpression */) { + if (typeOfExpr.parent.parent.kind === 219 /* BinaryExpression */) { var expr = typeOfExpr.parent.parent; if (expr.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) { return nonPrimitiveType; @@ -66857,6 +68054,16 @@ var ts; return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } + if (containsMissingType(type) && ts.isAccessExpression(reference) && ts.isPropertyAccessExpression(callExpression.expression)) { + var callAccess = callExpression.expression; + if (isMatchingReference(reference.expression, getReferenceCandidate(callAccess.expression)) && + ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) { + var argument = callExpression.arguments[0]; + if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) { + return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + } + } + } return type; } function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { @@ -66871,8 +68078,9 @@ var ts; !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(predicateArgument, type)) { - return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); + var access = getDiscriminantPropertyAccess(predicateArgument, type); + if (access) { + return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); } } } @@ -66887,20 +68095,35 @@ var ts; return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 78 /* Identifier */: - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 79 /* Identifier */: + // When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline + // up to five levels of aliased conditional expressions that are themselves declared as const variables. + if (!isMatchingReference(reference, expr) && inlineLevel < 5) { + var symbol = getResolvedSymbol(expr); + if (isConstVariable(symbol)) { + var declaration = symbol.valueDeclaration; + if (declaration && ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isConstantReference(reference)) { + inlineLevel++; + var result = narrowType(type, declaration.initializer, assumeTrue); + inlineLevel--; + return result; + } + } + } + // falls through + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 204 /* CallExpression */: + case 206 /* CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 208 /* ParenthesizedExpression */: - case 226 /* NonNullExpression */: + case 210 /* ParenthesizedExpression */: + case 228 /* NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -66912,8 +68135,9 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, type)) { - return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + var access = getDiscriminantPropertyAccess(expr, type); + if (access) { + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); } return type; } @@ -66924,7 +68148,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 78 /* Identifier */ || location.kind === 79 /* PrivateIdentifier */) { + if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -66943,14 +68167,14 @@ var ts; // to it at the given location. Since we have no control flow information for the // hypothetical reference (control flow information is created and attached by the // binder), we simply return the declared type of the symbol. - return getTypeOfSymbol(symbol); + return getNonMissingTypeOfSymbol(symbol); } function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 258 /* ModuleBlock */ || - node.kind === 298 /* SourceFile */ || - node.kind === 164 /* PropertyDeclaration */; + node.kind === 260 /* ModuleBlock */ || + node.kind === 300 /* SourceFile */ || + node.kind === 165 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -66972,10 +68196,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 161 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 162 /* Parameter */) { symbol.isAssigned = true; } } @@ -66985,13 +68209,13 @@ var ts; } } function isConstVariable(symbol) { - return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 161 /* Parameter */ && + declaration.kind === 162 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -67003,29 +68227,29 @@ var ts; return declaredType; } } - function isConstraintPosition(node) { + function isConstraintPosition(type, node) { var parent = node.parent; - // In an element access obj[x], we consider obj to be in a constraint position only when x is not - // of a generic type. This is because when both obj and x are of generic types T and K, we want - // the resulting type to be T[K]. - return parent.kind === 202 /* PropertyAccessExpression */ || - parent.kind === 204 /* CallExpression */ && parent.expression === node || - parent.kind === 203 /* ElementAccessExpression */ && parent.expression === node && - !isGenericIndexType(getTypeOfExpression(parent.argumentExpression)); + // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of + // a generic type without a nullable constraint and x is a generic type. This is because when both obj + // and x are of generic types T and K, we want the resulting type to be T[K]. + return parent.kind === 204 /* PropertyAccessExpression */ || + parent.kind === 206 /* CallExpression */ && parent.expression === node || + parent.kind === 205 /* ElementAccessExpression */ && parent.expression === node && + !(isGenericTypeWithoutNullableConstraint(type) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); } - function containsGenericType(type) { - return !!(type.flags & 465829888 /* Instantiable */ || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, containsGenericType)); + function isGenericTypeWithoutNullableConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */)); } - function hasContextualTypeWithNoGenericTypes(node) { + function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) { // Computing the contextual type for a child of a JSX element involves resolving the type of the // element's tag name, so we exclude that here to avoid circularities. var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && - getContextualType(node); - return contextualType && !someType(contextualType, containsGenericType); + getContextualType(node, 8 /* SkipBindingPatterns */); + return contextualType && !isGenericType(contextualType); } function getNarrowableTypeForReference(type, reference, checkMode) { // When the type of a reference is or contains an instantiable type with a union type constraint, and @@ -67037,7 +68261,7 @@ var ts; // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && - (isConstraintPosition(reference) || hasContextualTypeWithNoGenericTypes(reference)); + (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference)); return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { @@ -67073,9 +68297,13 @@ var ts; // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects if (symbol === argumentsSymbol) { + if (isInPropertyInitializerOrClassStaticBlock(node)) { + error(node, ts.Diagnostics.arguments_cannot_be_referenced_in_property_initializers); + return errorType; + } var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 210 /* ArrowFunction */) { + if (container.kind === 212 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { @@ -67100,7 +68328,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 253 /* ClassDeclaration */ + if (declaration.kind === 255 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -67112,14 +68340,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 222 /* ClassExpression */) { + else if (declaration.kind === 224 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 298 /* SourceFile */) { + while (container.kind !== 300 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 164 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { + if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -67175,7 +68403,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 161 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 162 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -67184,9 +68412,9 @@ var ts; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 209 /* FunctionExpression */ || - flowContainer.kind === 210 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 211 /* FunctionExpression */ || + flowContainer.kind === 212 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze @@ -67194,14 +68422,14 @@ var ts; // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 271 /* ExportSpecifier */) || - node.parent.kind === 226 /* NonNullExpression */ || - declaration.kind === 250 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 273 /* ExportSpecifier */) || + node.parent.kind === 228 /* NonNullExpression */ || + declaration.kind === 252 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); - var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized); + var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. @@ -67235,7 +68463,7 @@ var ts; (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 288 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 290 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -67250,7 +68478,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 251 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 253 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { @@ -67271,7 +68499,7 @@ var ts; // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 251 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 253 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -67290,7 +68518,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 208 /* ParenthesizedExpression */) { + while (current.parent.kind === 210 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -67298,7 +68526,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 215 /* PrefixUnaryExpression */ || current.parent.kind === 216 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 217 /* PrefixUnaryExpression */ || current.parent.kind === 218 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } @@ -67311,7 +68539,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 164 /* PropertyDeclaration */ || container.kind === 167 /* Constructor */) { + if (container.kind === 165 /* PropertyDeclaration */ || container.kind === 169 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -67346,47 +68574,48 @@ var ts; } } } + function checkThisInStaticClassFieldInitializerInDecoratedClass(thisExpression, container) { + if (ts.isPropertyDeclaration(container) && ts.hasStaticModifier(container) && + container.initializer && ts.textRangeContainsPositionInclusive(container.initializer, thisExpression.pos) && ts.length(container.parent.decorators)) { + error(thisExpression, ts.Diagnostics.Cannot_use_this_in_a_static_property_initializer_of_a_decorated_class); + } + } function checkThisExpression(node) { + var isNodeInTypeQuery = isInTypeQuery(node); // Stop at the first arrow function so that we can // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 167 /* Constructor */) { + if (container.kind === 169 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 210 /* ArrowFunction */) { + if (container.kind === 212 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } + checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 257 /* ModuleDeclaration */: + case 259 /* 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 256 /* EnumDeclaration */: + case 258 /* 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 167 /* Constructor */: + case 169 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields)) { - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); - // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks - } - break; - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } // When targeting es6, mark that we'll need to capture `this` in its lexically bound scope. - if (capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { + if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { captureLexicalThis(node, container); } var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); @@ -67436,7 +68665,7 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - var type = ts.hasSyntacticModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + var type = ts.isStatic(container) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; return getFlowTypeOfReference(node, type); } if (ts.isSourceFile(container)) { @@ -67464,12 +68693,12 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return ts.hasSyntacticModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return ts.isStatic(container) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 209 /* FunctionExpression */ && + if (container.kind === 211 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -67479,16 +68708,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 166 /* MethodDeclaration */ && - container.parent.kind === 201 /* ObjectLiteralExpression */ && + else if (container.kind === 167 /* MethodDeclaration */ && + container.parent.kind === 203 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 209 /* FunctionExpression */ && - container.parent.kind === 289 /* PropertyAssignment */ && - container.parent.parent.kind === 201 /* ObjectLiteralExpression */ && + else if (container.kind === 211 /* FunctionExpression */ && + container.parent.kind === 291 /* PropertyAssignment */ && + container.parent.parent.kind === 203 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -67496,7 +68725,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 209 /* FunctionExpression */ && + else if (container.kind === 211 /* FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && @@ -67521,7 +68750,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 309 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 312 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -67535,16 +68764,16 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 161 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 162 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 204 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 206 /* CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 210 /* ArrowFunction */) { + while (container && container.kind === 212 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -67557,14 +68786,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 159 /* ComputedPropertyName */; }); - if (current && current.kind === 159 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 160 /* ComputedPropertyName */; }); + if (current && current.kind === 160 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 201 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 203 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -67572,11 +68801,23 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 167 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 169 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } - if (ts.hasSyntacticModifier(container, 32 /* Static */) || isCallExpression) { + if (ts.isStatic(container) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; + if (!isCallExpression && + languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && + (ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) { + // for `super.x` or `super[x]` in a static initializer, mark all enclosing + // block scope containers so that we can report potential collisions with + // `Reflect`. + ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) { + if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) { + getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */; + } + }); + } } else { nodeCheckFlag = 256 /* SuperInstance */; @@ -67641,7 +68882,7 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 166 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 167 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -67655,7 +68896,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 201 /* ObjectLiteralExpression */) { + if (container.parent.kind === 203 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -67676,7 +68917,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 167 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 169 /* 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 errorType; @@ -67691,7 +68932,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 === 167 /* Constructor */; + return container.kind === 169 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -67699,21 +68940,23 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 201 /* ObjectLiteralExpression */) { - if (ts.hasSyntacticModifier(container, 32 /* Static */)) { - return container.kind === 166 /* MethodDeclaration */ || - container.kind === 165 /* MethodSignature */ || - container.kind === 168 /* GetAccessor */ || - container.kind === 169 /* SetAccessor */; + if (ts.isClassLike(container.parent) || container.parent.kind === 203 /* ObjectLiteralExpression */) { + if (ts.isStatic(container)) { + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 170 /* GetAccessor */ || + container.kind === 171 /* SetAccessor */ || + container.kind === 165 /* PropertyDeclaration */ || + container.kind === 168 /* ClassStaticBlockDeclaration */; } else { - return container.kind === 166 /* MethodDeclaration */ || - container.kind === 165 /* MethodSignature */ || - container.kind === 168 /* GetAccessor */ || - container.kind === 169 /* SetAccessor */ || - container.kind === 164 /* PropertyDeclaration */ || - container.kind === 163 /* PropertySignature */ || - container.kind === 167 /* Constructor */; + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 170 /* GetAccessor */ || + container.kind === 171 /* SetAccessor */ || + container.kind === 165 /* PropertyDeclaration */ || + container.kind === 164 /* PropertySignature */ || + container.kind === 169 /* Constructor */; } } } @@ -67721,10 +68964,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 166 /* MethodDeclaration */ || - func.kind === 168 /* GetAccessor */ || - func.kind === 169 /* SetAccessor */) && func.parent.kind === 201 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 209 /* FunctionExpression */ && func.parent.kind === 289 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 167 /* MethodDeclaration */ || + func.kind === 170 /* GetAccessor */ || + func.kind === 171 /* SetAccessor */) && func.parent.kind === 203 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 211 /* FunctionExpression */ && func.parent.kind === 291 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -67736,7 +68979,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 210 /* ArrowFunction */) { + if (func.kind === 212 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -67763,7 +69006,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 289 /* PropertyAssignment */) { + if (literal.parent.kind !== 291 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -67777,7 +69020,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 217 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent.kind === 219 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -67830,12 +69073,12 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 161 /* Parameter */: + case 162 /* Parameter */: return getContextuallyTypedParameterType(declaration); - case 199 /* BindingElement */: + case 201 /* BindingElement */: return getContextualTypeForBindingElement(declaration); - case 164 /* PropertyDeclaration */: - if (ts.hasSyntacticModifier(declaration, 32 /* Static */)) { + case 165 /* PropertyDeclaration */: + if (ts.isStatic(declaration)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } // By default, do nothing and return undefined - only the above cases have context implied by a parent @@ -67845,10 +69088,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 199 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); + parent.kind !== 201 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 198 /* ArrayBindingPattern */) { + if (parent.name.kind === 200 /* ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -67982,10 +69225,13 @@ var ts; if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } - return getTypeAtPosition(signature, argIndex); + var restIndex = signature.parameters.length - 1; + return signatureHasRestParameter(signature) && argIndex >= restIndex ? + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 206 /* TaggedTemplateExpression */) { + if (template.parent.kind === 208 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -67994,10 +69240,10 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 62 /* EqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: @@ -68016,6 +69262,27 @@ var ts; return undefined; } } + /** + * Try to find a resolved symbol for an expression without also resolving its type, as + * getSymbolAtLocation would (as that could be reentrant into contextual typing) + */ + function getSymbolForExpression(e) { + if (e.symbol) { + return e.symbol; + } + if (ts.isIdentifier(e)) { + return getResolvedSymbol(e); + } + if (ts.isPropertyAccessExpression(e)) { + var lhsType = getTypeOfExpression(e.expression); + return ts.isPrivateIdentifier(e.name) ? tryGetPrivateIdentifierPropertyOfType(lhsType, e.name) : getPropertyOfType(lhsType, e.name.escapedText); + } + return undefined; + function tryGetPrivateIdentifierPropertyOfType(type, id) { + var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(id.escapedText, id); + return lexicallyScopedSymbol && getPrivateIdentifierPropertyOfType(type, lexicallyScopedSymbol); + } + } // In an assignment expression, the right operand is contextually typed by the type of the left operand. // Don't do this for assignment declarations unless there is a type tag on the assignment, to avoid circularity from checking the right operand. function getContextualTypeForAssignmentDeclaration(binaryExpression) { @@ -68023,8 +69290,19 @@ var ts; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { case 0 /* None */: - return getTypeOfExpression(binaryExpression.left); case 4 /* ThisProperty */: + var lhsSymbol = getSymbolForExpression(binaryExpression.left); + var decl = lhsSymbol && lhsSymbol.valueDeclaration; + // Unannotated, uninitialized property declarations have a type implied by their usage in the constructor. + // We avoid calling back into `getTypeOfExpression` and reentering contextual typing to avoid a bogus circularity error in that case. + if (decl && (ts.isPropertyDeclaration(decl) || ts.isPropertySignature(decl))) { + var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); + return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || + (decl.initializer && getTypeOfExpression(binaryExpression.left)); + } + if (kind === 0 /* None */) { + return getTypeOfExpression(binaryExpression.left); + } return getContextualTypeForThisPropertyAssignment(binaryExpression); case 5 /* Property */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { @@ -68036,12 +69314,12 @@ var ts; return getTypeOfExpression(binaryExpression.left); } else { - var decl = binaryExpression.left.symbol.valueDeclaration; - if (!decl) { + var decl_1 = binaryExpression.left.symbol.valueDeclaration; + if (!decl_1) { return undefined; } var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); - var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); + var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl_1); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); } @@ -68059,7 +69337,7 @@ var ts; return undefined; } } - return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left); + return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left); } case 1 /* ExportsProperty */: case 6 /* Prototype */: @@ -68115,10 +69393,11 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { + var _a; if (isGenericMappedType(t)) { var constraint = getConstraintTypeFromMappedType(t); var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint; - var propertyNameType = getLiteralType(ts.unescapeLeadingUnderscores(name)); + var propertyNameType = getStringLiteralType(ts.unescapeLeadingUnderscores(name)); if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) { return substituteIndexedMappedType(t, propertyNameType); } @@ -68134,15 +69413,11 @@ var ts; return restType; } } - return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1 /* Number */) || - getIndexTypeOfContextualType(t, 0 /* String */); + return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type; } return undefined; }, /*noReductions*/ true); } - function getIndexTypeOfContextualType(type, kind) { - return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }, /*noReductions*/ true); - } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one // exists. Otherwise, it is the type of the string index signature in T, if one exists. @@ -68166,14 +69441,13 @@ var ts; // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. - var symbolName_3 = getSymbolOfNode(element).escapedName; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); - if (propertyType) { - return propertyType; - } + return getTypeOfPropertyOfContextualType(type, getSymbolOfNode(element).escapedName); + } + if (element.name) { + var nameType_1 = getLiteralTypeFromPropertyName(element.name); + // We avoid calling getApplicableIndexInfo here because it performs potentially expensive intersection reduction. + return mapType(type, function (t) { var _a; return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType_1)) === null || _a === void 0 ? void 0 : _a.type; }, /*noReductions*/ true); } - return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1 /* Number */) || - getIndexTypeOfContextualType(type, 0 /* String */); } return undefined; } @@ -68203,7 +69477,7 @@ var ts; var childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName); return childFieldType && (realChildren.length === 1 ? childFieldType : mapType(childFieldType, function (t) { if (isArrayLikeType(t)) { - return getIndexedAccessType(t, getLiteralType(childIndex)); + return getIndexedAccessType(t, getNumberLiteralType(childIndex)); } else { return t; @@ -68242,25 +69516,25 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 78 /* Identifier */: - case 150 /* UndefinedKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 79 /* Identifier */: + case 151 /* UndefinedKeyword */: return true; - case 202 /* PropertyAccessExpression */: - case 208 /* ParenthesizedExpression */: + case 204 /* PropertyAccessExpression */: + case 210 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 284 /* JsxExpression */: + case 286 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 289 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 291 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 281 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 283 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -68340,60 +69614,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 250 /* VariableDeclaration */: - case 161 /* Parameter */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 199 /* BindingElement */: + case 252 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 201 /* BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 210 /* ArrowFunction */: - case 243 /* ReturnStatement */: + case 212 /* ArrowFunction */: + case 245 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 220 /* YieldExpression */: + case 222 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 214 /* AwaitExpression */: + case 216 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 204 /* CallExpression */: - if (parent.expression.kind === 99 /* ImportKeyword */) { + case 206 /* CallExpression */: + if (parent.expression.kind === 100 /* ImportKeyword */) { return stringType; } /* falls through */ - case 205 /* NewExpression */: + case 207 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 207 /* TypeAssertionExpression */: - case 225 /* AsExpression */: + case 209 /* TypeAssertionExpression */: + case 227 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 289 /* PropertyAssignment */: - case 290 /* ShorthandPropertyAssignment */: + case 291 /* PropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 291 /* SpreadAssignment */: + case 293 /* SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 200 /* ArrayLiteralExpression */: { + case 202 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 229 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 219 /* TemplateExpression */); + case 231 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 221 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 208 /* ParenthesizedExpression */: { + case 210 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 226 /* NonNullExpression */: + case 228 /* NonNullExpression */: return getContextualType(parent, contextFlags); - case 284 /* JsxExpression */: + case 286 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 281 /* JsxAttribute */: - case 283 /* JsxSpreadAttribute */: + case 283 /* JsxAttribute */: + case 285 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 276 /* JsxOpeningElement */: - case 275 /* JsxSelfClosingElement */: + case 278 /* JsxOpeningElement */: + case 277 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -68633,7 +69907,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 209 /* FunctionExpression */ || node.kind === 210 /* ArrowFunction */; + return node.kind === 211 /* FunctionExpression */ || node.kind === 212 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -68647,7 +69921,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 !== 166 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -68661,8 +69935,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { - var current = types_20[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var current = types_19[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -68695,8 +69969,8 @@ var ts; return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 199 /* BindingElement */ && !!node.initializer) || - (node.kind === 217 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); + return (node.kind === 201 /* BindingElement */ && !!node.initializer) || + (node.kind === 219 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -68706,9 +69980,10 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); var inDestructuringPattern = ts.isAssignmentTarget(node); var inConstContext = isConstContext(node); + var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 221 /* SpreadElement */) { + if (e.kind === 223 /* SpreadElement */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); } @@ -68730,7 +70005,7 @@ var ts; // get the contextual element type from it. So we do something similar to // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. - var restElementType = getIndexTypeOfType(spreadType, 1 /* Number */) || + var restElementType = getIndexTypeOfType(spreadType, numberType) || getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || unknownType; elementTypes.push(restElementType); @@ -68741,11 +70016,16 @@ var ts; elementFlags.push(4 /* Rest */); } } + else if (exactOptionalPropertyTypes && e.kind === 225 /* OmittedExpression */) { + hasOmittedExpression = true; + elementTypes.push(missingType); + elementFlags.push(2 /* Optional */); + } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); - elementTypes.push(type); - elementFlags.push(1 /* Required */); + elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); + elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); } } if (inDestructuringPattern) { @@ -68771,9 +70051,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return isNumericComputedName(name); - case 78 /* Identifier */: + case 79 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -68787,9 +70067,6 @@ var ts; // but this behavior is consistent with checkIndexedAccess return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); } - function isInfinityOrNaNString(name) { - return name === "Infinity" || name === "-Infinity" || name === "NaN"; - } function isNumericLiteralName(name) { // The intent of numeric names is that // - they are names with text in a numeric form, and that @@ -68847,15 +70124,24 @@ var ts; var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; return isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name)); } - function getObjectLiteralIndexInfo(node, offset, properties, kind) { + function isSymbolWithSymbolName(symbol) { + var _a; + var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; + return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) && + isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */)); + } + function getObjectLiteralIndexInfo(node, offset, properties, keyType) { var propTypes = []; for (var i = offset; i < properties.length; i++) { - if (kind === 0 /* String */ || isSymbolWithNumericName(properties[i])) { + var prop = properties[i]; + if (keyType === stringType && !isSymbolWithSymbolName(prop) || + keyType === numberType && isSymbolWithNumericName(prop) || + keyType === esSymbolType && isSymbolWithSymbolName(prop)) { propTypes.push(getTypeOfSymbol(properties[i])); } } var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType; - return createIndexInfo(unionType, isConstContext(node)); + return createIndexInfo(keyType, unionType, isConstContext(node)); } function getImmediateAliasedSymbol(symbol) { ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); @@ -68878,7 +70164,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 197 /* ObjectBindingPattern */ || contextualType.pattern.kind === 201 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 199 /* ObjectBindingPattern */ || contextualType.pattern.kind === 203 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -68888,6 +70174,7 @@ var ts; var patternWithComputedProperties = false; var hasComputedStringProperty = false; var hasComputedNumberProperty = false; + var hasComputedSymbolProperty = false; // Spreads may cause an early bail; ensure computed names are always checked (this is cached) // As otherwise they may not be checked until exports for the type at this position are retrieved, // which may never occur. @@ -68901,16 +70188,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 159 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 160 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 289 /* PropertyAssignment */ || - memberDecl.kind === 290 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 291 /* PropertyAssignment */ || + memberDecl.kind === 292 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 289 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 291 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 290 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 292 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -68933,8 +70220,8 @@ var ts; 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 === 289 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 290 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 291 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 292 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -68946,7 +70233,7 @@ var ts; if (impliedProp) { prop.flags |= impliedProp.flags & 16777216 /* Optional */; } - else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0 /* String */)) { + else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); } } @@ -68960,7 +70247,7 @@ var ts; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); } - else if (memberDecl.kind === 291 /* SpreadAssignment */) { + else if (memberDecl.kind === 293 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -68970,17 +70257,19 @@ var ts; propertiesTable = ts.createSymbolTable(); hasComputedStringProperty = false; hasComputedNumberProperty = false; + hasComputedSymbolProperty = false; } var type = getReducedType(checkExpression(memberDecl.expression)); if (isValidSpreadType(type)) { + var mergedType = tryMergeUnionOfObjectTypeAndEmptyObject(type, inConstContext); if (allPropertiesTable) { - checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + checkSpreadPropOverrides(mergedType, allPropertiesTable, memberDecl); } offset = propertiesArray.length; if (spread === errorType) { continue; } - spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); + spread = getSpreadType(spread, mergedType, node.symbol, objectFlags, inConstContext); } else { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); @@ -68994,7 +70283,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 === 168 /* GetAccessor */ || memberDecl.kind === 169 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 170 /* GetAccessor */ || memberDecl.kind === 171 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -69002,6 +70291,9 @@ var ts; if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; } + else if (isTypeAssignableTo(computedNameType, esSymbolType)) { + hasComputedSymbolProperty = true; + } else { hasComputedStringProperty = true; } @@ -69019,7 +70311,7 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 291 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 293 /* SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { @@ -69047,9 +70339,14 @@ var ts; } return createObjectLiteralType(); function createObjectLiteralType() { - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0 /* String */) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1 /* Number */) : undefined; - var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); + var indexInfos = []; + if (hasComputedStringProperty) + indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, stringType)); + if (hasComputedNumberProperty) + indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, numberType)); + if (hasComputedSymbolProperty) + indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType)); + var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos); result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { result.objectFlags |= 8192 /* JSLiteral */; @@ -69111,14 +70408,14 @@ var ts; checkJsxChildren(node); return getJsxElementTypeAt(node) || anyType; } - function isUnhyphenatedJsxName(name) { - return !ts.stringContains(name, "-"); + function isHyphenatedJsxName(name) { + return ts.stringContains(name, "-"); } /** * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 78 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -69165,7 +70462,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 283 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 285 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -69191,7 +70488,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 274 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 276 /* JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -69215,7 +70512,7 @@ var ts; childrenPropSymbol.valueDeclaration.symbol = childrenPropSymbol; var childPropMap = ts.createSymbolTable(); childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol); - spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), attributes.symbol, objectFlags, /*readonly*/ false); + spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, ts.emptyArray), attributes.symbol, objectFlags, /*readonly*/ false); } } if (hasSpreadAnyType) { @@ -69232,7 +70529,7 @@ var ts; */ function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; - var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return result; } @@ -69248,7 +70545,7 @@ var ts; childrenTypes.push(stringType); } } - else if (child.kind === 284 /* JsxExpression */ && !child.expression) { + else if (child.kind === 286 /* JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -69260,11 +70557,12 @@ var ts; function checkSpreadPropOverrides(type, props, spread) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var right = _a[_i]; - var left = props.get(right.escapedName); - var rightType = getTypeOfSymbol(right); - if (left && !maybeTypeOfKind(rightType, 98304 /* Nullable */) && !(maybeTypeOfKind(rightType, 3 /* AnyOrUnknown */) && right.flags & 16777216 /* Optional */)) { - var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); - ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(spread, ts.Diagnostics.This_spread_always_overwrites_this_property)); + if (!(right.flags & 16777216 /* Optional */)) { + var left = props.get(right.escapedName); + if (left) { + var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(spread, ts.Diagnostics.This_spread_always_overwrites_this_property)); + } } } } @@ -69302,7 +70600,7 @@ var ts; return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { links.jsxFlags |= 2 /* IntrinsicIndexedElement */; return links.resolvedSymbol = intrinsicElementsType.symbol; @@ -69461,7 +70759,7 @@ var ts; if (intrinsicProp) { return getTypeOfSymbol(intrinsicProp); } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { return indexSignatureType; } @@ -69513,7 +70811,7 @@ var ts; } else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = - getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), 0 /* String */) || errorType; + getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType; } else { return links.resolvedJsxElementAttributesType = errorType; @@ -69603,11 +70901,13 @@ var ts; */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { if (targetType.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(targetType); - if (resolved.stringIndexInfo || - resolved.numberIndexInfo && isNumericLiteralName(name) || - getPropertyOfObjectType(targetType, name) || - isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) { + // For backwards compatibility a symbol-named property is satisfied by a string index signature. This + // is incorrect and inconsistent with element access expressions, where it is an error, so eventually + // we should remove this exception. + if (getPropertyOfObjectType(targetType, name) || + getApplicableIndexInfoForName(targetType, name) || + isLateBoundName(name) && getIndexInfoOfType(targetType, stringType) || + isComparingJsxAttributes && isHyphenatedJsxName(name)) { // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. return true; } @@ -69669,9 +70969,9 @@ var ts; function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } var flags = ts.getDeclarationModifierFlagsFromSymbol(prop, writing); - var errorNode = node.kind === 158 /* QualifiedName */ ? node.right : - node.kind === 196 /* ImportType */ ? node : - node.kind === 199 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + var errorNode = node.kind === 159 /* QualifiedName */ ? node.right : + node.kind === 198 /* ImportType */ ? node : + node.kind === 201 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; if (isSuper) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -69828,10 +71128,11 @@ var ts; return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name, checkMode), node, nonOptionalType !== leftType); } function checkQualifiedName(node, checkMode) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right, checkMode); + var leftType = ts.isPartOfTypeQuery(node) && ts.isThisIdentifier(node.left) ? checkNonNullType(checkThisExpression(node.left), node.left) : checkNonNullExpression(node.left); + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 208 /* ParenthesizedExpression */) { + while (node.parent.kind === 210 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -69966,9 +71267,11 @@ var ts; } var propType; if (!prop) { - var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ? getIndexInfoOfType(apparentType, 0 /* String */) : undefined; + var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ? + getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined; if (!(indexInfo && indexInfo.type)) { - if (isJSLiteralType(leftType)) { + var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true); + if (!isUncheckedJS && isJSLiteralType(leftType)) { return anyType; } if (leftType.symbol === globalThisSymbol) { @@ -69981,7 +71284,7 @@ var ts; return anyType; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType); + reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS); } return errorType; } @@ -70001,7 +71304,7 @@ var ts; markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; var writing = ts.isWriteAccess(node); - checkPropertyAccessibility(node, left.kind === 105 /* SuperKeyword */, writing, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; @@ -70010,16 +71313,37 @@ var ts; } return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode); } + /** + * Determines whether a did-you-mean error should be a suggestion in an unchecked JS file. + * Only applies to unchecked JS files without checkJS, // @ts-check or // @ts-nocheck + * It does not suggest when the suggestion: + * - Is from a global file that is different from the reference file, or + * - (optionally) Is a class, or is a this.x property access expression + */ + function isUncheckedJSSuggestion(node, suggestion, excludeClasses) { + var file = ts.getSourceFileOfNode(node); + if (file) { + if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) { + var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode); + return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) + && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */) + && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */); + } + } + return false; + } function getFlowTypeOfAccessExpression(node, prop, propType, errorNode, checkMode) { // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (assignmentKind === 1 /* Definite */ || - prop && - !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) - && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) - && !isDuplicatedCommonJSExport(prop.declarations)) { + if (assignmentKind === 1 /* Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + } + if (prop && + !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) + && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } if (propType === autoType) { @@ -70031,12 +71355,14 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 107 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; - if (declaration && isInstancePropertyWithoutInitializer(declaration)) { - var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 167 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { - assumeUninitialized = true; + if (declaration && isPropertyWithoutInitializer(declaration)) { + if (!ts.isStatic(declaration)) { + var flowContainer = getControlFlowContainer(node); + if (flowContainer.kind === 169 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { + assumeUninitialized = true; + } } } } @@ -70061,15 +71387,15 @@ var ts; } var diagnosticMessage; var declarationName = ts.idText(right); - if (isInPropertyInitializer(node) + if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 253 /* ClassDeclaration */ && - node.parent.kind !== 174 /* TypeReference */ && + else if (valueDeclaration.kind === 255 /* ClassDeclaration */ && + node.parent.kind !== 176 /* TypeReference */ && !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -70078,26 +71404,29 @@ var ts; ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here, declarationName)); } } - function isInPropertyInitializer(node) { + function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return true; - case 289 /* PropertyAssignment */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 291 /* SpreadAssignment */: - case 159 /* ComputedPropertyName */: - case 229 /* TemplateSpan */: - case 284 /* JsxExpression */: - case 281 /* JsxAttribute */: - case 282 /* JsxAttributes */: - case 283 /* JsxSpreadAttribute */: - case 276 /* JsxOpeningElement */: - case 224 /* ExpressionWithTypeArguments */: - case 287 /* HeritageClause */: + case 291 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 293 /* SpreadAssignment */: + case 160 /* ComputedPropertyName */: + case 231 /* TemplateSpan */: + case 286 /* JsxExpression */: + case 283 /* JsxAttribute */: + case 284 /* JsxAttributes */: + case 285 /* JsxSpreadAttribute */: + case 278 /* JsxOpeningElement */: + case 226 /* ExpressionWithTypeArguments */: + case 289 /* HeritageClause */: return false; + case 212 /* ArrowFunction */: + case 236 /* ExpressionStatement */: + return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; } @@ -70130,13 +71459,13 @@ var ts; } return getIntersectionType(x); } - function reportNonexistentProperty(propNode, containingType) { + function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { var errorInfo; var relatedInfo; if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -70164,7 +71493,8 @@ var ts; var suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType); if (suggestion !== undefined) { var suggestedName = ts.symbolName(suggestion); - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, missingProperty, container, suggestedName); + var message = isUncheckedJS ? ts.Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2 : ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2; + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, missingProperty, container, suggestedName); relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName); } else { @@ -70180,7 +71510,7 @@ var ts; if (relatedInfo) { ts.addRelatedInfo(resultDiagnostic, relatedInfo); } - diagnostics.add(resultDiagnostic); + addErrorOrSuggestion(!isUncheckedJS, resultDiagnostic); } function containerSeemsToBeEmptyDomElement(containingType) { return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) && @@ -70189,7 +71519,7 @@ var ts; } function typeHasStaticProperty(propName, containingType) { var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName); - return prop !== undefined && !!prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); + return prop !== undefined && !!prop.valueDeclaration && ts.isStatic(prop.valueDeclaration); } function getSuggestedLibForNonExistentName(name) { var missingName = diagnosticName(name); @@ -70219,6 +71549,9 @@ var ts; } } } + function getSuggestedSymbolForNonexistentClassMember(name, baseType) { + return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */); + } function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); if (typeof name !== "string") { @@ -70346,21 +71679,21 @@ var ts; (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; } function isSelfTypeAccess(name, parent) { - return name.kind === 107 /* ThisKeyword */ + return name.kind === 108 /* ThisKeyword */ || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 202 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 105 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 158 /* QualifiedName */: + case 204 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 159 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 196 /* ImportType */: + case 198 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 202 /* PropertyAccessExpression */ && node.expression.kind === 105 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 204 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -70383,13 +71716,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 251 /* VariableDeclarationList */) { + if (initializer.kind === 253 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 78 /* Identifier */) { + else if (initializer.kind === 79 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -70398,7 +71731,7 @@ var ts; * Return true if the given type is considered to have numeric property names. */ function hasNumericPropertyNames(type) { - return getIndexTypeOfType(type, 1 /* Number */) && !getIndexTypeOfType(type, 0 /* String */); + return getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, numberType); } /** * Return true if given node is an expression consisting of an identifier (possibly parenthesized) @@ -70406,13 +71739,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 78 /* Identifier */) { + if (e.kind === 79 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 239 /* ForInStatement */ && + if (node.kind === 241 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -70447,9 +71780,9 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : - 0 /* None */; - var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; + 4 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : + 32 /* ExpressionPosition */; + var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } function callLikeExpressionMayHaveTypeArguments(node) { @@ -70461,13 +71794,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 206 /* TaggedTemplateExpression */) { + if (node.kind === 208 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 162 /* Decorator */) { + else if (node.kind !== 163 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -70531,7 +71864,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 221 /* SpreadElement */ || arg.kind === 228 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 223 /* SpreadElement */ || arg.kind === 230 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -70548,9 +71881,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 206 /* TaggedTemplateExpression */) { + if (node.kind === 208 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 219 /* TemplateExpression */) { + if (node.template.kind === 221 /* 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 lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -70565,7 +71898,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 162 /* Decorator */) { + else if (node.kind === 163 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -70579,7 +71912,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 205 /* NewExpression */); + ts.Debug.assert(node.kind === 207 /* NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -70628,7 +71961,7 @@ var ts; function getSingleSignature(type, kind, allowMembers) { if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - if (allowMembers || resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) { if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { return resolved.callSignatures[0]; } @@ -70682,7 +72015,7 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 162 /* Decorator */) { + if (node.kind !== 163 /* Decorator */) { var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -70730,7 +72063,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 223 /* OmittedExpression */) { + if (arg.kind !== 225 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -70754,7 +72087,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 228 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 230 /* SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -70764,24 +72097,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 228 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 230 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); flags.push(8 /* Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 221 /* SpreadElement */ ? arg.expression : arg)); + types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 223 /* SpreadElement */ ? arg.expression : arg)); flags.push(4 /* Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getLiteralType(i - index)); + var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); flags.push(1 /* Required */); } - if (arg.kind === 228 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 230 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -70925,7 +72258,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 205 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 207 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -70943,7 +72276,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 223 /* OmittedExpression */) { + if (arg.kind !== 225 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -70988,8 +72321,10 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 204 /* CallExpression */) { - var callee = ts.skipOuterExpressions(node.expression); + var expression = node.kind === 206 /* CallExpression */ ? node.expression : + node.kind === 208 /* TaggedTemplateExpression */ ? node.tag : undefined; + if (expression) { + var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { return callee.expression; } @@ -71005,17 +72340,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 206 /* TaggedTemplateExpression */) { + if (node.kind === 208 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 219 /* TemplateExpression */) { + if (template.kind === 221 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 162 /* Decorator */) { + if (node.kind === 163 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -71026,10 +72361,10 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_21 = function (i) { + var _loop_23 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 221 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 223 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; @@ -71043,7 +72378,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_21(i); + _loop_23(i); } return effectiveArgs_1; } @@ -71056,30 +72391,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 161 /* Parameter */: + case 162 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 167 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 169 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 164 /* PropertyDeclaration */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* 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. - var hasPropDesc = parent.kind !== 164 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 165 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -71093,17 +72428,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: return 1; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return 2; - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 161 /* Parameter */: + case 162 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -71239,15 +72574,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 206 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 162 /* Decorator */; + var isTaggedTemplate = node.kind === 208 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 163 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray && produceDiagnostics; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 105 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -71302,7 +72637,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 204 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 206 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -71356,7 +72691,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_22 = function (c) { + var _loop_24 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -71374,14 +72709,14 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_22(c); + _loop_24(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); // The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic - var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; })); + var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; }), true); var diag = void 0; if (ts.every(diags_3, function (d) { return d.start === diags_3[0].start && d.length === diags_3[0].length && d.file === diags_3[0].file; })) { var _b = diags_3[0], file = _b.file, start = _b.start, length_7 = _b.length; @@ -71532,7 +72867,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_23 = function (i) { + var _loop_25 = function (i) { var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : i < s.parameters.length ? s.parameters[i] : undefined; }); @@ -71540,7 +72875,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_23(i); + _loop_25(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0 /* None */; @@ -71621,7 +72956,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -71847,7 +73182,7 @@ var ts; var declaration = signature.declaration; var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 167 /* Constructor */) { + if (!modifiers || declaration.kind !== 169 /* Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -71879,8 +73214,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { - var constituent = types_21[_i]; + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var constituent = types_20[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -71991,16 +73326,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 161 /* Parameter */: + case 162 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -72046,7 +73381,7 @@ var ts; // file would probably be preferable. var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -72095,16 +73430,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 204 /* CallExpression */: + case 206 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 205 /* NewExpression */: + case 207 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 162 /* Decorator */: + case 163 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 276 /* JsxOpeningElement */: - case 275 /* JsxSelfClosingElement */: + case 278 /* JsxOpeningElement */: + case 277 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -72204,7 +73539,7 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 62 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } @@ -72213,7 +73548,7 @@ var ts; name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -72236,10 +73571,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 202 /* PropertyAccessExpression */) { + while (parent && parent.kind === 204 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -72260,15 +73595,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return voidType; } - if (node.kind === 205 /* NewExpression */) { + if (node.kind === 207 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 167 /* Constructor */ && - declaration.kind !== 171 /* ConstructSignature */ && - declaration.kind !== 176 /* ConstructorType */ && + declaration.kind !== 169 /* Constructor */ && + declaration.kind !== 173 /* ConstructSignature */ && + declaration.kind !== 178 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -72288,7 +73623,7 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 204 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 234 /* ExpressionStatement */ && + if (node.kind === 206 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 236 /* ExpressionStatement */ && returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); @@ -72301,7 +73636,7 @@ var ts; if (ts.isInJSFile(node)) { var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { - var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); jsAssignmentType.objectFlags |= 8192 /* JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } @@ -72318,20 +73653,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 204 /* CallExpression */: - case 162 /* Decorator */: - case 205 /* NewExpression */: + case 206 /* CallExpression */: + case 163 /* Decorator */: + case 207 /* NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 276 /* JsxOpeningElement */: - case 275 /* JsxSelfClosingElement */: + case 278 /* JsxOpeningElement */: + case 277 /* JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: return node.argumentExpression; - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: return node.name; - case 174 /* TypeReference */: + case 176 /* TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -72392,11 +73727,11 @@ var ts; var memberTable = ts.createSymbolTable(); var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); newSymbol.parent = originalSymbol; - newSymbol.nameType = getLiteralType("default"); + newSymbol.nameType = getStringLiteralType("default"); newSymbol.target = resolveSymbol(symbol); memberTable.set("default" /* Default */, newSymbol); var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); - var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; } @@ -72424,9 +73759,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 252 /* FunctionDeclaration */ + ? 254 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 250 /* VariableDeclaration */ + ? 252 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -72454,21 +73789,21 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 200 /* ArrayLiteralExpression */: - case 201 /* ObjectLiteralExpression */: - case 219 /* TemplateExpression */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 202 /* ArrayLiteralExpression */: + case 203 /* ObjectLiteralExpression */: + case 221 /* TemplateExpression */: return true; - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -72510,21 +73845,32 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 102 /* NewKeyword */) { + if (node.keywordToken === 103 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 99 /* ImportKeyword */) { + if (node.keywordToken === 100 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); } + function checkMetaPropertyKeyword(node) { + switch (node.keywordToken) { + case 100 /* ImportKeyword */: + return getGlobalImportMetaExpressionType(); + case 103 /* NewKeyword */: + var type = checkNewTargetMetaProperty(node); + return type === errorType ? errorType : createNewTargetExpressionType(type); + default: + ts.Debug.assertNever(node.keywordToken); + } + } function checkNewTargetMetaProperty(node) { var container = ts.getNewTargetContainer(node); if (!container) { error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 167 /* Constructor */) { + else if (container.kind === 169 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -72539,7 +73885,6 @@ var ts; } var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); - ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { @@ -72570,8 +73915,37 @@ var ts; } return restParameter.escapedName; } + function getParameterIdentifierNameAtPosition(signature, pos) { + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); + if (pos < paramCount) { + var param = signature.parameters[pos]; + return isParameterDeclarationWithIdentifierName(param) ? [param.escapedName, false] : undefined; + } + var restParameter = signature.parameters[paramCount] || unknownSymbol; + if (!isParameterDeclarationWithIdentifierName(restParameter)) { + return undefined; + } + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var associatedNames = restType.target.labeledElementDeclarations; + var index = pos - paramCount; + var associatedName = associatedNames === null || associatedNames === void 0 ? void 0 : associatedNames[index]; + var isRestTupleElement = !!(associatedName === null || associatedName === void 0 ? void 0 : associatedName.dotDotDotToken); + return associatedName ? [ + getTupleElementLabel(associatedName), + isRestTupleElement + ] : undefined; + } + if (pos === paramCount) { + return [restParameter.escapedName, true]; + } + return undefined; + } + function isParameterDeclarationWithIdentifierName(symbol) { + return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); + } function isValidDeclarationForTupleLabel(d) { - return d.kind === 193 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 195 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -72603,7 +73977,7 @@ var ts; var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; if (!isTupleType(restType) || restType.target.hasRestElement || index < restType.target.fixedLength) { - return getIndexedAccessType(restType, getLiteralType(index)); + return getIndexedAccessType(restType, getNumberLiteralType(index)); } } return undefined; @@ -72784,7 +74158,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); - if (declaration.name.kind !== 78 /* Identifier */) { + if (declaration.name.kind !== 79 /* Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); @@ -72799,7 +74173,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 78 /* Identifier */) { + if (element.name.kind === 79 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -72843,6 +74217,16 @@ var ts; } return promiseType; } + function createNewTargetExpressionType(targetType) { + // Create a synthetic type `NewTargetExpression { target: TargetType; }` + var symbol = createSymbol(0 /* None */, "NewTargetExpression"); + var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */); + targetPropertySymbol.parent = symbol; + targetPropertySymbol.type = targetType; + var members = ts.createSymbolTable([targetPropertySymbol]); + symbol.members = members; + return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); + } function getReturnTypeFromBody(func, checkMode) { if (!func.body) { return errorType; @@ -72854,7 +74238,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 231 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 233 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -73039,7 +74423,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 212 /* TypeOfExpression */) { + if (node.expression.kind === 214 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. @@ -73102,11 +74486,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: return true; - case 166 /* MethodDeclaration */: - return func.parent.kind === 201 /* ObjectLiteralExpression */; + case 167 /* MethodDeclaration */: + return func.parent.kind === 203 /* ObjectLiteralExpression */; default: return false; } @@ -73132,7 +74516,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 165 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 231 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 166 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 233 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; @@ -73165,12 +74549,15 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 166 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); + if (ts.isFunctionExpression(node)) { + checkCollisionsForDeclarationName(node, node.name); + } // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage - if (!ts.getEffectiveReturnTypeNode(node) && !hasContextSensitiveParameters(node)) { + if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type var contextualSignature = getContextualSignature(node); if (contextualSignature && couldContainTypeVariables(getReturnTypeOfSignature(contextualSignature))) { @@ -73180,7 +74567,7 @@ var ts; } var returnType = getReturnTypeFromBody(node, checkMode); var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); + var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray); returnOnlyType.objectFlags |= 524288 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; } @@ -73189,7 +74576,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 209 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 211 /* FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -73235,7 +74622,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 166 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -73248,7 +74635,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 231 /* Block */) { + if (node.body.kind === 233 /* Block */) { checkSourceElement(node.body); } else { @@ -73335,10 +74722,10 @@ var ts; // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 107 /* ThisKeyword */) { + expr.expression.kind === 108 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 167 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 169 /* Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -73359,11 +74746,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; if (symbol_2.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 264 /* NamespaceImport */; + return !!declaration && declaration.kind === 266 /* NamespaceImport */; } } } @@ -73372,7 +74759,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 78 /* Identifier */ && !ts.isAccessExpression(node)) { + if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } @@ -73398,13 +74785,15 @@ var ts; if (isReadonlySymbol(symbol)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); } - checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol)); + checkDeleteExpressionMustBeOptional(expr, symbol); } return booleanType; } - function checkDeleteExpressionMustBeOptional(expr, type) { - var AnyOrUnknownOrNeverFlags = 3 /* AnyOrUnknown */ | 131072 /* Never */; - if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & 32768 /* Undefined */)) { + function checkDeleteExpressionMustBeOptional(expr, symbol) { + var type = getTypeOfSymbol(symbol); + if (strictNullChecks && + !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getFalsyFlags(type) & 32768 /* Undefined */)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -73419,7 +74808,11 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 32768 /* AwaitContext */)) { + var container = ts.getContainingFunctionOrClassStaticBlock(node); + if (container && ts.isClassStaticBlockDeclaration(container)) { + error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); + } + else if (!(node.flags & 32768 /* AwaitContext */)) { if (ts.isInTopLevelContext(node)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -73443,9 +74836,8 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); - var func = ts.getContainingFunction(node); - if (func && func.kind !== 167 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { - var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); + if (container && container.kind !== 169 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } diagnostics.add(diagnostic); @@ -73472,14 +74864,14 @@ var ts; case 8 /* NumericLiteral */: switch (node.operator) { case 40 /* MinusToken */: - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text)); case 39 /* PlusToken */: - return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text)); } break; case 9 /* BigIntLiteral */: if (node.operator === 40 /* MinusToken */) { - return getFreshTypeOfLiteralType(getLiteralType({ + return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) })); @@ -73546,8 +74938,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { - var t = types_22[_i]; + for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { + var t = types_21[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -73656,7 +75048,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 289 /* PropertyAssignment */ || property.kind === 290 /* ShorthandPropertyAssignment */) { + if (property.kind === 291 /* PropertyAssignment */ || property.kind === 292 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -73667,11 +75059,11 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 290 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 292 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 291 /* SpreadAssignment */) { + else if (property.kind === 293 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -73709,7 +75101,7 @@ var ts; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 221 /* SpreadElement */) { + if (node.elements[i].kind === 223 /* SpreadElement */) { type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); @@ -73719,14 +75111,14 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 223 /* OmittedExpression */) { - if (element.kind !== 221 /* SpreadElement */) { - var indexType = getLiteralType(elementIndex); + if (element.kind !== 225 /* OmittedExpression */) { + if (element.kind !== 223 /* SpreadElement */) { + var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = 16 /* ExpressionPosition */ | (hasDefaultValue(element) ? 8 /* NoTupleBoundsCheck */ : 0); - var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, createSyntheticExpression(element, indexType), accessFlags) || errorType; + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0); + var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); @@ -73738,7 +75130,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 217 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { + if (restExpression.kind === 219 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -73754,7 +75146,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 290 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 292 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -73770,24 +75162,24 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 217 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { + if (target.kind === 219 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 201 /* ObjectLiteralExpression */) { + if (target.kind === 203 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 200 /* ArrayLiteralExpression */) { + if (target.kind === 202 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 291 /* SpreadAssignment */ ? + var error = target.parent.kind === 293 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 291 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 293 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { @@ -73809,39 +75201,39 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 206 /* TaggedTemplateExpression */: - case 219 /* TemplateExpression */: + case 208 /* TaggedTemplateExpression */: + case 221 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 150 /* UndefinedKeyword */: - case 209 /* FunctionExpression */: - case 222 /* ClassExpression */: - case 210 /* ArrowFunction */: - case 200 /* ArrayLiteralExpression */: - case 201 /* ObjectLiteralExpression */: - case 212 /* TypeOfExpression */: - case 226 /* NonNullExpression */: - case 275 /* JsxSelfClosingElement */: - case 274 /* JsxElement */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 151 /* UndefinedKeyword */: + case 211 /* FunctionExpression */: + case 224 /* ClassExpression */: + case 212 /* ArrowFunction */: + case 202 /* ArrayLiteralExpression */: + case 203 /* ObjectLiteralExpression */: + case 214 /* TypeOfExpression */: + case 228 /* NonNullExpression */: + case 277 /* JsxSelfClosingElement */: + case 276 /* JsxElement */: return true; - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 215 /* PrefixUnaryExpression */: - case 216 /* PostfixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -73853,9 +75245,9 @@ var ts; } return false; // Some forms listed here for clarity - case 213 /* VoidExpression */: // Explicit opt-out - case 207 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 225 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 215 /* VoidExpression */: // Explicit opt-out + case 209 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 227 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -73892,9 +75284,9 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 62 /* EqualsToken */ && (node.left.kind === 201 /* ObjectLiteralExpression */ || node.left.kind === 200 /* ArrayLiteralExpression */)) { + if (operator === 63 /* EqualsToken */ && (node.left.kind === 203 /* ObjectLiteralExpression */ || node.left.kind === 202 /* ArrayLiteralExpression */)) { state.skip = true; - setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107 /* ThisKeyword */)); + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); return state; } return state; @@ -73985,8 +75377,8 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 62 /* EqualsToken */ && (left.kind === 201 /* ObjectLiteralExpression */ || left.kind === 200 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107 /* ThisKeyword */); + if (operator === 63 /* EqualsToken */ && (left.kind === 203 /* ObjectLiteralExpression */ || left.kind === 202 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); } var leftType; if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { @@ -74003,26 +75395,26 @@ var ts; switch (operator) { case 41 /* AsteriskToken */: case 42 /* AsteriskAsteriskToken */: - case 65 /* AsteriskEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: case 44 /* PercentToken */: - case 68 /* PercentEqualsToken */: + case 69 /* PercentEqualsToken */: case 40 /* MinusToken */: - case 64 /* MinusEqualsToken */: + case 65 /* MinusEqualsToken */: case 47 /* LessThanLessThanToken */: - case 69 /* LessThanLessThanEqualsToken */: + case 70 /* LessThanLessThanEqualsToken */: case 48 /* GreaterThanGreaterThanToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -74052,11 +75444,11 @@ var ts; else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: if (languageVersion < 3 /* ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } @@ -74074,7 +75466,7 @@ var ts; return resultType_1; } case 39 /* PlusToken */: - case 63 /* PlusEqualsToken */: + case 64 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -74117,7 +75509,7 @@ var ts; }); return anyType; } - if (operator === 63 /* PlusEqualsToken */) { + if (operator === 64 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; @@ -74139,41 +75531,41 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 100 /* InKeyword */: + case 101 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); case 55 /* AmpersandAmpersandToken */: - case 75 /* AmpersandAmpersandEqualsToken */: { + case 76 /* AmpersandAmpersandEqualsToken */: { var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 75 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } case 56 /* BarBarToken */: - case 74 /* BarBarEqualsToken */: { + case 75 /* BarBarEqualsToken */: { var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 74 /* BarBarEqualsToken */) { + if (operator === 75 /* BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } case 60 /* QuestionQuestionToken */: - case 76 /* QuestionQuestionEqualsToken */: { + case 77 /* QuestionQuestionEqualsToken */: { var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 76 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -74229,7 +75621,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -74245,13 +75637,13 @@ var ts; function getSuggestedBooleanOperator(operator) { switch (operator) { case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: return 56 /* BarBarToken */; case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: return 37 /* ExclamationEqualsEqualsToken */; case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; default: return undefined; @@ -74420,6 +75812,11 @@ var ts; var type2 = checkExpression(node.whenFalse, checkMode); return getUnionType([type1, type2], 2 /* Subtype */); } + function isTemplateLiteralContext(node) { + var parent = node.parent; + return ts.isParenthesizedExpression(parent) && isTemplateLiteralContext(parent) || + ts.isElementAccessExpression(parent) && parent.argumentExpression === node; + } function checkTemplateExpression(node) { var texts = [node.head.text]; var types = []; @@ -74432,14 +75829,14 @@ var ts; texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return isConstContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; + return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); } function getContextNode(node) { - if (node.kind === 282 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 284 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -74488,13 +75885,13 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 207 /* TypeAssertionExpression */ || node.kind === 225 /* AsExpression */; + return node.kind === 209 /* TypeAssertionExpression */ || node.kind === 227 /* AsExpression */; } function checkDeclarationInitializer(declaration, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer)); - return ts.isParameter(declaration) && declaration.name.kind === 198 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 200 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -74504,7 +75901,7 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 199 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 201 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); elementFlags.push(2 /* Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { @@ -74517,7 +75914,7 @@ var ts; function widenTypeInferredFromInitializer(declaration, type) { var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 98304 /* Nullable */) { + if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); return anyType; } @@ -74571,7 +75968,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 === 159 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -74582,7 +75979,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 === 159 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -74709,7 +76106,7 @@ var ts; len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { - var augmentedName = (s + index); + var augmentedName = s + index; if (!hasTypeParameterByName(typeParameters, augmentedName)) { return augmentedName; } @@ -74758,7 +76155,7 @@ var ts; var expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (ts.isCallExpression(expr) && expr.expression.kind !== 105 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -74769,7 +76166,7 @@ var ts; return getTypeFromTypeNode(expr.type); } else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 109 /* TrueKeyword */ || node.kind === 94 /* FalseKeyword */) { + node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { return checkExpression(node); } return undefined; @@ -74818,11 +76215,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 202 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 203 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 78 /* Identifier */ || node.kind === 158 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 177 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 271 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 204 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 205 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 179 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 273 /* ExportSpecifier */); // We allow reexporting const enums 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_or_type_query); } @@ -74837,7 +76234,7 @@ var ts; function checkParenthesizedExpression(node, checkMode) { var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined; if (tag) { - return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); + return checkAssertionWorker(tag.typeExpression.type, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -74847,106 +76244,109 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 222 /* ClassExpression */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 224 /* ClassExpression */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return checkIdentifier(node, checkMode); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return checkThisExpression(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: - return getFreshTypeOfLiteralType(getLiteralType(node.text)); + return getFreshTypeOfLiteralType(getStringLiteralType(node.text)); case 8 /* NumericLiteral */: checkGrammarNumericLiteral(node); - return getFreshTypeOfLiteralType(getLiteralType(+node.text)); + return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text)); case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); - return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 109 /* TrueKeyword */: + return getFreshTypeOfLiteralType(getBigIntLiteralType({ + negative: false, + base10Value: ts.parsePseudoBigInt(node.text) + })); + case 110 /* TrueKeyword */: return trueType; - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: return falseType; - case 219 /* TemplateExpression */: + case 221 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: return checkQualifiedName(node, checkMode); - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 204 /* CallExpression */: - if (node.expression.kind === 99 /* ImportKeyword */) { + case 206 /* CallExpression */: + if (node.expression.kind === 100 /* ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 205 /* NewExpression */: + case 207 /* NewExpression */: return checkCallExpression(node, checkMode); - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 222 /* ClassExpression */: + case 224 /* ClassExpression */: return checkClassExpression(node); - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 212 /* TypeOfExpression */: + case 214 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 207 /* TypeAssertionExpression */: - case 225 /* AsExpression */: + case 209 /* TypeAssertionExpression */: + case 227 /* AsExpression */: return checkAssertion(node); - case 226 /* NonNullExpression */: + case 228 /* NonNullExpression */: return checkNonNullAssertion(node); - case 227 /* MetaProperty */: + case 229 /* MetaProperty */: return checkMetaProperty(node); - case 211 /* DeleteExpression */: + case 213 /* DeleteExpression */: return checkDeleteExpression(node); - case 213 /* VoidExpression */: + case 215 /* VoidExpression */: return checkVoidExpression(node); - case 214 /* AwaitExpression */: + case 216 /* AwaitExpression */: return checkAwaitExpression(node); - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 216 /* PostfixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 221 /* SpreadElement */: + case 223 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 223 /* OmittedExpression */: + case 225 /* OmittedExpression */: return undefinedWideningType; - case 220 /* YieldExpression */: + case 222 /* YieldExpression */: return checkYieldExpression(node); - case 228 /* SyntheticExpression */: + case 230 /* SyntheticExpression */: return checkSyntheticExpression(node); - case 284 /* JsxExpression */: + case 286 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 274 /* JsxElement */: + case 276 /* JsxElement */: return checkJsxElement(node, checkMode); - case 275 /* JsxSelfClosingElement */: + case 277 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 278 /* JsxFragment */: + case 280 /* JsxFragment */: return checkJsxFragment(node); - case 282 /* JsxAttributes */: + case 284 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 276 /* JsxOpeningElement */: + case 278 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -74983,10 +76383,10 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 167 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 169 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 167 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 169 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -74997,13 +76397,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 167 /* Constructor */ || func.kind === 171 /* ConstructSignature */ || func.kind === 176 /* ConstructorType */) { + if (func.kind === 169 /* Constructor */ || func.kind === 173 /* ConstructSignature */ || func.kind === 178 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 210 /* ArrowFunction */) { + if (func.kind === 212 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 168 /* GetAccessor */ || func.kind === 169 /* SetAccessor */) { + if (func.kind === 170 /* GetAccessor */ || func.kind === 171 /* SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -75061,13 +76461,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 210 /* ArrowFunction */: - case 170 /* CallSignature */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 175 /* FunctionType */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: + case 212 /* ArrowFunction */: + case 172 /* CallSignature */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 177 /* FunctionType */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -75081,11 +76481,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 78 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 198 /* ArrayBindingPattern */ || name.kind === 197 /* ObjectBindingPattern */) { + else if (name.kind === 200 /* ArrayBindingPattern */ || name.kind === 199 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -75094,13 +76494,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 172 /* IndexSignature */) { + if (node.kind === 174 /* IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 175 /* FunctionType */ || node.kind === 252 /* FunctionDeclaration */ || node.kind === 176 /* ConstructorType */ || - node.kind === 170 /* CallSignature */ || node.kind === 167 /* Constructor */ || - node.kind === 171 /* ConstructSignature */) { + else if (node.kind === 177 /* FunctionType */ || node.kind === 254 /* FunctionDeclaration */ || node.kind === 178 /* ConstructorType */ || + node.kind === 172 /* CallSignature */ || node.kind === 169 /* Constructor */ || + node.kind === 173 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -75130,10 +76530,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 171 /* ConstructSignature */: + case 173 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 170 /* CallSignature */: + case 172 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -75163,7 +76563,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 172 /* IndexSignature */ && node.kind !== 309 /* JSDocFunctionType */) { + if (node.kind !== 174 /* IndexSignature */ && node.kind !== 312 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -75175,7 +76575,7 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 167 /* Constructor */) { + if (member.kind === 169 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { @@ -75184,29 +76584,29 @@ var ts; } } else { - var isStatic = ts.hasSyntacticModifier(member, 32 /* Static */); + var isStaticMember = ts.isStatic(member); var name = member.name; if (!name) { continue; } var isPrivate = ts.isPrivateIdentifier(name); - var privateStaticFlags = isPrivate && isStatic ? 16 /* PrivateStatic */ : 0; + var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0; var names = isPrivate ? privateIdentifiers : - isStatic ? staticNames : + isStaticMember ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 168 /* GetAccessor */: + case 170 /* GetAccessor */: addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); break; - case 169 /* SetAccessor */: + case 171 /* SetAccessor */: addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); break; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); break; - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); break; } @@ -75257,8 +76657,8 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; var memberNameNode = member.name; - var isStatic = ts.hasSyntacticModifier(member, 32 /* Static */); - if (isStatic && memberNameNode) { + var isStaticMember = ts.isStatic(member); + if (isStaticMember && memberNameNode) { var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode); switch (memberName) { case "name": @@ -75278,7 +76678,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 163 /* PropertySignature */) { + if (member.kind === 164 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -75286,7 +76686,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 78 /* Identifier */: + case 79 /* Identifier */: memberName = ts.idText(name); break; default: @@ -75303,7 +76703,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 254 /* InterfaceDeclaration */) { + if (node.kind === 256 /* 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 @@ -75316,32 +76716,32 @@ var ts; // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { - var seenNumericIndexer = false; - var seenStringIndexer = false; - for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var declaration = decl; + var indexSignatureMap_1 = new ts.Map(); + var _loop_26 = function (declaration) { if (declaration.parameters.length === 1 && declaration.parameters[0].type) { - switch (declaration.parameters[0].type.kind) { - case 147 /* StringKeyword */: - if (!seenStringIndexer) { - seenStringIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_string_index_signature); - } - break; - case 144 /* NumberKeyword */: - if (!seenNumericIndexer) { - seenNumericIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_number_index_signature); - } - break; - } + forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) { + var entry = indexSignatureMap_1.get(getTypeId(type)); + if (entry) { + entry.declarations.push(declaration); + } + else { + indexSignatureMap_1.set(getTypeId(type), { type: type, declarations: [declaration] }); + } + }); } + }; + for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + _loop_26(declaration); } + indexSignatureMap_1.forEach(function (entry) { + if (entry.declarations.length > 1) { + for (var _i = 0, _a = entry.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + error(declaration, ts.Diagnostics.Duplicate_index_signature_for_type_0, typeToString(entry.type)); + } + } + }); } } function checkPropertyDeclaration(node) { @@ -75353,6 +76753,10 @@ var ts; if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) { error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag); } + // property signatures already report "initializer not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* PropertyDeclaration */ && node.initializer) { + error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); + } } function checkPropertySignature(node) { if (ts.isPrivateIdentifier(node.name)) { @@ -75366,9 +76770,8 @@ var ts; checkGrammarComputedPropertyName(node.name); // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); - // Abstract methods cannot have an implementation. - // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* MethodDeclaration */ && node.body) { + // method signatures already report "implementation not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } // Private named methods are only allowed in class declarations @@ -75394,6 +76797,10 @@ var ts; } } } + function checkClassStaticBlockDeclaration(node) { + checkGrammarDecoratorsAndModifiers(node); + ts.forEachChild(node, checkSourceElement); + } function checkConstructorDeclaration(node) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. checkSignatureDeclaration(node); @@ -75418,8 +76825,8 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 164 /* PropertyDeclaration */ && - !ts.hasSyntacticModifier(n, 32 /* Static */) && + return n.kind === 165 /* PropertyDeclaration */ && + !ts.isStatic(n) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 @@ -75449,7 +76856,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { var statement = statements_4[_i]; - if (statement.kind === 234 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 236 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -75474,7 +76881,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 168 /* GetAccessor */) { + if (node.kind === 170 /* GetAccessor */) { if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -75484,15 +76891,15 @@ 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 === 159 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var symbol = getSymbolOfNode(node); - var getter = ts.getDeclarationOfKind(symbol, 168 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 169 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 170 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 171 /* SetAccessor */); if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { getNodeLinks(getter).flags |= 1 /* TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); @@ -75514,7 +76921,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 168 /* GetAccessor */) { + if (node.kind === 170 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -75556,7 +76963,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 174 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 176 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -75609,7 +77016,7 @@ var ts; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) { var e = elementTypes_1[_i]; - if (e.kind !== 193 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 195 /* NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } @@ -75658,7 +77065,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 203 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 205 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -75667,7 +77074,7 @@ var ts; // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. var apparentObjectType = getApparentType(objectType); - if (getIndexInfoOfType(apparentObjectType, 1 /* Number */) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { return type; } if (isGenericObjectType(objectType)) { @@ -75716,7 +77123,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 185 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 187 /* ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -75739,10 +77146,10 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 181 /* OptionalType */) { + if (node.type.kind === 183 /* OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 182 /* RestType */) { + if (node.type.kind === 184 /* RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); @@ -75755,9 +77162,9 @@ var ts; var flags = ts.getCombinedModifierFlags(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 !== 254 /* InterfaceDeclaration */ && - n.parent.kind !== 253 /* ClassDeclaration */ && - n.parent.kind !== 222 /* ClassExpression */ && + if (n.parent.kind !== 256 /* InterfaceDeclaration */ && + n.parent.kind !== 255 /* ClassDeclaration */ && + n.parent.kind !== 224 /* ClassExpression */ && n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported @@ -75853,14 +77260,14 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 166 /* MethodDeclaration */ || node.kind === 165 /* MethodSignature */) && - ts.hasSyntacticModifier(node, 32 /* Static */) !== ts.hasSyntacticModifier(subsequentNode, 32 /* Static */); + var reportError = (node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */) && + ts.isStatic(node) !== ts.isStatic(subsequentNode); // 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 = ts.hasSyntacticModifier(node, 32 /* Static */) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + var diagnostic = ts.isStatic(node) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); } return; @@ -75895,7 +77302,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 8388608 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 254 /* InterfaceDeclaration */ || node.parent.kind === 178 /* TypeLiteral */) || inAmbientContext; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 256 /* InterfaceDeclaration */ || node.parent.kind === 180 /* TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -75906,10 +77313,10 @@ 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 === 253 /* ClassDeclaration */ || node.kind === 222 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 255 /* ClassDeclaration */ || node.kind === 224 /* ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 252 /* FunctionDeclaration */ || node.kind === 166 /* MethodDeclaration */ || node.kind === 165 /* MethodSignature */ || node.kind === 167 /* Constructor */) { + if (node.kind === 254 /* FunctionDeclaration */ || node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */ || node.kind === 169 /* Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -75953,13 +77360,18 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { - // A non-ambient class cannot be an implementation for a non-constructor function/class merge - // TODO: The below just replicates our older error from when classes and functions were - // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" - // might be warranted. :shrug: + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 255 /* ClassDeclaration */; }) + .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations); + var diagnostic = declaration.kind === 255 /* ClassDeclaration */ + ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 + : declaration.kind === 254 /* FunctionDeclaration */ + ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient + : undefined; + if (diagnostic) { + ts.addRelatedInfo.apply(void 0, __spreadArray([error(ts.getNameOfDeclaration(declaration) || declaration, diagnostic, ts.symbolName(symbol))], relatedDiagnostics_1, false)); + } }); } // Abstract methods can't have an implementation -- in particular, they don't need one. @@ -76045,26 +77457,26 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 335 /* JSDocTypedefTag */: - case 328 /* JSDocCallbackTag */: - case 329 /* JSDocEnumTag */: + case 340 /* JSDocTypedefTag */: + case 333 /* JSDocCallbackTag */: + case 334 /* JSDocEnumTag */: return 2 /* ExportType */; - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 253 /* ClassDeclaration */: - case 256 /* EnumDeclaration */: - case 292 /* EnumMember */: + case 255 /* ClassDeclaration */: + case 258 /* EnumDeclaration */: + case 294 /* EnumMember */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 298 /* SourceFile */: + case 300 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 267 /* ExportAssignment */: - case 217 /* BinaryExpression */: + case 269 /* ExportAssignment */: + case 219 /* BinaryExpression */: var node_2 = d; var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values @@ -76074,18 +77486,18 @@ var ts; d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 261 /* ImportEqualsDeclaration */: - case 264 /* NamespaceImport */: - case 263 /* ImportClause */: - var result_13 = 0 /* None */; + case 263 /* ImportEqualsDeclaration */: + case 266 /* NamespaceImport */: + case 265 /* ImportClause */: + var result_12 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result_13 |= getDeclarationSpaces(d); }); - return result_13; - case 250 /* VariableDeclaration */: - case 199 /* BindingElement */: - case 252 /* FunctionDeclaration */: - case 266 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); + return result_12; + case 252 /* VariableDeclaration */: + case 201 /* BindingElement */: + case 254 /* FunctionDeclaration */: + case 268 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) @@ -76337,7 +77749,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 78 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -76377,24 +77789,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 161 /* Parameter */: + case 162 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -76415,8 +77827,8 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 78 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; - var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); + var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ && symbolIsValue(rootSymbol) @@ -76441,30 +77853,30 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 184 /* IntersectionType */: - case 183 /* UnionType */: + case 186 /* IntersectionType */: + case 185 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 185 /* ConditionalType */: + case 187 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 187 /* ParenthesizedType */: - case 193 /* NamedTupleMember */: + case 189 /* ParenthesizedType */: + case 195 /* NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 174 /* TypeReference */: + case 176 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { - var typeNode = types_23[_i]; - while (typeNode.kind === 187 /* ParenthesizedType */ || typeNode.kind === 193 /* NamedTupleMember */) { + for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { + var typeNode = types_22[_i]; + while (typeNode.kind === 189 /* ParenthesizedType */ || typeNode.kind === 195 /* NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 192 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 194 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -76510,14 +77922,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 161 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -76526,23 +77938,23 @@ var ts; } } break; - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - var otherKind = node.kind === 168 /* GetAccessor */ ? 169 /* SetAccessor */ : 168 /* GetAccessor */; + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + var otherKind = node.kind === 170 /* GetAccessor */ ? 171 /* SetAccessor */ : 170 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 161 /* Parameter */: + case 162 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -76558,8 +77970,7 @@ var ts; if (produceDiagnostics) { checkFunctionOrMethodDeclaration(node); checkGrammarForGenerator(node); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + checkCollisionsForDeclarationName(node, node.name); } } function checkJSDocTypeAliasTag(node) { @@ -76605,7 +78016,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 158 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 159 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -76647,9 +78058,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -76663,7 +78074,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 && node.name.kind === 159 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -76689,7 +78100,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 165 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 166 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -76731,42 +78142,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 298 /* SourceFile */: - case 257 /* ModuleDeclaration */: - case 231 /* Block */: - case 259 /* CaseBlock */: - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: + case 300 /* SourceFile */: + case 259 /* ModuleDeclaration */: + case 233 /* Block */: + case 261 /* CaseBlock */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 167 /* Constructor */: - case 209 /* FunctionExpression */: - case 252 /* FunctionDeclaration */: - case 210 /* ArrowFunction */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 169 /* Constructor */: + case 211 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: + case 212 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 165 /* MethodSignature */: - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 175 /* FunctionType */: - case 176 /* ConstructorType */: - case 255 /* TypeAliasDeclaration */: - case 254 /* InterfaceDeclaration */: + case 166 /* MethodSignature */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: + case 257 /* TypeAliasDeclaration */: + case 256 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 186 /* InferType */: + case 188 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -76786,11 +78197,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 166 /* MethodDeclaration */: - case 164 /* PropertyDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - if (member.kind === 169 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 167 /* MethodDeclaration */: + case 165 /* PropertyDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + if (member.kind === 171 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -76801,7 +78212,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 167 /* Constructor */: + case 169 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { @@ -76809,12 +78220,13 @@ var ts; } } break; - case 172 /* IndexSignature */: - case 230 /* SemicolonClassElement */: + case 174 /* IndexSignature */: + case 232 /* SemicolonClassElement */: + case 168 /* ClassStaticBlockDeclaration */: // Can't be private break; default: - ts.Debug.fail(); + ts.Debug.fail("Unexpected class member"); } } } @@ -76838,7 +78250,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 186 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 188 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -76847,12 +78259,14 @@ var ts; // Include the `<>` in the error message : ts.rangeOfTypeParameters(sourceFile, parent.typeParameters); var only = parent.typeParameters.length === 1; + //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); } } else { + //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); } } @@ -76942,7 +78356,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 264 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 266 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -76960,7 +78374,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 250 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 251 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 252 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 253 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -76981,7 +78395,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 233 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 235 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -76993,24 +78407,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.idText(name); - case 198 /* ArrayBindingPattern */: - case 197 /* ObjectBindingPattern */: + case 200 /* ArrayBindingPattern */: + case 199 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 263 /* ImportClause */ || node.kind === 266 /* ImportSpecifier */ || node.kind === 264 /* NamespaceImport */; + return node.kind === 265 /* ImportClause */ || node.kind === 268 /* ImportSpecifier */ || node.kind === 266 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 263 /* ImportClause */ ? decl : decl.kind === 264 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 265 /* ImportClause */ ? decl : decl.kind === 266 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 231 /* Block */) { + if (node.kind === 233 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -77036,25 +78450,37 @@ var ts; } }); } + /** + * Checks whether an {@link Identifier}, in the context of another {@link Node}, would collide with a runtime value + * of {@link name} in an outer scope. This is used to check for collisions for downlevel transformations that + * require names like `Object`, `Promise`, `Reflect`, `require`, `exports`, etc. + */ function needCollisionCheckForIdentifier(node, identifier, name) { - if (!(identifier && identifier.escapedText === name)) { + if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - if (node.kind === 164 /* PropertyDeclaration */ || - node.kind === 163 /* PropertySignature */ || - node.kind === 166 /* MethodDeclaration */ || - node.kind === 165 /* MethodSignature */ || - node.kind === 168 /* GetAccessor */ || - node.kind === 169 /* SetAccessor */) { - // it is ok to have member named '_super' or '_this' - member access is always qualified + if (node.kind === 165 /* PropertyDeclaration */ || + node.kind === 164 /* PropertySignature */ || + node.kind === 167 /* MethodDeclaration */ || + node.kind === 166 /* MethodSignature */ || + node.kind === 170 /* GetAccessor */ || + node.kind === 171 /* SetAccessor */ || + node.kind === 291 /* PropertyAssignment */) { + // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } if (node.flags & 8388608 /* Ambient */) { // ambient context - no codegen impact return false; } + if (ts.isImportClause(node) || ts.isImportEqualsDeclaration(node) || ts.isImportSpecifier(node)) { + // type-only imports do not require collision checks against runtime values. + if (ts.isTypeOnlyImportOrExportDeclaration(node)) { + return false; + } + } var root = ts.getRootDeclaration(node); - if (root.kind === 161 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (ts.isParameter(root) && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -77064,7 +78490,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 78 /* Identifier */; + var isDeclaration_1 = node.kind !== 79 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -77079,7 +78505,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 78 /* Identifier */; + var isDeclaration_2 = node.kind !== 79 /* Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -77091,19 +78517,12 @@ var ts; return false; }); } - function checkWeakMapSetCollision(node) { - var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); - if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { - ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); - errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); - } - } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { // No need to check for require or exports for ES6 modules and later if (moduleKind >= ts.ModuleKind.ES2015) { return; } - if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { + if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } // Uninstantiated modules shouldnt do this check @@ -77112,13 +78531,13 @@ var ts; } // 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 === 298 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 300 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { + if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check @@ -77127,11 +78546,76 @@ var ts; } // 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 === 298 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 300 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } + function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) { + if (languageVersion <= 8 /* ES2021 */ + && (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) { + potentialWeakMapSetCollisions.push(node); + } + } + function checkWeakMapSetCollision(node) { + var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); + if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { + ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); + errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); + } + } + function recordPotentialCollisionWithReflectInGeneratedCode(node, name) { + if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ + && needCollisionCheckForIdentifier(node, name, "Reflect")) { + potentialReflectCollisions.push(node); + } + } + function checkReflectCollision(node) { + var hasCollision = false; + if (ts.isClassExpression(node)) { + // ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members. + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + hasCollision = true; + break; + } + } + } + else if (ts.isFunctionExpression(node)) { + // FunctionExpression names don't contribute to their containers, but do matter for their contents + if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + hasCollision = true; + } + } + else { + var container = ts.getEnclosingBlockScopeContainer(node); + if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + hasCollision = true; + } + } + if (hasCollision) { + ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name), "The target of a Reflect collision check should be an identifier"); + errorSkippedOn("noEmit", node, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializers, ts.declarationNameToString(node.name), "Reflect"); + } + } + function checkCollisionsForDeclarationName(node, name) { + if (!name) + return; + checkCollisionWithRequireExportsInGeneratedCode(node, name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, name); + recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name); + recordPotentialCollisionWithReflectInGeneratedCode(node, name); + if (ts.isClassLike(node)) { + checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0); + if (!(node.flags & 8388608 /* Ambient */)) { + checkClassNameCollisionWithObject(name); + } + } + else if (ts.isEnumDeclaration(node)) { + checkTypeNameIsReserved(name, ts.Diagnostics.Enum_name_cannot_be_0); + } + } function checkVarDeclaredNamesNotShadowed(node) { // - ScriptBody : StatementList // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList @@ -77162,7 +78646,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 === 250 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 252 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -77174,17 +78658,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 251 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 233 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 253 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 235 /* 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 === 231 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 258 /* ModuleBlock */ || - container.kind === 257 /* ModuleDeclaration */ || - container.kind === 298 /* SourceFile */); + (container.kind === 233 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 260 /* ModuleBlock */ || + container.kind === 259 /* ModuleDeclaration */ || + container.kind === 300 /* 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 @@ -77215,7 +78699,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 === 159 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -77226,7 +78710,7 @@ var ts; checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 159 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -77240,14 +78724,14 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 105 /* SuperKeyword */, /*writing*/ false, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 198 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 200 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -77259,7 +78743,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 239 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 241 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -77301,7 +78785,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 239 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 241 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -77327,23 +78811,18 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 164 /* PropertyDeclaration */ && node.kind !== 163 /* PropertySignature */) { + if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 250 /* VariableDeclaration */ || node.kind === 199 /* BindingElement */) { + if (node.kind === 252 /* VariableDeclaration */ || node.kind === 201 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (languageVersion < 99 /* ESNext */ - && (needCollisionCheckForIdentifier(node, node.name, "WeakMap") || needCollisionCheckForIdentifier(node, node.name, "WeakSet"))) { - potentialWeakMapSetCollisions.push(node); - } + checkCollisionsForDeclarationName(node, node.name); } } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 164 /* PropertyDeclaration */ || nextDeclaration.kind === 163 /* PropertySignature */ + var message = nextDeclaration.kind === 165 /* PropertyDeclaration */ || nextDeclaration.kind === 164 /* PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -77353,8 +78832,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 161 /* Parameter */ && right.kind === 250 /* VariableDeclaration */) || - (left.kind === 250 /* VariableDeclaration */ && right.kind === 161 /* Parameter */)) { + if ((left.kind === 162 /* Parameter */ && right.kind === 252 /* VariableDeclaration */) || + (left.kind === 252 /* VariableDeclaration */ && right.kind === 162 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -77396,7 +78875,7 @@ var ts; var type = checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 232 /* EmptyStatement */) { + if (node.thenStatement.kind === 234 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -77407,15 +78886,13 @@ var ts; if (getFalsyFlags(type)) return; var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; + if (ts.isPropertyAccessExpression(location) && ts.isAssertionExpression(ts.skipParentheses(location.expression))) { + return; + } var testedNode = ts.isIdentifier(location) ? location : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) - && ts.isAssertionExpression(ts.skipParentheses(location.expression)); - if (!testedNode || isPropertyExpressionCast) { - return; - } // While it technically should be invalid for any known-truthy value // to be tested, we de-scope to functions and Promises unreferenced in // the block as a heuristic to identify the most common bugs. There @@ -77426,12 +78903,12 @@ var ts; if (callSignatures.length === 0 && !isPromise) { return; } - var testedSymbol = getSymbolAtLocation(testedNode); - if (!testedSymbol) { + var testedSymbol = testedNode && getSymbolAtLocation(testedNode); + if (!testedSymbol && !isPromise) { return; } - var isUsed = ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) - || body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol); + var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) + || testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { if (isPromise) { errorAndMaybeSuggestAwait(location, @@ -77456,7 +78933,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 107 /* ThisKeyword */ && childExpression.kind === 107 /* ThisKeyword */) { + testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -77521,12 +78998,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 251 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 253 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 251 /* VariableDeclarationList */) { + if (node.initializer.kind === 253 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -77544,11 +79021,17 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); + var container = ts.getContainingFunctionOrClassStaticBlock(node); if (node.awaitModifier) { - var functionFlags = ts.getFunctionFlags(ts.getContainingFunction(node)); - if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { - // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper - checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + if (container && ts.isClassStaticBlockDeclaration(container)) { + grammarErrorOnNode(node.awaitModifier, ts.Diagnostics.For_await_loops_cannot_be_used_inside_a_class_static_block); + } + else { + var functionFlags = ts.getFunctionFlags(container); + if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { + // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper + checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + } } } else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) { @@ -77560,14 +79043,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 === 251 /* VariableDeclarationList */) { + if (node.initializer.kind === 253 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 200 /* ArrayLiteralExpression */ || varExpr.kind === 201 /* ObjectLiteralExpression */) { + if (varExpr.kind === 202 /* ArrayLiteralExpression */ || varExpr.kind === 203 /* 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. @@ -77599,7 +79082,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 === 251 /* VariableDeclarationList */) { + if (node.initializer.kind === 253 /* 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); @@ -77613,7 +79096,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 === 200 /* ArrayLiteralExpression */ || varExpr.kind === 201 /* ObjectLiteralExpression */) { + if (varExpr.kind === 202 /* ArrayLiteralExpression */ || varExpr.kind === 203 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -77735,7 +79218,7 @@ var ts; } return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined; } - var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); + var arrayElementType = getIndexTypeOfType(arrayType, numberType); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { @@ -77824,8 +79307,8 @@ var ts; var yieldTypes; var returnTypes; var nextTypes; - for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { - var iterationTypes = array_10[_i]; + for (var _i = 0, array_11 = array; _i < array_11.length; _i++) { + var iterationTypes = array_11[_i]; if (iterationTypes === undefined || iterationTypes === noIterationTypes) { continue; } @@ -78327,27 +79810,31 @@ var ts; if (checkGrammarStatementInAmbientContext(node)) { return; } - var func = ts.getContainingFunction(node); - if (!func) { + var container = ts.getContainingFunctionOrClassStaticBlock(node); + if (container && ts.isClassStaticBlockDeclaration(container)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block); + return; + } + if (!container) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); return; } - var signature = getSignatureFromDeclaration(func); + var signature = getSignatureFromDeclaration(container); var returnType = getReturnTypeOfSignature(signature); - var functionFlags = ts.getFunctionFlags(func); + var functionFlags = ts.getFunctionFlags(container); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 169 /* SetAccessor */) { + if (container.kind === 171 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 167 /* Constructor */) { + else if (container.kind === 169 /* Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (getReturnTypeFromAnnotation(func)) { + else if (getReturnTypeFromAnnotation(container)) { var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; var unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(exprType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) @@ -78360,7 +79847,7 @@ var ts; } } } - else if (func.kind !== 167 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (container.kind !== 169 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -78389,7 +79876,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 286 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 288 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -78398,7 +79885,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 285 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 287 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -78430,7 +79917,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 246 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 248 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -78488,87 +79975,83 @@ var ts; checkBlock(node.finallyBlock); } } - function checkIndexConstraints(type, isStatic) { - var _a, _b, _c, _d; - var declaredNumberIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.exports : (_b = type.symbol) === null || _b === void 0 ? void 0 : _b.members, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_c = type.symbol) === null || _c === void 0 ? void 0 : _c.exports : (_d = type.symbol) === null || _d === void 0 ? void 0 : _d.members, 0 /* String */); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType || numberIndexType) { - ts.forEach(getPropertiesOfObjectType(type), function (prop) { - if (isStatic && prop.flags & 4194304 /* Prototype */) - return; - var propType = getTypeOfSymbol(prop); - checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); - checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); - }); - var classDeclaration = type.symbol.valueDeclaration; - if (ts.getObjectFlags(type) & 1 /* Class */ && classDeclaration && ts.isClassLike(classDeclaration)) { - for (var _i = 0, _e = classDeclaration.members; _i < _e.length; _i++) { - var member = _e[_i]; - // Only process instance properties with computed names here. - // Static properties cannot be in conflict with indexers, - // and properties with literal names were already checked. - if (!ts.hasSyntacticModifier(member, 32 /* Static */) && !hasBindableName(member)) { - var symbol = getSymbolOfNode(member); - var propType = getTypeOfSymbol(symbol); - checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); - checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); - } + function checkIndexConstraints(type, isStaticIndex) { + var indexInfos = getIndexInfosOfType(type); + if (indexInfos.length === 0) { + return; + } + for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) { + checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); + } + } + var typeDeclaration = type.symbol.valueDeclaration; + if (typeDeclaration && ts.isClassLike(typeDeclaration)) { + for (var _b = 0, _c = typeDeclaration.members; _b < _c.length; _b++) { + var member = _c[_b]; + // Only process instance properties with computed names here. Static properties cannot be in conflict with indexers, + // and properties with literal names were already checked. + if (!ts.isStatic(member) && !hasBindableName(member)) { + var symbol = getSymbolOfNode(member); + checkIndexConstraintForProperty(type, symbol, getTypeOfExpression(member.name.expression), getNonMissingTypeOfSymbol(symbol)); } } } - var errorNode; - if (stringIndexType && numberIndexType) { - errorNode = declaredNumberIndexer || declaredStringIndexer; - // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer - if (!errorNode && (ts.getObjectFlags(type) & 2 /* Interface */)) { - var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers || !type.symbol.declarations ? undefined : type.symbol.declarations[0]; + if (indexInfos.length > 1) { + for (var _d = 0, indexInfos_6 = indexInfos; _d < indexInfos_6.length; _d++) { + var info = indexInfos_6[_d]; + checkIndexConstraintForIndexSignature(type, info); } } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { // TODO: GH#18217 - error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); + } + function checkIndexConstraintForProperty(type, prop, propNameType, propType) { + var declaration = prop.valueDeclaration; + var name = ts.getNameOfDeclaration(declaration); + if (name && ts.isPrivateIdentifier(name)) { + return; } - function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { - // ESSymbol properties apply to neither string nor numeric indexers. - if (!indexType || ts.isKnownSymbol(prop)) { - return; - } - var propDeclaration = prop.valueDeclaration; - var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); - if (name && ts.isPrivateIdentifier(name)) { - return; - } - // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { - return; + var indexInfos = getApplicableIndexInfos(type, propNameType); + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 256 /* InterfaceDeclaration */) : undefined; + var localPropDeclaration = declaration && declaration.kind === 219 /* BinaryExpression */ || + name && name.kind === 160 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var _loop_27 = function (info) { + var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; + // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared + // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and + // the index signature (i.e. property and index signature are declared in separate inherited interfaces). + var errorNode = localPropDeclaration || localIndexDeclaration || + (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined); + if (errorNode && !isTypeAssignableTo(propType, info.type)) { + error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); } - // perform property check if property or indexer is declared in 'type' - // this allows us to rule out cases when both property and indexer are inherited from the base class - var errorNode; - if (propDeclaration && name && - (propDeclaration.kind === 217 /* BinaryExpression */ || - name.kind === 159 /* ComputedPropertyName */ || - prop.parent === containingType.symbol)) { - errorNode = propDeclaration; - } - else if (indexDeclaration) { - errorNode = indexDeclaration; - } - else if (ts.getObjectFlags(containingType) & 2 /* Interface */) { - // for interfaces property and indexer might be inherited from different bases - // check if any base class already has both property and indexer. - // check should be performed only if 'type' is the first type that brings property\indexer together - var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer || !containingType.symbol.declarations ? undefined : containingType.symbol.declarations[0]; - } - if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { - var errorMessage = indexKind === 0 /* String */ - ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 - : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); + }; + for (var _i = 0, indexInfos_7 = indexInfos; _i < indexInfos_7.length; _i++) { + var info = indexInfos_7[_i]; + _loop_27(info); + } + } + function checkIndexConstraintForIndexSignature(type, checkInfo) { + var declaration = checkInfo.declaration; + var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 256 /* InterfaceDeclaration */) : undefined; + var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; + var _loop_28 = function (info) { + if (info === checkInfo) + return "continue"; + var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; + // We check only when (a) the check index signature is declared in the containing type, or (b) the applicable index + // signature is declared in the containing type, or (c) the containing type is an interface and no base interface contains + // both index signatures (i.e. the index signatures are declared in separate inherited interfaces). + var errorNode = localCheckDeclaration || localIndexDeclaration || + (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getIndexInfoOfType(base, checkInfo.keyType) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined); + if (errorNode && !isTypeAssignableTo(checkInfo.type, info.type)) { + error(errorNode, ts.Diagnostics._0_index_type_1_is_not_assignable_to_2_index_type_3, typeToString(checkInfo.keyType), typeToString(checkInfo.type), typeToString(info.keyType), typeToString(info.type)); } + }; + for (var _i = 0, indexInfos_8 = indexInfos; _i < indexInfos_8.length; _i++) { + var info = indexInfos_8[_i]; + _loop_28(info); } } function checkTypeNameIsReserved(name, message) { @@ -78627,7 +80110,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 174 /* TypeReference */) { + if (node.kind === 176 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -78726,14 +80209,7 @@ var ts; function checkClassLikeDeclaration(node) { checkGrammarClassLikeDeclaration(node); checkDecorators(node); - if (node.name) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 8388608 /* Ambient */)) { - checkClassNameCollisionWithObject(node.name); - } - } + checkCollisionsForDeclarationName(node, node.name); checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); @@ -78835,7 +80311,7 @@ var ts; } if (produceDiagnostics) { checkIndexConstraints(type); - checkIndexConstraints(staticType, /*isStatic*/ true); + checkIndexConstraints(staticType, /*isStaticIndex*/ true); checkTypeForDuplicateIndexSignatures(node); checkPropertyInitialization(node); } @@ -78846,7 +80322,7 @@ var ts; var baseTypes = baseTypeNode && getBaseTypes(type); var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined; var baseStaticType = getBaseConstructorTypeOfClass(type); - var _loop_24 = function (member) { + var _loop_29 = function (member) { if (ts.hasAmbientModifier(member)) { return "continue"; } @@ -78861,11 +80337,11 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_24(member); + _loop_29(member); } function checkClassMember(member, memberIsParameterProperty) { var hasOverride = ts.hasOverrideModifier(member); - var hasStatic = ts.hasStaticModifier(member); + var hasStatic = ts.isStatic(member); if (baseWithThis && (hasOverride || compilerOptions.noImplicitOverride)) { var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); if (!declaredProp) { @@ -78877,10 +80353,13 @@ var ts; var baseProp = getPropertyOfType(baseType, declaredProp.escapedName); var baseClassName = typeToString(baseWithThis); if (prop && !baseProp && hasOverride) { - error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); + var suggestion = getSuggestedSymbolForNonexistentClassMember(ts.symbolName(declaredProp), baseType); + suggestion ? + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1, baseClassName, symbolToString(suggestion)) : + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); } - else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.valueDeclaration) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { - var baseHasAbstract = ts.hasAbstractModifier(baseProp.valueDeclaration); + else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { + var baseHasAbstract = ts.some(baseProp.declarations, function (d) { return ts.hasAbstractModifier(d); }); if (hasOverride) { return; } @@ -78904,8 +80383,8 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_25 = function (member) { - if (ts.hasStaticModifier(member)) { + var _loop_30 = function (member) { + if (ts.isStatic(member)) { return "continue"; } var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); @@ -78923,7 +80402,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_25(member); + _loop_30(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -78949,7 +80428,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 253 /* ClassDeclaration */ || d.kind === 254 /* InterfaceDeclaration */; + return d.kind === 255 /* ClassDeclaration */ || d.kind === 256 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -79005,7 +80484,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 222 /* ClassExpression */) { + if (derivedClassDecl.kind === 224 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -79026,7 +80505,7 @@ var ts; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 254 /* InterfaceDeclaration */ + || base.valueDeclaration && base.valueDeclaration.parent.kind === 256 /* InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment @@ -79041,7 +80520,7 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 164 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 165 /* PropertyDeclaration */ && !d.initializer; }); if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 128 /* Abstract */) @@ -79143,7 +80622,7 @@ var ts; if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) { continue; } - if (isInstancePropertyWithoutInitializer(member)) { + if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); @@ -79156,12 +80635,29 @@ var ts; } } } - function isInstancePropertyWithoutInitializer(node) { - return node.kind === 164 /* PropertyDeclaration */ && - !ts.hasSyntacticModifier(node, 32 /* Static */ | 128 /* Abstract */) && + function isPropertyWithoutInitializer(node) { + return node.kind === 165 /* PropertyDeclaration */ && + !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; } + function isPropertyInitializedInStaticBlocks(propName, propType, staticBlocks, startPos, endPos) { + for (var _i = 0, staticBlocks_2 = staticBlocks; _i < staticBlocks_2.length; _i++) { + var staticBlock = staticBlocks_2[_i]; + // static block must be within the provided range as they are evaluated in document order (unlike constructors) + if (staticBlock.pos >= startPos && staticBlock.pos <= endPos) { + var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName); + ts.setParent(reference.expression, reference); + ts.setParent(reference, staticBlock); + reference.flowNode = staticBlock.returnFlowNode; + var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); + if (!(getFalsyFlags(flowType) & 32768 /* Undefined */)) { + return true; + } + } + } + return false; + } function isPropertyInitializedInConstructor(propName, propType, constructor) { var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName); ts.setParent(reference.expression, reference); @@ -79181,7 +80677,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 254 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 256 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -79214,7 +80710,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 136 /* IntrinsicKeyword */) { + if (node.type.kind === 137 /* IntrinsicKeyword */) { if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); } @@ -79243,7 +80739,7 @@ var ts; } else { var text = ts.getTextOfPropertyName(member.name); - if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) { + if (isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } } @@ -79300,7 +80796,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -79310,7 +80806,7 @@ var ts; } } break; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -79339,22 +80835,22 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 78 /* Identifier */: + case 79 /* Identifier */: var identifier = expr; - if (isInfinityOrNaNString(identifier.escapedText)) { + if (ts.isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 203 /* ElementAccessExpression */: - case 202 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 202 /* PropertyAccessExpression */) { + if (ex.kind === 204 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -79386,9 +80882,9 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 78 /* Identifier */ || - node.kind === 202 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 203 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* Identifier */ || + node.kind === 204 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 205 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -79397,9 +80893,7 @@ var ts; } // Grammar checking checkGrammarDecoratorsAndModifiers(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + checkCollisionsForDeclarationName(node, node.name); checkExportsOnMergedDeclarations(node); node.members.forEach(checkEnumMember); computeEnumMemberValues(node); @@ -79424,7 +80918,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 256 /* EnumDeclaration */) { + if (declaration.kind !== 258 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -79453,8 +80947,8 @@ var ts; if (declarations) { for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 253 /* ClassDeclaration */ || - (declaration.kind === 252 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 255 /* ClassDeclaration */ || + (declaration.kind === 254 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } @@ -79497,8 +80991,7 @@ var ts; } } if (ts.isIdentifier(node.name)) { - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + checkCollisionsForDeclarationName(node, node.name); } checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); @@ -79519,7 +81012,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, 253 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 255 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -79570,23 +81063,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 267 /* ExportAssignment */: - case 268 /* ExportDeclaration */: + case 269 /* ExportAssignment */: + case 270 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 261 /* ImportEqualsDeclaration */: - case 262 /* ImportDeclaration */: + case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 199 /* BindingElement */: - case 250 /* VariableDeclaration */: + case 201 /* BindingElement */: + case 252 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -79597,12 +81090,12 @@ var ts; break; } // falls through - case 253 /* ClassDeclaration */: - case 256 /* EnumDeclaration */: - case 252 /* FunctionDeclaration */: - case 254 /* InterfaceDeclaration */: - case 257 /* ModuleDeclaration */: - case 255 /* TypeAliasDeclaration */: + case 255 /* ClassDeclaration */: + case 258 /* EnumDeclaration */: + case 254 /* FunctionDeclaration */: + case 256 /* InterfaceDeclaration */: + case 259 /* ModuleDeclaration */: + case 257 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -79623,20 +81116,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } @@ -79650,9 +81143,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 258 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 298 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 268 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 260 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 300 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 270 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -79687,14 +81180,14 @@ var ts; (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 271 /* ExportSpecifier */ ? + var message = node.kind === 273 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 271 /* ExportSpecifier */ + && node.kind === 273 /* ExportSpecifier */ && !node.parent.parent.isTypeOnly && !(target.flags & 111551 /* Value */) && !(node.flags & 8388608 /* Ambient */)) { @@ -79706,10 +81199,9 @@ var ts; } } function checkImportBinding(node) { - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 266 /* ImportSpecifier */ && + if (node.kind === 268 /* ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && compilerOptions.esModuleInterop && moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { @@ -79731,7 +81223,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 264 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 266 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) { // import * as ns from "foo"; @@ -79759,7 +81251,7 @@ var ts; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 273 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 275 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { @@ -79802,10 +81294,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 258 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 258 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 260 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 260 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; - if (node.parent.kind !== 298 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 300 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -79838,14 +81330,14 @@ var ts; } function checkGrammarExportDeclaration(node) { var _a; - var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 269 /* NamedExports */; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 271 /* NamedExports */; if (isTypeOnlyExportStar) { grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); } return !isTypeOnlyExportStar; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 298 /* SourceFile */ || node.parent.kind === 258 /* ModuleBlock */ || node.parent.kind === 257 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 300 /* SourceFile */ || node.parent.kind === 260 /* ModuleBlock */ || node.parent.kind === 259 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -79923,8 +81415,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 === 298 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 257 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 300 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 259 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -79937,7 +81429,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { @@ -80048,171 +81540,173 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 257 /* ModuleDeclaration */: - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 252 /* FunctionDeclaration */: + case 259 /* ModuleDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 254 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 233 /* FirstStatement */ && kind <= 249 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 235 /* FirstStatement */ && kind <= 251 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 160 /* TypeParameter */: + case 161 /* TypeParameter */: return checkTypeParameter(node); - case 161 /* Parameter */: + case 162 /* Parameter */: return checkParameter(node); - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return checkPropertyDeclaration(node); - case 163 /* PropertySignature */: + case 164 /* PropertySignature */: return checkPropertySignature(node); - case 176 /* ConstructorType */: - case 175 /* FunctionType */: - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 172 /* IndexSignature */: + case 178 /* ConstructorType */: + case 177 /* FunctionType */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 174 /* IndexSignature */: return checkSignatureDeclaration(node); - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return checkMethodDeclaration(node); - case 167 /* Constructor */: + case 168 /* ClassStaticBlockDeclaration */: + return checkClassStaticBlockDeclaration(node); + case 169 /* Constructor */: return checkConstructorDeclaration(node); - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return checkAccessorDeclaration(node); - case 174 /* TypeReference */: + case 176 /* TypeReference */: return checkTypeReferenceNode(node); - case 173 /* TypePredicate */: + case 175 /* TypePredicate */: return checkTypePredicate(node); - case 177 /* TypeQuery */: + case 179 /* TypeQuery */: return checkTypeQuery(node); - case 178 /* TypeLiteral */: + case 180 /* TypeLiteral */: return checkTypeLiteral(node); - case 179 /* ArrayType */: + case 181 /* ArrayType */: return checkArrayType(node); - case 180 /* TupleType */: + case 182 /* TupleType */: return checkTupleType(node); - case 183 /* UnionType */: - case 184 /* IntersectionType */: + case 185 /* UnionType */: + case 186 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 187 /* ParenthesizedType */: - case 181 /* OptionalType */: - case 182 /* RestType */: + case 189 /* ParenthesizedType */: + case 183 /* OptionalType */: + case 184 /* RestType */: return checkSourceElement(node.type); - case 188 /* ThisType */: + case 190 /* ThisType */: return checkThisType(node); - case 189 /* TypeOperator */: + case 191 /* TypeOperator */: return checkTypeOperator(node); - case 185 /* ConditionalType */: + case 187 /* ConditionalType */: return checkConditionalType(node); - case 186 /* InferType */: + case 188 /* InferType */: return checkInferType(node); - case 194 /* TemplateLiteralType */: + case 196 /* TemplateLiteralType */: return checkTemplateLiteralType(node); - case 196 /* ImportType */: + case 198 /* ImportType */: return checkImportType(node); - case 193 /* NamedTupleMember */: + case 195 /* NamedTupleMember */: return checkNamedTupleMember(node); - case 318 /* JSDocAugmentsTag */: + case 323 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 319 /* JSDocImplementsTag */: + case 324 /* JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 335 /* JSDocTypedefTag */: - case 328 /* JSDocCallbackTag */: - case 329 /* JSDocEnumTag */: + case 340 /* JSDocTypedefTag */: + case 333 /* JSDocCallbackTag */: + case 334 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 334 /* JSDocTemplateTag */: + case 339 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 333 /* JSDocTypeTag */: + case 338 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 330 /* JSDocParameterTag */: + case 335 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 337 /* JSDocPropertyTag */: + case 342 /* JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 309 /* JSDocFunctionType */: + case 312 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 307 /* JSDocNonNullableType */: - case 306 /* JSDocNullableType */: - case 304 /* JSDocAllType */: - case 305 /* JSDocUnknownType */: - case 314 /* JSDocTypeLiteral */: + case 310 /* JSDocNonNullableType */: + case 309 /* JSDocNullableType */: + case 307 /* JSDocAllType */: + case 308 /* JSDocUnknownType */: + case 317 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 310 /* JSDocVariadicType */: + case 313 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 302 /* JSDocTypeExpression */: + case 304 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 190 /* IndexedAccessType */: + case 192 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 191 /* MappedType */: + case 193 /* MappedType */: return checkMappedType(node); - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 231 /* Block */: - case 258 /* ModuleBlock */: + case 233 /* Block */: + case 260 /* ModuleBlock */: return checkBlock(node); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return checkVariableStatement(node); - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: return checkExpressionStatement(node); - case 235 /* IfStatement */: + case 237 /* IfStatement */: return checkIfStatement(node); - case 236 /* DoStatement */: + case 238 /* DoStatement */: return checkDoStatement(node); - case 237 /* WhileStatement */: + case 239 /* WhileStatement */: return checkWhileStatement(node); - case 238 /* ForStatement */: + case 240 /* ForStatement */: return checkForStatement(node); - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: return checkForInStatement(node); - case 240 /* ForOfStatement */: + case 242 /* ForOfStatement */: return checkForOfStatement(node); - case 241 /* ContinueStatement */: - case 242 /* BreakStatement */: + case 243 /* ContinueStatement */: + case 244 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 243 /* ReturnStatement */: + case 245 /* ReturnStatement */: return checkReturnStatement(node); - case 244 /* WithStatement */: + case 246 /* WithStatement */: return checkWithStatement(node); - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: return checkSwitchStatement(node); - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: return checkLabeledStatement(node); - case 247 /* ThrowStatement */: + case 249 /* ThrowStatement */: return checkThrowStatement(node); - case 248 /* TryStatement */: + case 250 /* TryStatement */: return checkTryStatement(node); - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 199 /* BindingElement */: + case 201 /* BindingElement */: return checkBindingElement(node); - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: return checkClassDeclaration(node); - case 254 /* InterfaceDeclaration */: + case 256 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 255 /* TypeAliasDeclaration */: + case 257 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return checkImportDeclaration(node); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: return checkExportDeclaration(node); - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: return checkExportAssignment(node); - case 232 /* EmptyStatement */: - case 249 /* DebuggerStatement */: + case 234 /* EmptyStatement */: + case 251 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 272 /* MissingDeclaration */: + case 274 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -80311,33 +81805,33 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 204 /* CallExpression */: - case 205 /* NewExpression */: - case 206 /* TaggedTemplateExpression */: - case 162 /* Decorator */: - case 276 /* JsxOpeningElement */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: + case 208 /* TaggedTemplateExpression */: + case 163 /* Decorator */: + case 278 /* JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 222 /* ClassExpression */: + case 224 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 275 /* JsxSelfClosingElement */: + case 277 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 274 /* JsxElement */: + case 276 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -80380,6 +81874,7 @@ var ts; ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); ts.clear(potentialWeakMapSetCollisions); + ts.clear(potentialReflectCollisions); ts.forEach(node.statements, checkSourceElement); checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); @@ -80413,6 +81908,10 @@ var ts; ts.forEach(potentialWeakMapSetCollisions, checkWeakMapSetCollision); ts.clear(potentialWeakMapSetCollisions); } + if (potentialReflectCollisions.length) { + ts.forEach(potentialReflectCollisions, checkReflectCollision); + ts.clear(potentialReflectCollisions); + } links.flags |= 1 /* TypeChecked */; } } @@ -80473,7 +81972,7 @@ var ts; return []; } var symbols = ts.createSymbolTable(); - var isStatic = false; + var isStaticSymbol = false; populateSymbols(); symbols.delete("this" /* This */); // Not a symbol, a keyword return symbolsToArray(symbols); @@ -80483,17 +81982,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 298 /* SourceFile */: + case 300 /* SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 222 /* ClassExpression */: + case 224 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -80501,17 +82000,17 @@ var ts; // 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. // falls through - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // 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 (!isStatic) { + if (!isStaticSymbol) { copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 209 /* FunctionExpression */: + case 211 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -80521,7 +82020,7 @@ var ts; if (ts.introducesArgumentsExoticObject(location)) { copySymbol(argumentsSymbol, meaning); } - isStatic = ts.hasSyntacticModifier(location, 32 /* Static */); + isStaticSymbol = ts.isStatic(location); location = location.parent; } copySymbols(globals, meaning); @@ -80555,7 +82054,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 271 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 270 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 273 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 272 /* NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -80563,25 +82062,25 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 78 /* Identifier */ && + return name.kind === 79 /* Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 160 /* TypeParameter */: - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 256 /* EnumDeclaration */: - case 335 /* JSDocTypedefTag */: - case 328 /* JSDocCallbackTag */: - case 329 /* JSDocEnumTag */: + case 161 /* TypeParameter */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 258 /* EnumDeclaration */: + case 340 /* JSDocTypedefTag */: + case 333 /* JSDocCallbackTag */: + case 334 /* JSDocEnumTag */: return true; - case 263 /* ImportClause */: + case 265 /* ImportClause */: return node.isTypeOnly; - case 266 /* ImportSpecifier */: - case 271 /* ExportSpecifier */: + case 268 /* ImportSpecifier */: + case 273 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -80589,25 +82088,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 158 /* QualifiedName */) { + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 174 /* TypeReference */; + return node.parent.kind === 176 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 202 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent.kind === 224 /* ExpressionWithTypeArguments */; - } - function getJSDocEntryNameReference(node) { - while (node.parent.kind === 158 /* QualifiedName */) { - node = node.parent; - } - while (node.parent.kind === 202 /* PropertyAccessExpression */) { + while (node.parent.kind === 204 /* PropertyAccessExpression */) { node = node.parent; } - return ts.isJSDocNameReference(node.parent) ? node.parent : undefined; + return node.parent.kind === 226 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -80635,13 +82125,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 158 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 159 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 261 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 263 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 267 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 269 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -80667,7 +82157,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 196 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 198 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -80677,17 +82167,17 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 202 /* PropertyAccessExpression */ && + name.parent.kind === 204 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment - if (!ts.isPrivateIdentifier(name)) { + if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } } - if (name.parent.kind === 267 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 269 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -80695,13 +82185,13 @@ var ts; return success; } } - else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) { + else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 261 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 263 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } - if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) { + if (ts.isEntityName(name)) { var possibleImportNode = isImportTypeQualifierPart(name); if (possibleImportNode) { getTypeFromTypeNode(possibleImportNode); @@ -80709,13 +82199,13 @@ var ts; return sym === unknownSymbol ? undefined : sym; } } - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(name)) { name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 224 /* ExpressionWithTypeArguments */) { + if (name.parent.kind === 226 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { @@ -80731,10 +82221,10 @@ var ts; return entityNameSymbol; } } - if (name.parent.kind === 330 /* JSDocParameterTag */) { + if (name.parent.kind === 335 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 160 /* TypeParameter */ && name.parent.parent.kind === 334 /* JSDocTemplateTag */) { + if (name.parent.kind === 161 /* TypeParameter */ && name.parent.parent.kind === 339 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -80744,63 +82234,81 @@ var ts; // Missing entity name. return undefined; } - if (name.kind === 78 /* Identifier */) { + var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); + var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */; + if (name.kind === 79 /* Identifier */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(name, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + if (!result && isJSDoc_1) { + var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); + if (container) { + return resolveJSDocMemberName(name, getSymbolOfNode(container)); + } + } + return result; } - else if (name.kind === 202 /* PropertyAccessExpression */ || name.kind === 158 /* QualifiedName */) { + else if (name.kind === 204 /* PropertyAccessExpression */ || name.kind === 159 /* QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 202 /* PropertyAccessExpression */) { + if (name.kind === 204 /* PropertyAccessExpression */) { checkPropertyAccessExpression(name, 0 /* Normal */); } else { checkQualifiedName(name, 0 /* Normal */); } + if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { + return resolveJSDocMemberName(name); + } return links.resolvedSymbol; } + else if (ts.isJSDocMemberName(name)) { + return resolveJSDocMemberName(name); + } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 174 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 176 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - var jsdocReference = getJSDocEntryNameReference(name); - if (jsdocReference || ts.isJSDocLink(name.parent)) { + if (name.parent.kind === 175 /* TypePredicate */) { + return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + } + return undefined; + } + /** + * Recursively resolve entity names and jsdoc instance references: + * 1. K#m as K.prototype.m for a class (or other value) K + * 2. K.m as K.prototype.m + * 3. I.m as I.m for a type I, or any other I.m that fails to resolve in (1) or (2) + * + * For unqualified names, a container K may be provided as a second argument. + */ + function resolveJSDocMemberName(name, container) { + if (ts.isEntityName(name)) { + // resolve static values first var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; - var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ false, ts.getHostSignatureFromJSDoc(name)); + var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); + if (!symbol && ts.isIdentifier(name) && container) { + symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); + } if (symbol) { return symbol; } - else if (ts.isQualifiedName(name) && ts.isIdentifier(name.left)) { - // resolve C.m as a static member first - var links = getNodeLinks(name); - if (links.resolvedSymbol) { - return links.resolvedSymbol; - } - checkQualifiedName(name, 0 /* Normal */); - if (links.resolvedSymbol) { - return links.resolvedSymbol; - } - // then resolve it as an instance member - var s = resolveEntityName(name.left, meaning, /*ignoreErrors*/ false); - if (s) { - var t = getDeclaredTypeOfSymbol(s); - return getPropertyOfType(t, name.right.escapedText); - } - } } - if (name.parent.kind === 173 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); + var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; + if (left) { + var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); + return getPropertyOfType(t, right); } - return undefined; } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 298 /* SourceFile */) { + if (node.kind === 300 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -80819,12 +82327,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 199 /* BindingElement */ && - grandParent.kind === 197 /* ObjectBindingPattern */ && + else if (parent.kind === 201 /* BindingElement */ && + grandParent.kind === 199 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -80832,14 +82340,24 @@ var ts; return propertyDeclaration; } } + else if (ts.isMetaProperty(parent)) { + var parentType = getTypeOfNode(parent); + var propertyDeclaration = getPropertyOfType(parentType, node.escapedText); + if (propertyDeclaration) { + return propertyDeclaration; + } + if (parent.keywordToken === 103 /* NewKeyword */) { + return checkNewTargetMetaProperty(parent).symbol; + } + } } switch (node.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 202 /* PropertyAccessExpression */: - case 158 /* QualifiedName */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 204 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: return getSymbolOfNameOrPropertyAccessExpression(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -80851,14 +82369,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 188 /* ThisType */: + case 190 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkExpression(node).symbol; - case 132 /* ConstructorKeyword */: + case 133 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 167 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 169 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -80869,7 +82387,7 @@ var ts; // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 262 /* ImportDeclaration */ || node.parent.kind === 268 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 264 /* ImportDeclaration */ || node.parent.kind === 270 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -80886,21 +82404,35 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 87 /* DefaultKeyword */: - case 97 /* FunctionKeyword */: + case 88 /* DefaultKeyword */: + case 98 /* FunctionKeyword */: case 38 /* EqualsGreaterThanToken */: - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 196 /* ImportType */: + case 198 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; + case 100 /* ImportKeyword */: + case 103 /* NewKeyword */: + return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined; + case 229 /* MetaProperty */: + return checkExpression(node).symbol; default: return undefined; } } + function getIndexInfosAtLocation(node) { + if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { + var keyType_1 = getLiteralTypeFromPropertyName(node); + var objectType = getTypeOfExpression(node.parent.expression); + var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType]; + return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); }); + } + return undefined; + } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 290 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 292 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -80970,6 +82502,9 @@ var ts; return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol); } } + if (ts.isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) { + return checkMetaPropertyKeyword(node.parent); + } return errorType; } // Gets the type of object literal or array literal of destructuring assignment. @@ -80979,23 +82514,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 201 /* ObjectLiteralExpression */ || expr.kind === 200 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 203 /* ObjectLiteralExpression */ || expr.kind === 202 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 240 /* ForOfStatement */) { + if (expr.parent.kind === 242 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 217 /* BinaryExpression */) { + if (expr.parent.kind === 219 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 289 /* PropertyAssignment */) { + if (expr.parent.kind === 291 /* PropertyAssignment */) { var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); @@ -81031,19 +82566,19 @@ var ts; */ function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return ts.hasSyntacticModifier(node, 32 /* Static */) + return ts.isStatic(node) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 78 /* Identifier */: - return getLiteralType(ts.idText(name)); + case 79 /* Identifier */: + return getStringLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: - return getLiteralType(name.text); - case 159 /* ComputedPropertyName */: + return getStringLiteralType(name.text); + case 160 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -81161,7 +82696,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 298 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 300 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -81193,7 +82728,7 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 288 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 290 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -81224,7 +82759,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 231 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 233 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -81265,20 +82800,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 263 /* ImportClause */: - case 264 /* NamespaceImport */: - case 266 /* ImportSpecifier */: - case 271 /* ExportSpecifier */: + case 265 /* ImportClause */: + case 266 /* NamespaceImport */: + case 268 /* ImportSpecifier */: + case 273 /* ExportSpecifier */: var symbol = getSymbolOfNode(node) || unknownSymbol; return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 267 /* ExportAssignment */: - return node.expression && node.expression.kind === 78 /* Identifier */ ? + case 269 /* ExportAssignment */: + return node.expression && node.expression.kind === 79 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -81286,7 +82821,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 298 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 300 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -81386,7 +82921,11 @@ var ts; return symbol && getPropertiesOfType(getTypeOfSymbol(symbol)) || ts.emptyArray; } function getNodeCheckFlags(node) { - return getNodeLinks(node).flags || 0; + var _a; + var nodeId = node.id || 0; + if (nodeId < 0 || nodeId >= nodeLinks.length) + return 0; + return ((_a = nodeLinks[nodeId]) === null || _a === void 0 ? void 0 : _a.flags) || 0; } function getEnumMemberValue(node) { computeEnumMemberValues(node.parent); @@ -81394,15 +82933,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 292 /* EnumMember */: - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 294 /* EnumMember */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 292 /* EnumMember */) { + if (node.kind === 294 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -81419,7 +82958,7 @@ var ts; return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { - var _a; + var _a, _b; // ensure both `typeName` and `location` are parse tree nodes. var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName); if (!typeName) @@ -81430,9 +82969,14 @@ var ts; return ts.TypeReferenceSerializationKind.Unknown; } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. + var isTypeOnly = false; + if (ts.isQualifiedName(typeName)) { + var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)); + } var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); - var isTypeOnly = ((_a = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)) || false; var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol; + isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration))); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (resolvedSymbol && resolvedSymbol === typeSymbol) { @@ -81490,7 +83034,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -81509,7 +83053,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -81517,7 +83061,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -81674,12 +83218,12 @@ var ts; getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 169 /* SetAccessor */ ? 168 /* GetAccessor */ : 169 /* SetAccessor */; + var otherKind = accessor.kind === 171 /* SetAccessor */ ? 170 /* GetAccessor */ : 171 /* SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 169 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 168 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 171 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 170 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -81695,7 +83239,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 298 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 300 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -81732,7 +83276,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 224 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 287 /* HeritageClause */; + return node.parent && node.parent.kind === 226 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 289 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -81744,7 +83288,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 78 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 202 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 204 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -81792,7 +83336,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 298 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 300 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -81820,12 +83364,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 257 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 259 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 298 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 300 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -81911,7 +83455,7 @@ var ts; autoArrayType = createArrayType(autoType); if (autoArrayType === emptyObjectType) { // autoArrayType is used as a marker, so even if global Array type is not defined, it needs to be a unique type - autoArrayType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + autoArrayType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); } globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", /*arity*/ 1) || globalArrayType; anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; @@ -81979,6 +83523,11 @@ var ts; error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); } } + else if (helper & 1024 /* SpreadArray */) { + if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) { + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3); + } + } } } } @@ -82028,14 +83577,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 166 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 167 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 168 /* GetAccessor */ || node.kind === 169 /* SetAccessor */) { + else if (node.kind === 170 /* GetAccessor */ || node.kind === 171 /* 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); @@ -82052,21 +83601,21 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 142 /* ReadonlyKeyword */) { - if (node.kind === 163 /* PropertySignature */ || node.kind === 165 /* MethodSignature */) { + if (modifier.kind !== 143 /* ReadonlyKeyword */) { + if (node.kind === 164 /* PropertySignature */ || node.kind === 166 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 172 /* IndexSignature */ && (modifier.kind !== 123 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 174 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 84 /* ConstKeyword */: - if (node.kind !== 256 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84 /* ConstKeyword */)); + case 85 /* ConstKeyword */: + if (node.kind !== 258 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); } break; - case 156 /* OverrideKeyword */: + case 157 /* OverrideKeyword */: // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. if (flags & 16384 /* Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); @@ -82083,9 +83632,9 @@ var ts; flags |= 16384 /* Override */; lastOverride = modifier; break; - case 122 /* PublicKeyword */: - case 121 /* ProtectedKeyword */: - case 120 /* PrivateKeyword */: + case 123 /* PublicKeyword */: + case 122 /* ProtectedKeyword */: + case 121 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -82102,11 +83651,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 258 /* ModuleBlock */ || node.parent.kind === 298 /* SourceFile */) { + else if (node.parent.kind === 260 /* ModuleBlock */ || node.parent.kind === 300 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { - if (modifier.kind === 120 /* PrivateKeyword */) { + if (modifier.kind === 121 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -82118,7 +83667,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -82128,10 +83677,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 258 /* ModuleBlock */ || node.parent.kind === 298 /* SourceFile */) { + else if (node.parent.kind === 260 /* ModuleBlock */ || node.parent.kind === 300 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 161 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -82143,18 +83692,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 164 /* PropertyDeclaration */ && node.kind !== 163 /* PropertySignature */ && node.kind !== 172 /* IndexSignature */ && node.kind !== 161 /* Parameter */) { + else if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */ && node.kind !== 174 /* IndexSignature */ && node.kind !== 162 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -82170,19 +83719,22 @@ var ts; else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 161 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 87 /* DefaultKeyword */: - var container = node.parent.kind === 298 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 257 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* DefaultKeyword */: + var container = node.parent.kind === 300 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 259 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } + else if (!(flags & 1 /* Export */)) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); + } flags |= 512 /* Default */; break; - case 133 /* DeclareKeyword */: + case 134 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } @@ -82195,10 +83747,10 @@ var ts; else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 161 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 258 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 260 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { @@ -82207,19 +83759,19 @@ var ts; flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 125 /* AbstractKeyword */: + case 126 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 253 /* ClassDeclaration */ && - node.kind !== 176 /* ConstructorType */) { - if (node.kind !== 166 /* MethodDeclaration */ && - node.kind !== 164 /* PropertyDeclaration */ && - node.kind !== 168 /* GetAccessor */ && - node.kind !== 169 /* SetAccessor */) { + if (node.kind !== 255 /* ClassDeclaration */ && + node.kind !== 178 /* ConstructorType */) { + if (node.kind !== 167 /* MethodDeclaration */ && + node.kind !== 165 /* PropertyDeclaration */ && + node.kind !== 170 /* GetAccessor */ && + node.kind !== 171 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 253 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 255 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -82235,19 +83787,19 @@ var ts; return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } } - if (ts.isNamedDeclaration(node) && node.name.kind === 79 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } flags |= 128 /* Abstract */; break; - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 161 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } if (flags & 128 /* Abstract */) { @@ -82258,7 +83810,7 @@ var ts; break; } } - if (node.kind === 167 /* Constructor */) { + if (node.kind === 169 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -82276,13 +83828,13 @@ var ts; } return false; } - else if ((node.kind === 262 /* ImportDeclaration */ || node.kind === 261 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 264 /* ImportDeclaration */ || node.kind === 263 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 161 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 161 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -82303,39 +83855,40 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 167 /* Constructor */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 172 /* IndexSignature */: - case 257 /* ModuleDeclaration */: - case 262 /* ImportDeclaration */: - case 261 /* ImportEqualsDeclaration */: - case 268 /* ExportDeclaration */: - case 267 /* ExportAssignment */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 161 /* Parameter */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 169 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 174 /* IndexSignature */: + case 259 /* ModuleDeclaration */: + case 264 /* ImportDeclaration */: + case 263 /* ImportEqualsDeclaration */: + case 270 /* ExportDeclaration */: + case 269 /* ExportAssignment */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 162 /* Parameter */: return false; default: - if (node.parent.kind === 258 /* ModuleBlock */ || node.parent.kind === 298 /* SourceFile */) { + if (node.parent.kind === 260 /* ModuleBlock */ || node.parent.kind === 300 /* SourceFile */) { return false; } switch (node.kind) { - case 252 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 129 /* AsyncKeyword */); - case 253 /* ClassDeclaration */: - case 176 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 125 /* AbstractKeyword */); - case 254 /* InterfaceDeclaration */: - case 233 /* VariableStatement */: - case 255 /* TypeAliasDeclaration */: + case 254 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 130 /* AsyncKeyword */); + case 255 /* ClassDeclaration */: + case 178 /* ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); + case 256 /* InterfaceDeclaration */: + case 235 /* VariableStatement */: + case 257 /* TypeAliasDeclaration */: + case 168 /* ClassStaticBlockDeclaration */: return true; - case 256 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 84 /* ConstKeyword */); + case 258 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); default: ts.Debug.fail(); } @@ -82346,10 +83899,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 166 /* MethodDeclaration */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -82412,7 +83965,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_2 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, __spreadArray([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_2)); + ts.addRelatedInfo.apply(void 0, __spreadArray([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_2, false)); return true; } } @@ -82468,15 +84021,12 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 147 /* StringKeyword */ && parameter.type.kind !== 144 /* NumberKeyword */) { - var type = getTypeFromTypeNode(parameter.type); - if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); - } - if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true)) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); - } - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number); + var type = getTypeFromTypeNode(parameter.type); + if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead); + } + if (!everyType(type, isValidIndexKeyType)) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); @@ -82510,7 +84060,7 @@ var ts; if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 223 /* OmittedExpression */) { + if (arg.kind === 225 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -82540,7 +84090,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -82553,7 +84103,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -82569,14 +84119,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -82587,20 +84137,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 159 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 217 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 219 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 252 /* FunctionDeclaration */ || - node.kind === 209 /* FunctionExpression */ || - node.kind === 166 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 254 /* FunctionDeclaration */ || + node.kind === 211 /* FunctionExpression */ || + node.kind === 167 /* MethodDeclaration */); if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -82619,7 +84169,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 291 /* SpreadAssignment */) { + if (prop.kind === 293 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -82630,16 +84180,16 @@ var ts; continue; } var name = prop.name; - if (name.kind === 159 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 290 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 292 /* 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.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } - if (name.kind === 79 /* PrivateIdentifier */) { + if (name.kind === 80 /* PrivateIdentifier */) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration @@ -82647,7 +84197,7 @@ var ts; // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 129 /* AsyncKeyword */ || prop.kind !== 166 /* MethodDeclaration */) { + if (mod.kind !== 130 /* AsyncKeyword */ || prop.kind !== 167 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -82662,10 +84212,10 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -82673,13 +84223,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 168 /* GetAccessor */: + case 170 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 169 /* SetAccessor */: + case 171 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -82719,7 +84269,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 283 /* JsxSpreadAttribute */) { + if (attr.kind === 285 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -82729,7 +84279,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 284 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 286 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -82764,7 +84314,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 240 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 242 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { @@ -82782,7 +84332,7 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 167 /* Constructor */) { + if (func && func.kind !== 169 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -82794,7 +84344,12 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 251 /* VariableDeclarationList */) { + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) && + ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") { + grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async); + return false; + } + if (forInOrOfStatement.initializer.kind === 253 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -82809,20 +84364,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 239 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 241 /* 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 239 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 241 /* 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 === 239 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 241 /* 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); @@ -82832,7 +84387,7 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 178 /* TypeLiteral */) && (accessor.parent.kind !== 254 /* InterfaceDeclaration */)) { + if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 180 /* TypeLiteral */) && (accessor.parent.kind !== 256 /* InterfaceDeclaration */)) { if (languageVersion < 1 /* ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } @@ -82847,7 +84402,7 @@ var ts; if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - if (accessor.parent.kind === 178 /* TypeLiteral */ || accessor.parent.kind === 254 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 180 /* TypeLiteral */ || accessor.parent.kind === 256 /* InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -82855,11 +84410,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 168 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 170 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 169 /* SetAccessor */) { + if (accessor.kind === 171 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -82881,17 +84436,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 168 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 170 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 168 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 170 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 151 /* UniqueKeyword */) { - if (node.type.kind !== 148 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(148 /* SymbolKeyword */)); + if (node.operator === 152 /* UniqueKeyword */) { + if (node.type.kind !== 149 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(149 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -82902,9 +84457,9 @@ var ts; } } switch (parent.kind) { - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 78 /* Identifier */) { + if (decl.name.kind !== 79 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { @@ -82914,13 +84469,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 164 /* PropertyDeclaration */: - if (!ts.hasSyntacticModifier(parent, 32 /* Static */) || - !ts.hasEffectiveModifier(parent, 64 /* Readonly */)) { + case 165 /* PropertyDeclaration */: + if (!ts.isStatic(parent) || + !ts.hasEffectiveReadonlyModifier(parent)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 163 /* PropertySignature */: + case 164 /* PropertySignature */: if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } @@ -82929,9 +84484,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 142 /* ReadonlyKeyword */) { - if (node.type.kind !== 179 /* ArrayType */ && node.type.kind !== 180 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148 /* SymbolKeyword */)); + else if (node.operator === 143 /* ReadonlyKeyword */) { + if (node.type.kind !== 181 /* ArrayType */ && node.type.kind !== 182 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(149 /* SymbolKeyword */)); } } } @@ -82944,10 +84499,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 166 /* MethodDeclaration */) { - if (node.parent.kind === 201 /* ObjectLiteralExpression */) { + if (node.kind === 167 /* MethodDeclaration */) { + if (node.parent.kind === 203 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 129 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 130 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -82976,29 +84531,29 @@ var ts; if (node.flags & 8388608 /* Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 166 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 167 /* MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 254 /* InterfaceDeclaration */) { + else if (node.parent.kind === 256 /* InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 178 /* TypeLiteral */) { + else if (node.parent.kind === 180 /* TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } function checkGrammarBreakOrContinueStatement(node) { var current = node; while (current) { - if (ts.isFunctionLike(current)) { + if (ts.isFunctionLikeOrClassStaticBlockDeclaration(current)) { return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 241 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 243 /* ContinueStatement */ && !ts.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); @@ -83006,8 +84561,8 @@ var ts; return false; } break; - case 245 /* SwitchStatement */: - if (node.kind === 242 /* BreakStatement */ && !node.label) { + case 247 /* SwitchStatement */: + if (node.kind === 244 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -83022,13 +84577,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 242 /* BreakStatement */ + var message = node.kind === 244 /* 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 === 242 /* BreakStatement */ + var message = node.kind === 244 /* 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); @@ -83052,12 +84607,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 215 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 217 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 215 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 217 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -83071,7 +84626,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 109 /* TrueKeyword */ || initializer.kind === 94 /* FalseKeyword */ || + initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -83088,7 +84643,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 239 /* ForInStatement */ && node.parent.parent.kind !== 240 /* ForOfStatement */) { + if (node.parent.parent.kind !== 241 /* ForInStatement */ && node.parent.parent.kind !== 242 /* ForOfStatement */) { if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } @@ -83101,7 +84656,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 233 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 235 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -83124,7 +84679,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -83141,8 +84696,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 78 /* Identifier */) { - if (name.originalKeywordKind === 118 /* LetKeyword */) { + if (name.kind === 79 /* Identifier */) { + if (name.originalKeywordKind === 119 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -83169,15 +84724,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 235 /* IfStatement */: - case 236 /* DoStatement */: - case 237 /* WhileStatement */: - case 244 /* WithStatement */: - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: + case 237 /* IfStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: + case 246 /* WithStatement */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: return false; - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -83195,12 +84750,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -83269,7 +84824,7 @@ var ts; return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 254 /* InterfaceDeclaration */) { + else if (node.parent.kind === 256 /* InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -83277,7 +84832,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 178 /* TypeLiteral */) { + else if (node.parent.kind === 180 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -83289,7 +84844,7 @@ var ts; checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 8388608 /* Ambient */ || ts.hasSyntacticModifier(node, 32 /* Static */ | 128 /* Abstract */))) { + node.flags & 8388608 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -83311,13 +84866,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 254 /* InterfaceDeclaration */ || - node.kind === 255 /* TypeAliasDeclaration */ || - node.kind === 262 /* ImportDeclaration */ || - node.kind === 261 /* ImportEqualsDeclaration */ || - node.kind === 268 /* ExportDeclaration */ || - node.kind === 267 /* ExportAssignment */ || - node.kind === 260 /* NamespaceExportDeclaration */ || + if (node.kind === 256 /* InterfaceDeclaration */ || + node.kind === 257 /* TypeAliasDeclaration */ || + node.kind === 264 /* ImportDeclaration */ || + node.kind === 263 /* ImportEqualsDeclaration */ || + node.kind === 270 /* ExportDeclaration */ || + node.kind === 269 /* ExportAssignment */ || + node.kind === 262 /* NamespaceExportDeclaration */ || ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -83326,7 +84881,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 === 233 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 235 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -83349,7 +84904,7 @@ var ts; // to prevent noisiness. 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 === 231 /* Block */ || node.parent.kind === 258 /* ModuleBlock */ || node.parent.kind === 298 /* SourceFile */) { + if (node.parent.kind === 233 /* Block */ || node.parent.kind === 260 /* ModuleBlock */ || node.parent.kind === 300 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -83371,10 +84926,10 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 192 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 194 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 292 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 294 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -83553,14 +85108,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 252 /* FunctionDeclaration */ && declaration.kind !== 166 /* MethodDeclaration */) || + return (declaration.kind !== 254 /* FunctionDeclaration */ && declaration.kind !== 167 /* MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 266 /* ImportSpecifier */: - case 271 /* ExportSpecifier */: + case 268 /* ImportSpecifier */: + case 273 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -83810,432 +85365,437 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 157 /* LastToken */) || kind === 188 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 158 /* LastToken */) || kind === 190 /* ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 78 /* Identifier */: + case 79 /* Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 160 /* TypeParameter */: + case 161 /* TypeParameter */: ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 161 /* Parameter */: + case 162 /* Parameter */: ts.Debug.type(node); return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 162 /* Decorator */: + case 163 /* Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 163 /* PropertySignature */: + case 164 /* PropertySignature */: ts.Debug.type(node); return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 165 /* MethodSignature */: + case 166 /* MethodSignature */: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: ts.Debug.type(node); return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 167 /* Constructor */: + case 169 /* Constructor */: ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 168 /* GetAccessor */: + case 170 /* GetAccessor */: ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 169 /* SetAccessor */: + case 171 /* SetAccessor */: ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 170 /* CallSignature */: + case 168 /* ClassStaticBlockDeclaration */: + ts.Debug.type(node); + context.startLexicalEnvironment(); + context.suspendLexicalEnvironment(); + return factory.updateClassStaticBlockDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + case 172 /* CallSignature */: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 171 /* ConstructSignature */: + case 173 /* ConstructSignature */: ts.Debug.type(node); return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 172 /* IndexSignature */: + case 174 /* IndexSignature */: ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 173 /* TypePredicate */: + case 175 /* TypePredicate */: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 174 /* TypeReference */: + case 176 /* TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 175 /* FunctionType */: + case 177 /* FunctionType */: ts.Debug.type(node); return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 176 /* ConstructorType */: + case 178 /* ConstructorType */: ts.Debug.type(node); return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 177 /* TypeQuery */: + case 179 /* TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName)); - case 178 /* TypeLiteral */: + case 180 /* TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 179 /* ArrayType */: + case 181 /* ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 180 /* TupleType */: + case 182 /* TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 181 /* OptionalType */: + case 183 /* OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 182 /* RestType */: + case 184 /* RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 183 /* UnionType */: + case 185 /* UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 184 /* IntersectionType */: + case 186 /* IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 185 /* ConditionalType */: + case 187 /* ConditionalType */: ts.Debug.type(node); return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 186 /* InferType */: + case 188 /* InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 196 /* ImportType */: + case 198 /* ImportType */: ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 193 /* NamedTupleMember */: + case 195 /* NamedTupleMember */: ts.Debug.type(node); return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 187 /* ParenthesizedType */: + case 189 /* ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 189 /* TypeOperator */: + case 191 /* TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 190 /* IndexedAccessType */: + case 192 /* IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 191 /* MappedType */: + case 193 /* MappedType */: ts.Debug.type(node); return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 192 /* LiteralType */: + case 194 /* LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 194 /* TemplateLiteralType */: + case 196 /* TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 195 /* TemplateLiteralTypeSpan */: + case 197 /* TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 197 /* ObjectBindingPattern */: + case 199 /* ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 198 /* ArrayBindingPattern */: + case 200 /* ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 199 /* BindingElement */: + case 201 /* BindingElement */: ts.Debug.type(node); return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: if (node.flags & 32 /* OptionalChain */) { ts.Debug.type(node); return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName)); } ts.Debug.type(node); return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: if (node.flags & 32 /* OptionalChain */) { ts.Debug.type(node); return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 204 /* CallExpression */: + case 206 /* CallExpression */: if (node.flags & 32 /* OptionalChain */) { ts.Debug.type(node); return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 205 /* NewExpression */: + case 207 /* NewExpression */: ts.Debug.type(node); return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: ts.Debug.type(node); return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 207 /* TypeAssertionExpression */: + case 209 /* TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 209 /* FunctionExpression */: + case 211 /* FunctionExpression */: ts.Debug.type(node); return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: ts.Debug.type(node); return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 211 /* DeleteExpression */: + case 213 /* DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* TypeOfExpression */: + case 214 /* TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* VoidExpression */: + case 215 /* VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 214 /* AwaitExpression */: + case 216 /* AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 216 /* PostfixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: ts.Debug.type(node); return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: ts.Debug.type(node); return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 219 /* TemplateExpression */: + case 221 /* TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 220 /* YieldExpression */: + case 222 /* YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 221 /* SpreadElement */: + case 223 /* SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 222 /* ClassExpression */: + case 224 /* ClassExpression */: ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 225 /* AsExpression */: + case 227 /* AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 226 /* NonNullExpression */: + case 228 /* NonNullExpression */: if (node.flags & 32 /* OptionalChain */) { ts.Debug.type(node); return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 227 /* MetaProperty */: + case 229 /* MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 229 /* TemplateSpan */: + case 231 /* TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 231 /* Block */: + case 233 /* Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 235 /* IfStatement */: + case 237 /* IfStatement */: ts.Debug.type(node); return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 236 /* DoStatement */: + case 238 /* DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 237 /* WhileStatement */: + case 239 /* WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 238 /* ForStatement */: + case 240 /* ForStatement */: ts.Debug.type(node); return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: ts.Debug.type(node); return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 240 /* ForOfStatement */: + case 242 /* ForOfStatement */: ts.Debug.type(node); return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 241 /* ContinueStatement */: + case 243 /* ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 242 /* BreakStatement */: + case 244 /* BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 243 /* ReturnStatement */: + case 245 /* ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 244 /* WithStatement */: + case 246 /* WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 247 /* ThrowStatement */: + case 249 /* ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 248 /* TryStatement */: + case 250 /* TryStatement */: ts.Debug.type(node); return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: ts.Debug.type(node); return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 251 /* VariableDeclarationList */: + case 253 /* VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: ts.Debug.type(node); return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 254 /* InterfaceDeclaration */: + case 256 /* InterfaceDeclaration */: ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 255 /* TypeAliasDeclaration */: + case 257 /* TypeAliasDeclaration */: ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: ts.Debug.type(node); return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 258 /* ModuleBlock */: + case 260 /* ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 259 /* CaseBlock */: + case 261 /* CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 260 /* NamespaceExportDeclaration */: + case 262 /* NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 263 /* ImportClause */: + case 265 /* ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 270 /* NamespaceExport */: + case 272 /* NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 265 /* NamedImports */: + case 267 /* NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 266 /* ImportSpecifier */: + case 268 /* ImportSpecifier */: ts.Debug.type(node); return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 269 /* NamedExports */: + case 271 /* NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 271 /* ExportSpecifier */: + case 273 /* ExportSpecifier */: ts.Debug.type(node); return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 273 /* ExternalModuleReference */: + case 275 /* ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 274 /* JsxElement */: + case 276 /* JsxElement */: ts.Debug.type(node); return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 275 /* JsxSelfClosingElement */: + case 277 /* JsxSelfClosingElement */: ts.Debug.type(node); return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 276 /* JsxOpeningElement */: + case 278 /* JsxOpeningElement */: ts.Debug.type(node); return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 277 /* JsxClosingElement */: + case 279 /* JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 278 /* JsxFragment */: + case 280 /* JsxFragment */: ts.Debug.type(node); return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 281 /* JsxAttribute */: + case 283 /* JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 282 /* JsxAttributes */: + case 284 /* JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 283 /* JsxSpreadAttribute */: + case 285 /* JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 284 /* JsxExpression */: + case 286 /* JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 285 /* CaseClause */: + case 287 /* CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 286 /* DefaultClause */: + case 288 /* DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 287 /* HeritageClause */: + case 289 /* HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 288 /* CatchClause */: + case 290 /* CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 291 /* SpreadAssignment */: + case 293 /* SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 292 /* EnumMember */: + case 294 /* EnumMember */: ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 298 /* SourceFile */: + case 300 /* SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 340 /* PartiallyEmittedExpression */: + case 345 /* PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 341 /* CommaListExpression */: + case 346 /* CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -84268,6 +85828,7 @@ var ts; var sourcesContent; var names = []; var nameToNameIndexMap; + var mappingCharCodes = []; var mappings = ""; // Last recorded and encoded mappings var lastGeneratedLine = 0; @@ -84442,6 +86003,14 @@ var ts; || lastSourceCharacter !== pendingSourceCharacter || lastNameIndex !== pendingNameIndex; } + function appendMappingCharCode(charCode) { + mappingCharCodes.push(charCode); + // String.fromCharCode accepts its arguments on the stack, so we have to chunk the input, + // otherwise we can get stack overflows for large source maps + if (mappingCharCodes.length >= 1024) { + flushMappingBuffer(); + } + } function commitPendingMapping() { if (!hasPending || !shouldCommitMapping()) { return; @@ -84451,42 +86020,50 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - mappings += ";"; + appendMappingCharCode(59 /* semicolon */); lastGeneratedLine++; - lastGeneratedCharacter = 0; } while (lastGeneratedLine < pendingGeneratedLine); + // Only need to set this once + lastGeneratedCharacter = 0; } else { ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - mappings += ","; + appendMappingCharCode(44 /* comma */); } } // 1. Relative generated character - mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + appendBase64VLQ(pendingGeneratedCharacter - lastGeneratedCharacter); lastGeneratedCharacter = pendingGeneratedCharacter; if (hasPendingSource) { // 2. Relative sourceIndex - mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + appendBase64VLQ(pendingSourceIndex - lastSourceIndex); lastSourceIndex = pendingSourceIndex; // 3. Relative source line - mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + appendBase64VLQ(pendingSourceLine - lastSourceLine); lastSourceLine = pendingSourceLine; // 4. Relative source character - mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + appendBase64VLQ(pendingSourceCharacter - lastSourceCharacter); lastSourceCharacter = pendingSourceCharacter; if (hasPendingName) { // 5. Relative nameIndex - mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + appendBase64VLQ(pendingNameIndex - lastNameIndex); lastNameIndex = pendingNameIndex; } } hasLast = true; exit(); } + function flushMappingBuffer() { + if (mappingCharCodes.length > 0) { + mappings += String.fromCharCode.apply(undefined, mappingCharCodes); + mappingCharCodes.length = 0; + } + } function toJSON() { commitPendingMapping(); + flushMappingBuffer(); return { version: 3, file: file, @@ -84497,10 +86074,33 @@ var ts; sourcesContent: sourcesContent, }; } + function appendBase64VLQ(inValue) { + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + appendMappingCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + } } ts.createSourceMapGenerator = createSourceMapGenerator; // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; function getLineInfo(text, lineStarts) { return { @@ -84517,7 +86117,7 @@ var ts; var line = lineInfo.getLineText(index); var comment = sourceMapCommentRegExp.exec(line); if (comment) { - return comment[1]; + return ts.trimStringEnd(comment[1]); } // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file else if (!line.match(whitespaceOrMapCommentRegExp)) { @@ -84723,31 +86323,6 @@ var ts; ch === 47 /* slash */ ? 63 : -1; } - function base64VLQFormatEncode(inValue) { - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); - } while (inValue > 0); - return encodedStr; - } function isSourceMappedPosition(value) { return value.sourceIndex !== undefined && value.sourcePosition !== undefined; @@ -84911,7 +86486,7 @@ var ts; function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 298 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 300 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -84962,7 +86537,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -84975,13 +86550,13 @@ var ts; hasImportDefault = true; } break; - case 261 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 273 /* ExternalModuleReference */) { + case 263 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 275 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -85012,13 +86587,13 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -85026,7 +86601,7 @@ var ts; } } break; - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default function() { } @@ -85046,7 +86621,7 @@ var ts; } } break; - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default class { } @@ -85144,27 +86719,27 @@ var ts; } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 63 /* FirstCompoundAssignment */ - && kind <= 77 /* LastCompoundAssignment */; + return kind >= 64 /* FirstCompoundAssignment */ + && kind <= 78 /* LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 73 /* BarEqualsToken */: return 51 /* BarToken */; - case 77 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 74 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 75 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 76 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + case 64 /* PlusEqualsToken */: return 39 /* PlusToken */; + case 65 /* MinusEqualsToken */: return 40 /* MinusToken */; + case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; + case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; + case 68 /* SlashEqualsToken */: return 43 /* SlashToken */; + case 69 /* PercentEqualsToken */: return 44 /* PercentToken */; + case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; + case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; + case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; + case 74 /* BarEqualsToken */: return 51 /* BarToken */; + case 78 /* CaretEqualsToken */: return 52 /* CaretToken */; + case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */; + case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; + case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -85201,6 +86776,13 @@ var ts; return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } ts.getProperties = getProperties; + function isStaticPropertyDeclarationOrClassStaticBlockDeclaration(element) { + return isStaticPropertyDeclaration(element) || ts.isClassStaticBlockDeclaration(element); + } + function getStaticPropertiesAndClassStaticBlock(node) { + return ts.filter(node.members, isStaticPropertyDeclarationOrClassStaticBlockDeclaration); + } + ts.getStaticPropertiesAndClassStaticBlock = getStaticPropertiesAndClassStaticBlock; /** * Is a class element either a static or an instance property declaration with an initializer? * @@ -85212,6 +86794,9 @@ var ts; && (!!member.initializer || !requireInitializer) && ts.hasStaticModifier(member) === isStatic; } + function isStaticPropertyDeclaration(member) { + return ts.isPropertyDeclaration(member) && ts.hasStaticModifier(member); + } /** * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. * @@ -85219,7 +86804,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 164 /* PropertyDeclaration */ + return member.kind === 165 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -85229,7 +86814,7 @@ var ts; * @param member The class element node. */ function isNonStaticMethodOrAccessorWithPrivateName(member) { - return !ts.hasStaticModifier(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name); + return !ts.isStatic(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name); } ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName; })(ts || (ts = {})); @@ -85769,6 +87354,7 @@ var ts; // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". var text = node.rawText; if (text === undefined) { + ts.Debug.assertIsDefined(currentSourceFile, "Template literal node is missing 'rawText' and does not have a source file. Possibly bad transform."); text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), // thus we need to remove those characters. @@ -85830,8 +87416,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(202 /* PropertyAccessExpression */); - context.enableSubstitution(203 /* ElementAccessExpression */); + context.enableSubstitution(204 /* PropertyAccessExpression */); + context.enableSubstitution(205 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -85857,14 +87443,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 299 /* Bundle */) { + if (node.kind === 301 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 301 /* InputFiles */) { + if (prepend.kind === 303 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -85915,16 +87501,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 298 /* SourceFile */: - case 259 /* CaseBlock */: - case 258 /* ModuleBlock */: - case 231 /* Block */: + case 300 /* SourceFile */: + case 261 /* CaseBlock */: + case 260 /* ModuleBlock */: + case 233 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 253 /* ClassDeclaration */: - case 252 /* FunctionDeclaration */: + case 255 /* ClassDeclaration */: + case 254 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { break; } @@ -85936,7 +87522,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 253 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 255 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -85979,10 +87565,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 262 /* ImportDeclaration */: - case 261 /* ImportEqualsDeclaration */: - case 267 /* ExportAssignment */: - case 268 /* ExportDeclaration */: + case 264 /* ImportDeclaration */: + case 263 /* ImportEqualsDeclaration */: + case 269 /* ExportAssignment */: + case 270 /* ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -86003,13 +87589,13 @@ var ts; return node; } switch (node.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return visitImportDeclaration(node); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: return visitExportAssignment(node); - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -86029,11 +87615,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 268 /* ExportDeclaration */ || - node.kind === 262 /* ImportDeclaration */ || - node.kind === 263 /* ImportClause */ || - (node.kind === 261 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 273 /* ExternalModuleReference */)) { + if (node.kind === 270 /* ExportDeclaration */ || + node.kind === 264 /* ImportDeclaration */ || + node.kind === 265 /* ImportClause */ || + (node.kind === 263 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 275 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -86057,19 +87643,20 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 167 /* Constructor */: + case 169 /* Constructor */: return visitConstructor(node); - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 172 /* IndexSignature */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 166 /* MethodDeclaration */: + case 174 /* IndexSignature */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 168 /* ClassStaticBlockDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 230 /* SemicolonClassElement */: + case 232 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -86079,7 +87666,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 18654 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 92 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { return undefined; } return node; @@ -86096,71 +87683,72 @@ var ts; return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 125 /* AbstractKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 126 /* AbstractKeyword */: + case 157 /* OverrideKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 143 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 179 /* ArrayType */: - case 180 /* TupleType */: - case 181 /* OptionalType */: - case 182 /* RestType */: - case 178 /* TypeLiteral */: - case 173 /* TypePredicate */: - case 160 /* TypeParameter */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 131 /* BooleanKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 141 /* NeverKeyword */: - case 113 /* VoidKeyword */: - case 148 /* SymbolKeyword */: - case 176 /* ConstructorType */: - case 175 /* FunctionType */: - case 177 /* TypeQuery */: - case 174 /* TypeReference */: - case 183 /* UnionType */: - case 184 /* IntersectionType */: - case 185 /* ConditionalType */: - case 187 /* ParenthesizedType */: - case 188 /* ThisType */: - case 189 /* TypeOperator */: - case 190 /* IndexedAccessType */: - case 191 /* MappedType */: - case 192 /* LiteralType */: + case 181 /* ArrayType */: + case 182 /* TupleType */: + case 183 /* OptionalType */: + case 184 /* RestType */: + case 180 /* TypeLiteral */: + case 175 /* TypePredicate */: + case 161 /* TypeParameter */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 132 /* BooleanKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 142 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 149 /* SymbolKeyword */: + case 178 /* ConstructorType */: + case 177 /* FunctionType */: + case 179 /* TypeQuery */: + case 176 /* TypeReference */: + case 185 /* UnionType */: + case 186 /* IntersectionType */: + case 187 /* ConditionalType */: + case 189 /* ParenthesizedType */: + case 190 /* ThisType */: + case 191 /* TypeOperator */: + case 192 /* IndexedAccessType */: + case 193 /* MappedType */: + case 194 /* LiteralType */: // TypeScript type nodes are elided. // falls through - case 172 /* IndexSignature */: + case 174 /* IndexSignature */: // TypeScript index signatures are elided. // falls through - case 162 /* Decorator */: - // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - // falls through - case 255 /* TypeAliasDeclaration */: - // TypeScript type-only declarations are elided. + case 163 /* Decorator */: + // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. return undefined; - case 164 /* PropertyDeclaration */: + case 257 /* TypeAliasDeclaration */: + // TypeScript type-only declarations are elided. + return factory.createNotEmittedStatement(node); + case 165 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 260 /* NamespaceExportDeclaration */: + case 262 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 167 /* Constructor */: + case 169 /* Constructor */: return visitConstructor(node); - case 254 /* InterfaceDeclaration */: + case 256 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -86170,7 +87758,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 222 /* ClassExpression */: + case 224 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -86180,35 +87768,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 287 /* HeritageClause */: + case 289 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 168 /* GetAccessor */: + case 170 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 169 /* SetAccessor */: + case 171 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 209 /* FunctionExpression */: + case 211 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 161 /* Parameter */: + case 162 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -86218,40 +87806,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 207 /* TypeAssertionExpression */: - case 225 /* AsExpression */: + case 209 /* TypeAssertionExpression */: + case 227 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 204 /* CallExpression */: + case 206 /* CallExpression */: return visitCallExpression(node); - case 205 /* NewExpression */: + case 207 /* NewExpression */: return visitNewExpression(node); - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 226 /* NonNullExpression */: + case 228 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 275 /* JsxSelfClosingElement */: + case 277 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 276 /* JsxOpeningElement */: + case 278 /* JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -86264,33 +87852,14 @@ var ts; !ts.isJsonSourceFile(node); return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } - /** - * Tests whether we should emit a __decorate call for a class declaration. - */ - function shouldEmitDecorateCallForClass(node) { - if (node.decorators && node.decorators.length > 0) { - return true; - } - var constructor = ts.getFirstConstructorWithBody(node); - if (constructor) { - return ts.forEach(constructor.parameters, shouldEmitDecorateCallForParameter); - } - return false; - } - /** - * Tests whether we should emit a __decorate call for a parameter declaration. - */ - function shouldEmitDecorateCallForParameter(parameter) { - return parameter.decorators !== undefined && parameter.decorators.length > 0; - } function getClassFacts(node, staticProperties) { var facts = 0 /* None */; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; - if (shouldEmitDecorateCallForClass(node)) + if (ts.classOrConstructorParameterIsDecorated(node)) facts |= 2 /* HasConstructorDecorators */; if (ts.childIsDecorated(node)) facts |= 4 /* HasMemberDecorators */; @@ -86511,7 +88080,11 @@ var ts; // var location = ts.moveRangePastDecorators(node); var classAlias = getClassAliasIfNeeded(node); - var declName = factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); + // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name + // without any block-scoped variable collision handling + var declName = languageVersion <= 2 /* ES2015 */ ? + factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : + factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { // ${members} // } @@ -86589,7 +88162,7 @@ var ts; * @param member The class member. */ function isStaticDecoratedClassElement(member, parent) { - return isDecoratedClassElement(member, /*isStatic*/ true, parent); + return isDecoratedClassElement(member, /*isStaticElement*/ true, parent); } /** * Determines whether a class member is an instance member of a class that is decorated, @@ -86598,7 +88171,7 @@ var ts; * @param member The class member. */ function isInstanceDecoratedClassElement(member, parent) { - return isDecoratedClassElement(member, /*isStatic*/ false, parent); + return isDecoratedClassElement(member, /*isStaticElement*/ false, parent); } /** * Determines whether a class member is either a static or an instance member of a class @@ -86606,9 +88179,9 @@ var ts; * * @param member The class member. */ - function isDecoratedClassElement(member, isStatic, parent) { + function isDecoratedClassElement(member, isStaticElement, parent) { return ts.nodeOrChildIsDecorated(member, parent) - && isStatic === ts.hasSyntacticModifier(member, 32 /* Static */); + && isStaticElement === ts.isStatic(member); } /** * Gets an array of arrays of decorators for the parameters of a function-like node. @@ -86660,12 +88233,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -86818,7 +88391,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 164 /* PropertyDeclaration */ + ? member.kind === 165 /* PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -86854,7 +88427,11 @@ var ts; return undefined; } var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; - var localName = factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); + // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name + // without any block-scoped variable collision handling + var localName = languageVersion <= 2 /* ES2015 */ ? + factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : + factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); ts.setEmitFlags(expression, 1536 /* NoComments */); @@ -86942,10 +88519,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 166 /* MethodDeclaration */ - || kind === 168 /* GetAccessor */ - || kind === 169 /* SetAccessor */ - || kind === 164 /* PropertyDeclaration */; + return kind === 167 /* MethodDeclaration */ + || kind === 170 /* GetAccessor */ + || kind === 171 /* SetAccessor */ + || kind === 165 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -86955,7 +88532,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 166 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -86966,12 +88543,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return true; } return false; @@ -86988,15 +88565,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 164 /* PropertyDeclaration */: - case 161 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 162 /* Parameter */: return serializeTypeNode(node.type); - case 169 /* SetAccessor */: - case 168 /* GetAccessor */: + case 171 /* SetAccessor */: + case 170 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 166 /* MethodDeclaration */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 167 /* MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -87033,7 +88610,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 168 /* GetAccessor */) { + if (container && node.kind === 170 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -87078,82 +88655,82 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return factory.createVoidZero(); - case 187 /* ParenthesizedType */: + case 189 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 175 /* FunctionType */: - case 176 /* ConstructorType */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: return factory.createIdentifier("Function"); - case 179 /* ArrayType */: - case 180 /* TupleType */: + case 181 /* ArrayType */: + case 182 /* TupleType */: return factory.createIdentifier("Array"); - case 173 /* TypePredicate */: - case 131 /* BooleanKeyword */: + case 175 /* TypePredicate */: + case 132 /* BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return factory.createIdentifier("String"); - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return factory.createIdentifier("Object"); - case 192 /* LiteralType */: + case 194 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return factory.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return factory.createIdentifier("Boolean"); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return factory.createIdentifier("Number"); - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 174 /* TypeReference */: + case 176 /* TypeReference */: return serializeTypeReferenceNode(node); - case 184 /* IntersectionType */: - case 183 /* UnionType */: + case 186 /* IntersectionType */: + case 185 /* UnionType */: return serializeTypeList(node.types); - case 185 /* ConditionalType */: + case 187 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 189 /* TypeOperator */: - if (node.operator === 142 /* ReadonlyKeyword */) { + case 191 /* TypeOperator */: + if (node.operator === 143 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 177 /* TypeQuery */: - case 190 /* IndexedAccessType */: - case 191 /* MappedType */: - case 178 /* TypeLiteral */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 188 /* ThisType */: - case 196 /* ImportType */: + case 179 /* TypeQuery */: + case 192 /* IndexedAccessType */: + case 193 /* MappedType */: + case 180 /* TypeLiteral */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 190 /* ThisType */: + case 198 /* ImportType */: break; // handle JSDoc types from an invalid parse - case 304 /* JSDocAllType */: - case 305 /* JSDocUnknownType */: - case 309 /* JSDocFunctionType */: - case 310 /* JSDocVariadicType */: - case 311 /* JSDocNamepathType */: + case 307 /* JSDocAllType */: + case 308 /* JSDocUnknownType */: + case 312 /* JSDocFunctionType */: + case 313 /* JSDocVariadicType */: + case 314 /* JSDocNamepathType */: break; - case 306 /* JSDocNullableType */: - case 307 /* JSDocNonNullableType */: - case 308 /* JSDocOptionalType */: + case 309 /* JSDocNullableType */: + case 310 /* JSDocNonNullableType */: + case 311 /* JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -87164,15 +88741,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_24 = types; _i < types_24.length; _i++) { - var typeNode = types_24[_i]; - while (typeNode.kind === 187 /* ParenthesizedType */) { + for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { + var typeNode = types_23[_i]; + while (typeNode.kind === 189 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 192 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 194 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -87254,12 +88831,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 78 /* Identifier */) { + if (node.left.kind === 79 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -87275,14 +88852,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -87373,7 +88950,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 116 /* ImplementsKeyword */) { + if (node.token === 117 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -87855,12 +89432,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 298 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 300 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 256 /* EnumDeclaration */) { + if (node.kind === 258 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -87985,7 +89562,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 258 /* ModuleBlock */) { + if (node.body.kind === 260 /* ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -88032,13 +89609,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 258 /* ModuleBlock */) { + if (!node.body || node.body.kind !== 260 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 257 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 259 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -88088,7 +89665,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 264 /* NamespaceImport */) { + if (node.kind === 266 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -88315,14 +89892,14 @@ var ts; return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype"); } function getClassMemberPrefix(node, member) { - return ts.hasSyntacticModifier(member, 32 /* Static */) + return ts.isStatic(member) ? factory.getDeclarationName(node) : getClassPrototype(node); } function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -88330,7 +89907,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -88340,17 +89917,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(78 /* Identifier */); - context.enableSubstitution(290 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(292 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(257 /* ModuleDeclaration */); + context.enableEmitNotification(259 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 257 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 259 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 256 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 258 /* EnumDeclaration */; } /** * Hook for node emit. @@ -88409,11 +89986,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -88451,9 +90028,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 298 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 257 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 256 /* EnumDeclaration */); + if (container && container.kind !== 300 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 259 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 258 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -88504,6 +90081,11 @@ var ts; * which have initializers that reference the class name. */ ClassPropertySubstitutionFlags[ClassPropertySubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + /** + * Enables substitutions for class expressions with static fields + * which have initializers that reference the 'this' or 'super'. + */ + ClassPropertySubstitutionFlags[ClassPropertySubstitutionFlags["ClassStaticThisOrSuperReference"] = 2] = "ClassStaticThisOrSuperReference"; })(ClassPropertySubstitutionFlags || (ClassPropertySubstitutionFlags = {})); var PrivateIdentifierKind; (function (PrivateIdentifierKind) { @@ -88511,6 +90093,14 @@ var ts; PrivateIdentifierKind["Method"] = "m"; PrivateIdentifierKind["Accessor"] = "a"; })(PrivateIdentifierKind = ts.PrivateIdentifierKind || (ts.PrivateIdentifierKind = {})); + var ClassFacts; + (function (ClassFacts) { + ClassFacts[ClassFacts["None"] = 0] = "None"; + ClassFacts[ClassFacts["ClassWasDecorated"] = 1] = "ClassWasDecorated"; + ClassFacts[ClassFacts["NeedsClassConstructorReference"] = 2] = "NeedsClassConstructorReference"; + ClassFacts[ClassFacts["NeedsClassSuperReference"] = 4] = "NeedsClassSuperReference"; + ClassFacts[ClassFacts["NeedsSubstitutionForThisInClassStaticField"] = 8] = "NeedsSubstitutionForThisInClassStaticField"; + })(ClassFacts || (ClassFacts = {})); /** * Transforms ECMAScript Class Syntax. * TypeScript parameter property syntax is transformed in the TypeScript transformer. @@ -88519,14 +90109,20 @@ var ts; * When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty. */ function transformClassFields(context) { - var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, addBlockScopedVariable = context.addBlockScopedVariable; + var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, addBlockScopedVariable = context.addBlockScopedVariable; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); - var shouldTransformPrivateElements = languageVersion < 99 /* ESNext */; + var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 99 /* ESNext */; + // We don't need to transform `super` property access when targeting ES5, ES3 because + // the es2015 transformation handles those. + var shouldTransformSuperInStaticInitializers = (languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields) && languageVersion >= 2 /* ES2015 */; + var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; var enabledSubstitutions; var classAliases; /** @@ -88539,8 +90135,11 @@ var ts; * emitted at the next execution site, in document order (for decorated classes). */ var pendingStatements; - var privateIdentifierEnvironmentStack = []; - var currentPrivateIdentifierEnvironment; + var classLexicalEnvironmentStack = []; + var classLexicalEnvironmentMap = new ts.Map(); + var currentClassLexicalEnvironment; + var currentComputedPropertyNameClassLexicalEnvironment; + var currentStaticPropertyDeclarationOrStaticBlock; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { var options = context.getCompilerOptions(); @@ -88552,42 +90151,80 @@ var ts; ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function visitorWorker(node, valueIsDiscarded) { + if (node.transformFlags & 8388608 /* ContainsClassFields */) { + switch (node.kind) { + case 224 /* ClassExpression */: + case 255 /* ClassDeclaration */: + return visitClassLike(node); + case 165 /* PropertyDeclaration */: + return visitPropertyDeclaration(node); + case 235 /* VariableStatement */: + return visitVariableStatement(node); + case 80 /* PrivateIdentifier */: + return visitPrivateIdentifier(node); + case 168 /* ClassStaticBlockDeclaration */: + return visitClassStaticBlockDeclaration(node); + } + } + if (node.transformFlags & 8388608 /* ContainsClassFields */ || + node.transformFlags & 33554432 /* ContainsLexicalSuper */ && + shouldTransformSuperInStaticInitializers && + currentStaticPropertyDeclarationOrStaticBlock && + currentClassLexicalEnvironment) { + switch (node.kind) { + case 217 /* PrefixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: + return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); + case 219 /* BinaryExpression */: + return visitBinaryExpression(node, valueIsDiscarded); + case 206 /* CallExpression */: + return visitCallExpression(node); + case 208 /* TaggedTemplateExpression */: + return visitTaggedTemplateExpression(node); + case 204 /* PropertyAccessExpression */: + return visitPropertyAccessExpression(node); + case 205 /* ElementAccessExpression */: + return visitElementAccessExpression(node); + case 236 /* ExpressionStatement */: + return visitExpressionStatement(node); + case 240 /* ForStatement */: + return visitForStatement(node); + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 169 /* Constructor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: { + var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; + currentStaticPropertyDeclarationOrStaticBlock = undefined; + var result = ts.visitEachChild(node, visitor, context); + currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; + return result; + } + } + } + return ts.visitEachChild(node, visitor, context); + } + function discardedValueVisitor(node) { + return visitorWorker(node, /*valueIsDiscarded*/ true); + } function visitor(node) { - if (!(node.transformFlags & 8388608 /* ContainsClassFields */)) - return node; + return visitorWorker(node, /*valueIsDiscarded*/ false); + } + function heritageClauseVisitor(node) { switch (node.kind) { - case 222 /* ClassExpression */: - case 253 /* ClassDeclaration */: - return visitClassLike(node); - case 164 /* PropertyDeclaration */: - return visitPropertyDeclaration(node); - case 233 /* VariableStatement */: - return visitVariableStatement(node); - case 202 /* PropertyAccessExpression */: - return visitPropertyAccessExpression(node); - case 215 /* PrefixUnaryExpression */: - return visitPrefixUnaryExpression(node); - case 216 /* PostfixUnaryExpression */: - return visitPostfixUnaryExpression(node, /*valueIsDiscarded*/ false); - case 204 /* CallExpression */: - return visitCallExpression(node); - case 217 /* BinaryExpression */: - return visitBinaryExpression(node); - case 79 /* PrivateIdentifier */: - return visitPrivateIdentifier(node); - case 234 /* ExpressionStatement */: - return visitExpressionStatement(node); - case 238 /* ForStatement */: - return visitForStatement(node); - case 206 /* TaggedTemplateExpression */: - return visitTaggedTemplateExpression(node); + case 289 /* HeritageClause */: + return ts.visitEachChild(node, heritageClauseVisitor, context); + case 226 /* ExpressionWithTypeArguments */: + return visitExpressionWithTypeArguments(node); } - return ts.visitEachChild(node, visitor, context); + return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 201 /* ObjectLiteralExpression */: - case 200 /* ArrayLiteralExpression */: + case 203 /* ObjectLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -88598,7 +90235,7 @@ var ts; * Replace it with an empty identifier to indicate a problem with the code. */ function visitPrivateIdentifier(node) { - if (!shouldTransformPrivateElements) { + if (!shouldTransformPrivateElementsOrClassStaticBlocks) { return node; } return ts.setOriginalNode(factory.createIdentifier(""), node); @@ -88610,19 +90247,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 167 /* Constructor */: + case 169 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 166 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 167 /* MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 230 /* SemicolonClassElement */: + case 232 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -88632,7 +90269,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? __spreadArray([visitedNode], pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArray([visitedNode], pendingStatements, true) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -88649,7 +90286,7 @@ var ts; } function visitMethodOrAccessorDeclaration(node) { ts.Debug.assert(!ts.some(node.decorators)); - if (!shouldTransformPrivateElements || !ts.isPrivateIdentifier(node.name)) { + if (!shouldTransformPrivateElementsOrClassStaticBlocks || !ts.isPrivateIdentifier(node.name)) { return ts.visitEachChild(node, classElementVisitor, context); } // leave invalid code untransformed @@ -88686,7 +90323,7 @@ var ts; function visitPropertyDeclaration(node) { ts.Debug.assert(!ts.some(node.decorators)); if (ts.isPrivateIdentifier(node.name)) { - if (!shouldTransformPrivateElements) { + if (!shouldTransformPrivateElementsOrClassStaticBlocks) { // Initializer is elided as the field is initialized in transformConstructor. return factory.updatePropertyDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, @@ -88727,60 +90364,130 @@ var ts; } } function visitPropertyAccessExpression(node) { - if (shouldTransformPrivateElements && ts.isPrivateIdentifier(node.name)) { + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(node.name)) { var privateIdentifierInfo = accessPrivateIdentifier(node.name); if (privateIdentifierInfo) { return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node), node); } } + if (shouldTransformSuperInStaticInitializers && + ts.isSuperProperty(node) && + ts.isIdentifier(node.name) && + currentStaticPropertyDeclarationOrStaticBlock && + currentClassLexicalEnvironment) { + var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; + if (facts & 1 /* ClassWasDecorated */) { + return visitInvalidSuperProperty(node); + } + if (classConstructor && superClassReference) { + // converts `super.x` into `Reflect.get(_baseTemp, "x", _classTemp)` + var superProperty = factory.createReflectGetCall(superClassReference, factory.createStringLiteralFromNode(node.name), classConstructor); + ts.setOriginalNode(superProperty, node.expression); + ts.setTextRange(superProperty, node.expression); + return superProperty; + } + } return ts.visitEachChild(node, visitor, context); } - function visitPrefixUnaryExpression(node) { - if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; - var info = void 0; - if (operator && (info = accessPrivateIdentifier(node.operand.name))) { - var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); - var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; - var existingValue = factory.createPrefixUnaryExpression(39 /* PlusToken */, createPrivateIdentifierAccess(info, readExpression)); - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), node); + function visitElementAccessExpression(node) { + if (shouldTransformSuperInStaticInitializers && + ts.isSuperProperty(node) && + currentStaticPropertyDeclarationOrStaticBlock && + currentClassLexicalEnvironment) { + var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; + if (facts & 1 /* ClassWasDecorated */) { + return visitInvalidSuperProperty(node); + } + if (classConstructor && superClassReference) { + // converts `super[x]` into `Reflect.get(_baseTemp, x, _classTemp)` + var superProperty = factory.createReflectGetCall(superClassReference, ts.visitNode(node.argumentExpression, visitor, ts.isExpression), classConstructor); + ts.setOriginalNode(superProperty, node.expression); + ts.setTextRange(superProperty, node.expression); + return superProperty; } } return ts.visitEachChild(node, visitor, context); } - function visitPostfixUnaryExpression(node, valueIsDiscarded) { - if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { - var operator = node.operator === 45 /* PlusPlusToken */ ? - 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? - 40 /* MinusToken */ : undefined; - var info = void 0; - if (operator && (info = accessPrivateIdentifier(node.operand.name))) { - var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); - var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; - var existingValue = factory.createPrefixUnaryExpression(39 /* PlusToken */, createPrivateIdentifierAccess(info, readExpression)); - // Create a temporary variable to store the value returned by the expression. - var returnValue = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); - return ts.setOriginalNode(factory.inlineExpressions(ts.compact([ - createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), - returnValue - ])), node); + function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + var info = void 0; + if (info = accessPrivateIdentifier(node.operand.name)) { + var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); + var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; + var expression = createPrivateIdentifierAccess(info, readExpression); + var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); + expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); + expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */); + ts.setOriginalNode(expression, node); + ts.setTextRange(expression, node); + if (temp) { + expression = factory.createComma(expression, temp); + ts.setTextRange(expression, node); + } + return expression; + } + } + else if (shouldTransformSuperInStaticInitializers && + ts.isSuperProperty(node.operand) && + currentStaticPropertyDeclarationOrStaticBlock && + currentClassLexicalEnvironment) { + // converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)` + // converts `++super[f()]` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = ++_b), _classTemp), _c)` + // converts `--super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = --_a), _classTemp), _b)` + // converts `--super[f()]` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = --_b), _classTemp), _c)` + // converts `super.a++` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a++), _classTemp), _b)` + // converts `super[f()]++` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b++), _classTemp), _c)` + // converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)` + // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)` + var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; + if (facts & 1 /* ClassWasDecorated */) { + var operand = visitInvalidSuperProperty(node.operand); + return ts.isPrefixUnaryExpression(node) ? + factory.updatePrefixUnaryExpression(node, operand) : + factory.updatePostfixUnaryExpression(node, operand); + } + if (classConstructor && superClassReference) { + var setterName = void 0; + var getterName = void 0; + if (ts.isPropertyAccessExpression(node.operand)) { + if (ts.isIdentifier(node.operand.name)) { + getterName = setterName = factory.createStringLiteralFromNode(node.operand.name); + } + } + else { + if (ts.isSimpleInlineableExpression(node.operand.argumentExpression)) { + getterName = setterName = node.operand.argumentExpression; + } + else { + getterName = factory.createTempVariable(hoistVariableDeclaration); + setterName = factory.createAssignment(getterName, ts.visitNode(node.operand.argumentExpression, visitor, ts.isExpression)); + } + } + if (setterName && getterName) { + var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor); + ts.setTextRange(expression, node.operand); + var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); + expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); + expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor); + ts.setOriginalNode(expression, node); + ts.setTextRange(expression, node); + if (temp) { + expression = factory.createComma(expression, temp); + ts.setTextRange(expression, node); + } + return expression; + } + } } } return ts.visitEachChild(node, visitor, context); } function visitForStatement(node) { - if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) { - return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitIterationBody(node.statement, visitor, context)); - } - return ts.visitEachChild(node, visitor, context); + return factory.updateForStatement(node, ts.visitNode(node.initializer, discardedValueVisitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, discardedValueVisitor, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); } function visitExpressionStatement(node) { - if (ts.isPostfixUnaryExpression(node.expression)) { - return factory.updateExpressionStatement(node, visitPostfixUnaryExpression(node.expression, /*valueIsDiscarded*/ true)); - } - return ts.visitEachChild(node, visitor, context); + return factory.updateExpressionStatement(node, ts.visitNode(node.expression, discardedValueVisitor, ts.isExpression)); } function createCopiableReceiverExpr(receiver) { var clone = ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver); @@ -88792,47 +90499,132 @@ var ts; return { readExpression: readExpression, initializeExpression: initializeExpression }; } function visitCallExpression(node) { - if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { // Transform call expressions of private names to properly bind the `this` parameter. var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; if (ts.isCallChain(node)) { return factory.updateCallChain(node, factory.createPropertyAccessChain(ts.visitNode(target, visitor), node.questionDotToken, "call"), /*questionDotToken*/ undefined, - /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); + /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression), true)); } return factory.updateCallExpression(node, factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "call"), - /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); + /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression), true)); + } + if (shouldTransformSuperInStaticInitializers && + ts.isSuperProperty(node.expression) && + currentStaticPropertyDeclarationOrStaticBlock && + (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.classConstructor)) { + // converts `super.f(...)` into `Reflect.get(_baseTemp, "f", _classTemp).call(_classTemp, ...)` + var invocation = factory.createFunctionCallCall(ts.visitNode(node.expression, visitor, ts.isExpression), currentClassLexicalEnvironment.classConstructor, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + ts.setOriginalNode(invocation, node); + ts.setTextRange(invocation, node); + return invocation; } return ts.visitEachChild(node, visitor, context); } function visitTaggedTemplateExpression(node) { - if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { // Bind the `this` correctly for tagged template literals when the tag is a private identifier property access. var _a = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; return factory.updateTaggedTemplateExpression(node, factory.createCallExpression(factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "bind"), /*typeArguments*/ undefined, [ts.visitNode(thisArg, visitor, ts.isExpression)]), /*typeArguments*/ undefined, ts.visitNode(node.template, visitor, ts.isTemplateLiteral)); } + if (shouldTransformSuperInStaticInitializers && + ts.isSuperProperty(node.tag) && + currentStaticPropertyDeclarationOrStaticBlock && + (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.classConstructor)) { + // converts `` super.f`x` `` into `` Reflect.get(_baseTemp, "f", _classTemp).bind(_classTemp)`x` `` + var invocation = factory.createFunctionBindCall(ts.visitNode(node.tag, visitor, ts.isExpression), currentClassLexicalEnvironment.classConstructor, []); + ts.setOriginalNode(invocation, node); + ts.setTextRange(invocation, node); + return factory.updateTaggedTemplateExpression(node, invocation, + /*typeArguments*/ undefined, ts.visitNode(node.template, visitor, ts.isTemplateLiteral)); + } return ts.visitEachChild(node, visitor, context); } - function visitBinaryExpression(node) { - if (shouldTransformPrivateElements) { - if (ts.isDestructuringAssignment(node)) { - var savedPendingExpressions = pendingExpressions; - pendingExpressions = undefined; - node = factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorDestructuringTarget), node.operatorToken, ts.visitNode(node.right, visitor)); - var expr = ts.some(pendingExpressions) ? - factory.inlineExpressions(ts.compact(__spreadArray(__spreadArray([], pendingExpressions), [node]))) : - node; - pendingExpressions = savedPendingExpressions; - return expr; - } - if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) { + function transformClassStaticBlockDeclaration(node) { + if (shouldTransformPrivateElementsOrClassStaticBlocks) { + if (currentClassLexicalEnvironment) { + classLexicalEnvironmentMap.set(ts.getOriginalNodeId(node), currentClassLexicalEnvironment); + } + startLexicalEnvironment(); + var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; + currentStaticPropertyDeclarationOrStaticBlock = node; + var statements = ts.visitNodes(node.body.statements, visitor, ts.isStatement); + statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); + currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; + var iife = factory.createImmediatelyInvokedArrowFunction(statements); + ts.setOriginalNode(iife, node); + ts.setTextRange(iife, node); + ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */); + return iife; + } + } + function visitBinaryExpression(node, valueIsDiscarded) { + if (ts.isDestructuringAssignment(node)) { + var savedPendingExpressions = pendingExpressions; + pendingExpressions = undefined; + node = factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorDestructuringTarget), node.operatorToken, ts.visitNode(node.right, visitor)); + var expr = ts.some(pendingExpressions) ? + factory.inlineExpressions(ts.compact(__spreadArray(__spreadArray([], pendingExpressions, true), [node], false))) : + node; + pendingExpressions = savedPendingExpressions; + return expr; + } + if (ts.isAssignmentExpression(node)) { + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) { var info = accessPrivateIdentifier(node.left.name); if (info) { return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node), node); } } + else if (shouldTransformSuperInStaticInitializers && + ts.isSuperProperty(node.left) && + currentStaticPropertyDeclarationOrStaticBlock && + currentClassLexicalEnvironment) { + var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; + if (facts & 1 /* ClassWasDecorated */) { + return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); + } + if (classConstructor && superClassReference) { + var setterName = ts.isElementAccessExpression(node.left) ? ts.visitNode(node.left.argumentExpression, visitor, ts.isExpression) : + ts.isIdentifier(node.left.name) ? factory.createStringLiteralFromNode(node.left.name) : + undefined; + if (setterName) { + // converts `super.x = 1` into `(Reflect.set(_baseTemp, "x", _a = 1, _classTemp), _a)` + // converts `super[f()] = 1` into `(Reflect.set(_baseTemp, f(), _a = 1, _classTemp), _a)` + // converts `super.x += 1` into `(Reflect.set(_baseTemp, "x", _a = Reflect.get(_baseTemp, "x", _classtemp) + 1, _classTemp), _a)` + // converts `super[f()] += 1` into `(Reflect.set(_baseTemp, _a = f(), _b = Reflect.get(_baseTemp, _a, _classtemp) + 1, _classTemp), _b)` + var expression = ts.visitNode(node.right, visitor, ts.isExpression); + if (ts.isCompoundAssignment(node.operatorToken.kind)) { + var getterName = setterName; + if (!ts.isSimpleInlineableExpression(setterName)) { + getterName = factory.createTempVariable(hoistVariableDeclaration); + setterName = factory.createAssignment(getterName, setterName); + } + var superPropertyGet = factory.createReflectGetCall(superClassReference, getterName, classConstructor); + ts.setOriginalNode(superPropertyGet, node.left); + ts.setTextRange(superPropertyGet, node.left); + expression = factory.createBinaryExpression(superPropertyGet, ts.getNonAssignmentOperatorForCompoundAssignment(node.operatorToken.kind), expression); + ts.setTextRange(expression, node); + } + var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); + if (temp) { + expression = factory.createAssignment(temp, expression); + ts.setTextRange(temp, node); + } + expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor); + ts.setOriginalNode(expression, node); + ts.setTextRange(expression, node); + if (temp) { + expression = factory.createComma(expression, temp); + ts.setTextRange(expression, node); + } + return expression; + } + } + } } return ts.visitEachChild(node, visitor, context); } @@ -88861,10 +90653,13 @@ var ts; * Set up the environment for a class. */ function visitClassLike(node) { + if (!ts.forEach(node.members, doesClassElementNeedTransform)) { + return ts.visitEachChild(node, visitor, context); + } var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; - if (shouldTransformPrivateElements) { - startPrivateIdentifierEnvironment(); + startClassLexicalEnvironment(); + if (shouldTransformPrivateElementsOrClassStaticBlocks) { var name = ts.getNameOfDeclaration(node); if (name && ts.isIdentifier(name)) { getPrivateIdentifierEnvironment().className = ts.idText(name); @@ -88877,38 +90672,81 @@ var ts; var result = ts.isClassDeclaration(node) ? visitClassDeclaration(node) : visitClassExpression(node); - if (shouldTransformPrivateElements) { - endPrivateIdentifierEnvironment(); - } + endClassLexicalEnvironment(); pendingExpressions = savedPendingExpressions; return result; } function doesClassElementNeedTransform(node) { - return ts.isPropertyDeclaration(node) || (shouldTransformPrivateElements && node.name && ts.isPrivateIdentifier(node.name)); + return ts.isPropertyDeclaration(node) || ts.isClassStaticBlockDeclaration(node) || (shouldTransformPrivateElementsOrClassStaticBlocks && node.name && ts.isPrivateIdentifier(node.name)); } function getPrivateInstanceMethodsAndAccessors(node) { return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } - function visitClassDeclaration(node) { - if (!ts.forEach(node.members, doesClassElementNeedTransform)) { - return ts.visitEachChild(node, visitor, context); + function getClassFacts(node) { + var facts = 0 /* None */; + var original = ts.getOriginalNode(node); + if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) { + facts |= 1 /* ClassWasDecorated */; } - var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); - var pendingPrivateStateAssignment; - if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { - var temp = factory.createTempVariable(hoistVariableDeclaration, /* reservedInNestedScopes */ true); - getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); - pendingPrivateStateAssignment = factory.createAssignment(temp, factory.getInternalName(node)); + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (!ts.isStatic(member)) + continue; + if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) { + facts |= 2 /* NeedsClassConstructorReference */; + } + if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { + if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) { + facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */; + if (!(facts & 1 /* ClassWasDecorated */)) { + facts |= 2 /* NeedsClassConstructorReference */; + } + } + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) { + if (!(facts & 1 /* ClassWasDecorated */)) { + facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */; + } + } + } + } + return facts; + } + function visitExpressionWithTypeArguments(node) { + var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */; + if (facts & 4 /* NeedsClassSuperReference */) { + var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true); + getClassLexicalEnvironment().superClassReference = temp; + return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)), + /*typeArguments*/ undefined); + } + return ts.visitEachChild(node, visitor, context); + } + function visitClassDeclaration(node) { + var facts = getClassFacts(node); + if (facts) { + getClassLexicalEnvironment().facts = facts; + } + if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + enableSubstitutionForClassStaticThisOrSuperReference(); + } + var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node); + // If a class has private static fields, or a static field has a `this` or `super` reference, + // then we need to allocate a temp variable to hold on to that reference. + var pendingClassReferenceAssignment; + if (facts & 2 /* NeedsClassConstructorReference */) { + var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); + getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); + pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node)); } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); var statements = [ factory.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) ]; - if (pendingPrivateStateAssignment) { - getPendingExpressions().unshift(pendingPrivateStateAssignment); + if (pendingClassReferenceAssignment) { + getPendingExpressions().unshift(pendingClassReferenceAssignment); } // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { @@ -88920,13 +90758,17 @@ var ts; // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. if (ts.some(staticProperties)) { - addPropertyStatements(statements, staticProperties, factory.getInternalName(node)); + addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node)); } return statements; } function visitClassExpression(node) { - if (!ts.forEach(node.members, doesClassElementNeedTransform)) { - return ts.visitEachChild(node, visitor, context); + var facts = getClassFacts(node); + if (facts) { + getClassLexicalEnvironment().facts = facts; + } + if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + enableSubstitutionForClassStaticThisOrSuperReference(); } // If this class expression is a transformation of a decorated class declaration, // then we want to output the pendingExpressions as statements, not as inlined @@ -88935,10 +90777,10 @@ var ts; // In this case, we use pendingStatements to produce the same output as the // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. - var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); + var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */); + var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; var temp; function createClassTempVar() { @@ -88947,13 +90789,13 @@ var ts; var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); } - if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + if (facts & 2 /* NeedsClassConstructorReference */) { temp = createClassTempVar(); - getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); - var hasTransformableStatics = ts.some(staticProperties, function (p) { return !!p.initializer || (shouldTransformPrivateElements && ts.isPrivateIdentifier(p.name)); }); + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); + var hasTransformableStatics = ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(p.name)); }); if (hasTransformableStatics || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration."); @@ -88961,8 +90803,8 @@ var ts; if (pendingStatements && pendingExpressions && ts.some(pendingExpressions)) { pendingStatements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))); } - if (pendingStatements && ts.some(staticProperties)) { - addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node)); + if (pendingStatements && ts.some(staticPropertiesOrClassStaticBlocks)) { + addPropertyOrClassStaticBlockStatements(pendingStatements, staticPropertiesOrClassStaticBlocks, factory.getInternalName(node)); } if (temp) { return factory.inlineExpressions([factory.createAssignment(temp, classExpression), temp]); @@ -88985,15 +90827,22 @@ var ts; expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression))); // Add any pending expressions leftover from elided or relocated computed property names ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine)); - ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); + ts.addRange(expressions, generateInitializedPropertyExpressionsOrClassStaticBlock(staticPropertiesOrClassStaticBlocks, temp)); expressions.push(ts.startOnNewLine(temp)); return factory.inlineExpressions(expressions); } } return classExpression; } + function visitClassStaticBlockDeclaration(node) { + if (!shouldTransformPrivateElementsOrClassStaticBlocks) { + return ts.visitEachChild(node, classElementVisitor, context); + } + // ClassStaticBlockDeclaration for classes are transformed in `visitClassDeclaration` or `visitClassExpression`. + return undefined; + } function transformClassMembers(node, isDerivedClass) { - if (shouldTransformPrivateElements) { + if (shouldTransformPrivateElementsOrClassStaticBlocks) { // Declare private names. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -89020,7 +90869,7 @@ var ts; /*typeArguments*/ undefined, []))); } function isClassElementThatRequiresConstructorStatement(member) { - if (ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { return false; } if (useDefineForClassFields) { @@ -89028,7 +90877,7 @@ var ts; // then we don't need to transform any class properties. return languageVersion < 99 /* ESNext */; } - return ts.isInitializedProperty(member) || shouldTransformPrivateElements && ts.isPrivateIdentifierClassElementDeclaration(member); + return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member); } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); @@ -89095,7 +90944,7 @@ var ts; var receiver = factory.createThis(); // private methods can be called in property initializers, they should execute first. addMethodStatements(statements, privateMethodsAndAccessors, receiver); - addPropertyStatements(statements, properties, receiver); + addPropertyOrClassStaticBlockStatements(statements, properties, receiver); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -89112,10 +90961,12 @@ var ts; * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addPropertyStatements(statements, properties, receiver) { + function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) { for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; - var expression = transformProperty(property, receiver); + var expression = ts.isClassStaticBlockDeclaration(property) ? + transformClassStaticBlockDeclaration(property) : + transformProperty(property, receiver); if (!expression) { continue; } @@ -89129,14 +90980,14 @@ var ts; /** * Generates assignment expressions for property initializers. * - * @param properties An array of property declarations to transform. + * @param propertiesOrClassStaticBlocks An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function generateInitializedPropertyExpressions(properties, receiver) { + function generateInitializedPropertyExpressionsOrClassStaticBlock(propertiesOrClassStaticBlocks, receiver) { var expressions = []; - for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { - var property = properties_8[_i]; - var expression = transformProperty(property, receiver); + for (var _i = 0, propertiesOrClassStaticBlocks_1 = propertiesOrClassStaticBlocks; _i < propertiesOrClassStaticBlocks_1.length; _i++) { + var property = propertiesOrClassStaticBlocks_1[_i]; + var expression = ts.isClassStaticBlockDeclaration(property) ? transformClassStaticBlockDeclaration(property) : transformProperty(property, receiver); if (!expression) { continue; } @@ -89155,13 +91006,28 @@ var ts; * @param receiver The object receiving the property assignment. */ function transformProperty(property, receiver) { + var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; + var transformed = transformPropertyWorker(property, receiver); + if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) { + // capture the lexical environment for the member + ts.setOriginalNode(transformed, property); + ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */); + classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment); + } + currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; + return transformed; + } + function transformPropertyWorker(property, receiver) { var _a; // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) var emitAssignment = !useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name)) : property.name; - if (shouldTransformPrivateElements && ts.isPrivateIdentifier(propertyName)) { + if (ts.hasStaticModifier(property)) { + currentStaticPropertyDeclarationOrStaticBlock = property; + } + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { if (privateIdentifierInfo.kind === "f" /* Field */) { @@ -89207,11 +91073,30 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } } + function enableSubstitutionForClassStaticThisOrSuperReference() { + if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) { + enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */; + // substitute `this` in a static field initializer + context.enableSubstitution(108 /* ThisKeyword */); + // these push a new lexical environment that is not the class lexical environment + context.enableEmitNotification(254 /* FunctionDeclaration */); + context.enableEmitNotification(211 /* FunctionExpression */); + context.enableEmitNotification(169 /* Constructor */); + // these push a new lexical environment that is not the class lexical environment, except + // when they have a computed property name + context.enableEmitNotification(170 /* GetAccessor */); + context.enableEmitNotification(171 /* SetAccessor */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(165 /* PropertyDeclaration */); + // class lexical environments are restored when entering a computed property name + context.enableEmitNotification(160 /* ComputedPropertyName */); + } + } /** * Generates brand-check initializer for private methods. * @@ -89220,13 +91105,76 @@ var ts; * @param receiver The receiver on which each method should be assigned. */ function addMethodStatements(statements, methods, receiver) { - if (!shouldTransformPrivateElements || !ts.some(methods)) { + if (!shouldTransformPrivateElementsOrClassStaticBlocks || !ts.some(methods)) { return; } var weakSetName = getPrivateIdentifierEnvironment().weakSetName; ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); statements.push(factory.createExpressionStatement(createPrivateInstanceMethodInitializer(receiver, weakSetName))); } + function visitInvalidSuperProperty(node) { + return ts.isPropertyAccessExpression(node) ? + factory.updatePropertyAccessExpression(node, factory.createVoidZero(), node.name) : + factory.updateElementAccessExpression(node, factory.createVoidZero(), ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + } + function onEmitNode(hint, node, emitCallback) { + var original = ts.getOriginalNode(node); + if (original.id) { + var classLexicalEnvironment = classLexicalEnvironmentMap.get(original.id); + if (classLexicalEnvironment) { + var savedClassLexicalEnvironment = currentClassLexicalEnvironment; + var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; + currentClassLexicalEnvironment = classLexicalEnvironment; + currentComputedPropertyNameClassLexicalEnvironment = classLexicalEnvironment; + previousOnEmitNode(hint, node, emitCallback); + currentClassLexicalEnvironment = savedClassLexicalEnvironment; + currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; + return; + } + } + switch (node.kind) { + case 211 /* FunctionExpression */: + if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { + break; + } + // falls through + case 254 /* FunctionDeclaration */: + case 169 /* Constructor */: { + var savedClassLexicalEnvironment = currentClassLexicalEnvironment; + var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; + currentClassLexicalEnvironment = undefined; + currentComputedPropertyNameClassLexicalEnvironment = undefined; + previousOnEmitNode(hint, node, emitCallback); + currentClassLexicalEnvironment = savedClassLexicalEnvironment; + currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; + return; + } + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 165 /* PropertyDeclaration */: { + var savedClassLexicalEnvironment = currentClassLexicalEnvironment; + var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; + currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; + currentClassLexicalEnvironment = undefined; + previousOnEmitNode(hint, node, emitCallback); + currentClassLexicalEnvironment = savedClassLexicalEnvironment; + currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; + return; + } + case 160 /* ComputedPropertyName */: { + var savedClassLexicalEnvironment = currentClassLexicalEnvironment; + var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; + currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; + currentComputedPropertyNameClassLexicalEnvironment = undefined; + previousOnEmitNode(hint, node, emitCallback); + currentClassLexicalEnvironment = savedClassLexicalEnvironment; + currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } /** * Hooks node substitutions. * @@ -89242,8 +91190,22 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); + case 108 /* ThisKeyword */: + return substituteThisExpression(node); + } + return node; + } + function substituteThisExpression(node) { + if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { + var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor; + if (facts & 1 /* ClassWasDecorated */) { + return factory.createParenthesizedExpression(factory.createVoidZero()); + } + if (classConstructor) { + return ts.setTextRange(ts.setOriginalNode(factory.cloneNode(classConstructor), node), node); + } } return node; } @@ -89296,21 +91258,28 @@ var ts; return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression; } } - function startPrivateIdentifierEnvironment() { - privateIdentifierEnvironmentStack.push(currentPrivateIdentifierEnvironment); - currentPrivateIdentifierEnvironment = undefined; + function startClassLexicalEnvironment() { + classLexicalEnvironmentStack.push(currentClassLexicalEnvironment); + currentClassLexicalEnvironment = undefined; } - function endPrivateIdentifierEnvironment() { - currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop(); + function endClassLexicalEnvironment() { + currentClassLexicalEnvironment = classLexicalEnvironmentStack.pop(); + } + function getClassLexicalEnvironment() { + return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = { + facts: 0 /* None */, + classConstructor: undefined, + superClassReference: undefined, + privateIdentifierEnvironment: undefined, + }); } function getPrivateIdentifierEnvironment() { - if (!currentPrivateIdentifierEnvironment) { - currentPrivateIdentifierEnvironment = { - className: "", - identifiers: new ts.Map() - }; - } - return currentPrivateIdentifierEnvironment; + var lex = getClassLexicalEnvironment(); + lex.privateIdentifierEnvironment || (lex.privateIdentifierEnvironment = { + className: "", + identifiers: new ts.Map() + }); + return lex.privateIdentifierEnvironment; } function getPendingExpressions() { return pendingExpressions || (pendingExpressions = []); @@ -89318,17 +91287,19 @@ var ts; function addPrivateIdentifierToEnvironment(node) { var _a; var text = ts.getTextOfPropertyName(node.name); - var env = getPrivateIdentifierEnvironment(); - var weakSetName = env.weakSetName, classConstructor = env.classConstructor; + var lex = getClassLexicalEnvironment(); + var classConstructor = lex.classConstructor; + var privateEnv = getPrivateIdentifierEnvironment(); + var weakSetName = privateEnv.weakSetName; var assignmentExpressions = []; var privateName = node.name.escapedText; - var previousInfo = env.identifiers.get(privateName); + var previousInfo = privateEnv.identifiers.get(privateName); var isValid = !isReservedPrivateName(node.name) && previousInfo === undefined; if (ts.hasStaticModifier(node)) { ts.Debug.assert(classConstructor, "weakSetName should be set in private identifier environment"); if (ts.isPropertyDeclaration(node)) { var variableName = createHoistedVariableForPrivateName(text, node); - env.identifiers.set(privateName, { + privateEnv.identifiers.set(privateName, { kind: "f" /* Field */, variableName: variableName, brandCheckIdentifier: classConstructor, @@ -89338,7 +91309,7 @@ var ts; } else if (ts.isMethodDeclaration(node)) { var functionName = createHoistedVariableForPrivateName(text, node); - env.identifiers.set(privateName, { + privateEnv.identifiers.set(privateName, { kind: "m" /* Method */, methodName: functionName, brandCheckIdentifier: classConstructor, @@ -89352,7 +91323,7 @@ var ts; previousInfo.getterName = getterName; } else { - env.identifiers.set(privateName, { + privateEnv.identifiers.set(privateName, { kind: "a" /* Accessor */, getterName: getterName, setterName: undefined, @@ -89368,7 +91339,7 @@ var ts; previousInfo.setterName = setterName; } else { - env.identifiers.set(privateName, { + privateEnv.identifiers.set(privateName, { kind: "a" /* Accessor */, getterName: undefined, setterName: setterName, @@ -89384,7 +91355,7 @@ var ts; } else if (ts.isPropertyDeclaration(node)) { var weakMapName = createHoistedVariableForPrivateName(text, node); - env.identifiers.set(privateName, { + privateEnv.identifiers.set(privateName, { kind: "f" /* Field */, brandCheckIdentifier: weakMapName, isStatic: false, @@ -89396,7 +91367,7 @@ var ts; } else if (ts.isMethodDeclaration(node)) { ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); - env.identifiers.set(privateName, { + privateEnv.identifiers.set(privateName, { kind: "m" /* Method */, methodName: createHoistedVariableForPrivateName(text, node), brandCheckIdentifier: weakSetName, @@ -89412,7 +91383,7 @@ var ts; previousInfo.getterName = getterName; } else { - env.identifiers.set(privateName, { + privateEnv.identifiers.set(privateName, { kind: "a" /* Accessor */, getterName: getterName, setterName: undefined, @@ -89428,7 +91399,7 @@ var ts; previousInfo.setterName = setterName; } else { - env.identifiers.set(privateName, { + privateEnv.identifiers.set(privateName, { kind: "a" /* Accessor */, getterName: undefined, setterName: setterName, @@ -89460,18 +91431,19 @@ var ts; return createHoistedVariableForClass(privateName.substring(1), node.name); } function accessPrivateIdentifier(name) { - if (currentPrivateIdentifierEnvironment) { - var info = currentPrivateIdentifierEnvironment.identifiers.get(name.escapedText); + var _a; + if (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.privateIdentifierEnvironment) { + var info = currentClassLexicalEnvironment.privateIdentifierEnvironment.identifiers.get(name.escapedText); if (info) { return info; } } - for (var i = privateIdentifierEnvironmentStack.length - 1; i >= 0; --i) { - var env = privateIdentifierEnvironmentStack[i]; + for (var i = classLexicalEnvironmentStack.length - 1; i >= 0; --i) { + var env = classLexicalEnvironmentStack[i]; if (!env) { continue; } - var info = env.identifiers.get(name.escapedText); + var info = (_a = env.privateIdentifierEnvironment) === null || _a === void 0 ? void 0 : _a.identifiers.get(name.escapedText); if (info) { return info; } @@ -89489,53 +91461,93 @@ var ts; // differently inside the function. if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 62 /* EqualsToken */, node.expression)); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); } - return factory.createPropertyAccessExpression( - // Explicit parens required because of v8 regression (https://bugs.chromium.org/p/v8/issues/detail?id=9560) - factory.createParenthesizedExpression(factory.createObjectLiteralExpression([ - factory.createSetAccessorDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, "value", [factory.createParameterDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, parameter, - /*questionToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62 /* EqualsToken */))])) - ])), "value"); + return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */)); } function visitArrayAssignmentTarget(node) { var target = ts.getTargetOfBindingOrAssignmentElement(node); - if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) { - var wrapped = wrapPrivateIdentifierForDestructuringTarget(target); - if (ts.isAssignmentExpression(node)) { - return factory.updateBinaryExpression(node, wrapped, node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); - } - else if (ts.isSpreadElement(node)) { - return factory.updateSpreadElement(node, wrapped); + if (target) { + var wrapped = void 0; + if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { + wrapped = wrapPrivateIdentifierForDestructuringTarget(target); + } + else if (shouldTransformSuperInStaticInitializers && + ts.isSuperProperty(target) && + currentStaticPropertyDeclarationOrStaticBlock && + currentClassLexicalEnvironment) { + var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; + if (facts & 1 /* ClassWasDecorated */) { + wrapped = visitInvalidSuperProperty(target); + } + else if (classConstructor && superClassReference) { + var name = ts.isElementAccessExpression(target) ? ts.visitNode(target.argumentExpression, visitor, ts.isExpression) : + ts.isIdentifier(target.name) ? factory.createStringLiteralFromNode(target.name) : + undefined; + if (name) { + var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); + wrapped = factory.createAssignmentTargetWrapper(temp, factory.createReflectSetCall(superClassReference, name, temp, classConstructor)); + } + } } - else { - return wrapped; + if (wrapped) { + if (ts.isAssignmentExpression(node)) { + return factory.updateBinaryExpression(node, wrapped, node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); + } + else if (ts.isSpreadElement(node)) { + return factory.updateSpreadElement(node, wrapped); + } + else { + return wrapped; + } } } return ts.visitNode(node, visitorDestructuringTarget); } function visitObjectAssignmentTarget(node) { - if (ts.isPropertyAssignment(node)) { + if (ts.isObjectBindingOrAssignmentElement(node) && !ts.isShorthandPropertyAssignment(node)) { var target = ts.getTargetOfBindingOrAssignmentElement(node); - if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) { + var wrapped = void 0; + if (target) { + if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { + wrapped = wrapPrivateIdentifierForDestructuringTarget(target); + } + else if (shouldTransformSuperInStaticInitializers && + ts.isSuperProperty(target) && + currentStaticPropertyDeclarationOrStaticBlock && + currentClassLexicalEnvironment) { + var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; + if (facts & 1 /* ClassWasDecorated */) { + wrapped = visitInvalidSuperProperty(target); + } + else if (classConstructor && superClassReference) { + var name = ts.isElementAccessExpression(target) ? ts.visitNode(target.argumentExpression, visitor, ts.isExpression) : + ts.isIdentifier(target.name) ? factory.createStringLiteralFromNode(target.name) : + undefined; + if (name) { + var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); + wrapped = factory.createAssignmentTargetWrapper(temp, factory.createReflectSetCall(superClassReference, name, temp, classConstructor)); + } + } + } + } + if (ts.isPropertyAssignment(node)) { var initializer = ts.getInitializerOfBindingOrAssignmentElement(node); - var wrapped = wrapPrivateIdentifierForDestructuringTarget(target); - return factory.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), initializer ? factory.createAssignment(wrapped, ts.visitNode(initializer, visitor)) : wrapped); + return factory.updatePropertyAssignment(node, ts.visitNode(node.name, visitor, ts.isPropertyName), wrapped ? + initializer ? factory.createAssignment(wrapped, ts.visitNode(initializer, visitor)) : wrapped : + ts.visitNode(node.initializer, visitorDestructuringTarget, ts.isExpression)); } - return factory.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), ts.visitNode(node.initializer, visitorDestructuringTarget)); + if (ts.isSpreadAssignment(node)) { + return factory.updateSpreadAssignment(node, wrapped || ts.visitNode(node.expression, visitorDestructuringTarget, ts.isExpression)); + } + ts.Debug.assert(wrapped === undefined, "Should not have generated a wrapped target"); } return ts.visitNode(node, visitor); } function visitAssignmentPattern(node) { if (ts.isArrayLiteralExpression(node)) { // Transforms private names in destructuring assignment array bindings. + // Transforms SuperProperty assignments in destructuring assignment array bindings in static initializers. // // Source: // ([ this.#myProp ] = [ "hello" ]); @@ -89546,6 +91558,7 @@ var ts; } else { // Transforms private names in destructuring assignment object bindings. + // Transforms SuperProperty assignments in destructuring assignment object bindings in static initializers. // // Source: // ({ stringProperty: this.#myProp } = { stringProperty: "hello" }); @@ -89659,34 +91672,34 @@ var ts; return node; } switch (node.kind) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 214 /* AwaitExpression */: + case 216 /* AwaitExpression */: return visitAwaitExpression(node); - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 209 /* FunctionExpression */: + case 211 /* FunctionExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 202 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 203 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 205 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 167 /* Constructor */: - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 169 /* Constructor */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -89695,27 +91708,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 238 /* ForStatement */: + case 240 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 240 /* ForOfStatement */: + case 242 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 288 /* CatchClause */: + case 290 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 231 /* Block */: - case 245 /* SwitchStatement */: - case 259 /* CaseBlock */: - case 285 /* CaseClause */: - case 286 /* DefaultClause */: - case 248 /* TryStatement */: - case 236 /* DoStatement */: - case 237 /* WhileStatement */: - case 235 /* IfStatement */: - case 244 /* WithStatement */: - case 246 /* LabeledStatement */: + case 233 /* Block */: + case 247 /* SwitchStatement */: + case 261 /* CaseBlock */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: + case 250 /* TryStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: + case 237 /* IfStatement */: + case 246 /* WithStatement */: + case 248 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -89920,7 +91933,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 210 /* ArrowFunction */; + var isArrowFunction = node.kind === 212 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -90011,17 +92024,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(204 /* CallExpression */); - context.enableSubstitution(202 /* PropertyAccessExpression */); - context.enableSubstitution(203 /* ElementAccessExpression */); + context.enableSubstitution(206 /* CallExpression */); + context.enableSubstitution(204 /* PropertyAccessExpression */); + context.enableSubstitution(205 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(253 /* ClassDeclaration */); - context.enableEmitNotification(166 /* MethodDeclaration */); - context.enableEmitNotification(168 /* GetAccessor */); - context.enableEmitNotification(169 /* SetAccessor */); - context.enableEmitNotification(167 /* Constructor */); + context.enableEmitNotification(255 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(170 /* GetAccessor */); + context.enableEmitNotification(171 /* SetAccessor */); + context.enableEmitNotification(169 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(233 /* VariableStatement */); + context.enableEmitNotification(235 /* VariableStatement */); } } /** @@ -90069,23 +92082,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 204 /* CallExpression */: + case 206 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -90099,17 +92112,17 @@ var ts; return factory.createCallExpression(factory.createPropertyAccessExpression(argumentExpression, "call"), /*typeArguments*/ undefined, __spreadArray([ factory.createThis() - ], node.arguments)); + ], node.arguments, true)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 253 /* ClassDeclaration */ - || kind === 167 /* Constructor */ - || kind === 166 /* MethodDeclaration */ - || kind === 168 /* GetAccessor */ - || kind === 169 /* SetAccessor */; + return kind === 255 /* ClassDeclaration */ + || kind === 169 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 170 /* GetAccessor */ + || kind === 171 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -90266,7 +92279,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 129 /* AsyncKeyword */) { + if (node.kind === 130 /* AsyncKeyword */) { return undefined; } return node; @@ -90292,70 +92305,70 @@ var ts; return node; } switch (node.kind) { - case 214 /* AwaitExpression */: + case 216 /* AwaitExpression */: return visitAwaitExpression(node); - case 220 /* YieldExpression */: + case 222 /* YieldExpression */: return visitYieldExpression(node); - case 243 /* ReturnStatement */: + case 245 /* ReturnStatement */: return visitReturnStatement(node); - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: return visitLabeledStatement(node); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 341 /* CommaListExpression */: + case 346 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 288 /* CatchClause */: + case 290 /* CatchClause */: return visitCatchClause(node); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return visitVariableStatement(node); - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 236 /* DoStatement */: - case 237 /* WhileStatement */: - case 239 /* ForInStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: + case 241 /* ForInStatement */: return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 240 /* ForOfStatement */: + case 242 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ForStatement */: + case 240 /* ForStatement */: return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 213 /* VoidExpression */: + case 215 /* VoidExpression */: return visitVoidExpression(node); - case 167 /* Constructor */: + case 169 /* Constructor */: return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 168 /* GetAccessor */: + case 170 /* GetAccessor */: return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 169 /* SetAccessor */: + case 171 /* SetAccessor */: return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 209 /* FunctionExpression */: + case 211 /* FunctionExpression */: return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 161 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: return visitExpressionStatement(node); - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 202 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 203 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 205 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); @@ -90391,7 +92404,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 240 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 242 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -90403,7 +92416,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 291 /* SpreadAssignment */) { + if (e.kind === 293 /* SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -90412,7 +92425,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 289 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 291 /* PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -90446,7 +92459,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 201 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 203 /* ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -90535,7 +92548,7 @@ var ts; if (ts.some(visitedBindings)) { block = factory.updateBlock(block, __spreadArray([ factory.createVariableStatement(/*modifiers*/ undefined, visitedBindings) - ], block.statements)); + ], block.statements, true)); } return factory.updateCatchClause(node, factory.updateVariableDeclaration(node.variableDeclaration, name, /*exclamationToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined), block); } @@ -90859,17 +92872,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(204 /* CallExpression */); - context.enableSubstitution(202 /* PropertyAccessExpression */); - context.enableSubstitution(203 /* ElementAccessExpression */); + context.enableSubstitution(206 /* CallExpression */); + context.enableSubstitution(204 /* PropertyAccessExpression */); + context.enableSubstitution(205 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(253 /* ClassDeclaration */); - context.enableEmitNotification(166 /* MethodDeclaration */); - context.enableEmitNotification(168 /* GetAccessor */); - context.enableEmitNotification(169 /* SetAccessor */); - context.enableEmitNotification(167 /* Constructor */); + context.enableEmitNotification(255 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(170 /* GetAccessor */); + context.enableEmitNotification(171 /* SetAccessor */); + context.enableEmitNotification(169 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(233 /* VariableStatement */); + context.enableEmitNotification(235 /* VariableStatement */); } } /** @@ -90917,23 +92930,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 204 /* CallExpression */: + case 206 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -90947,17 +92960,17 @@ var ts; return factory.createCallExpression(factory.createPropertyAccessExpression(argumentExpression, "call"), /*typeArguments*/ undefined, __spreadArray([ factory.createThis() - ], node.arguments)); + ], node.arguments, true)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 253 /* ClassDeclaration */ - || kind === 167 /* Constructor */ - || kind === 166 /* MethodDeclaration */ - || kind === 168 /* GetAccessor */ - || kind === 169 /* SetAccessor */; + return kind === 255 /* ClassDeclaration */ + || kind === 169 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 170 /* GetAccessor */ + || kind === 171 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -90989,7 +93002,7 @@ var ts; return node; } switch (node.kind) { - case 288 /* CatchClause */: + case 290 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -91021,25 +93034,25 @@ var ts; return node; } switch (node.kind) { - case 204 /* CallExpression */: { + case 206 /* CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 211 /* DeleteExpression */: + case 213 /* DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -91081,7 +93094,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 202 /* PropertyAccessExpression */ + expression = node.kind === 204 /* PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -91104,10 +93117,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 208 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 204 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 210 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 206 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -91126,8 +93139,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -91137,13 +93150,13 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 202 /* PropertyAccessExpression */ + rightExpression = segment.kind === 204 /* PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 204 /* CallExpression */: + case 206 /* CallExpression */: if (i === 0 && leftThisArg) { - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -91198,7 +93211,7 @@ var ts; return node; } switch (node.kind) { - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -91367,13 +93380,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 274 /* JsxElement */: + case 276 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 275 /* JsxSelfClosingElement */: + case 277 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 278 /* JsxFragment */: + case 280 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 284 /* JsxExpression */: + case 286 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -91383,13 +93396,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 284 /* JsxExpression */: + case 286 /* JsxExpression */: return visitJsxExpression(node); - case 274 /* JsxElement */: + case 276 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 275 /* JsxSelfClosingElement */: + case 277 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 278 /* JsxFragment */: + case 280 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -91429,9 +93442,9 @@ var ts; function convertJsxChildrenToChildrenPropObject(children) { var nonWhitespaceChildren = ts.getSemanticJsxChildren(children); if (ts.length(nonWhitespaceChildren) === 1) { - var result_14 = transformJsxChildToExpression(nonWhitespaceChildren[0]); - return result_14 && factory.createObjectLiteralExpression([ - factory.createPropertyAssignment("children", result_14) + var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]); + return result_13 && factory.createObjectLiteralExpression([ + factory.createPropertyAssignment("children", result_13) ]); } var result = ts.mapDefined(children, transformJsxChildToExpression); @@ -91583,7 +93596,7 @@ var ts; var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 284 /* JsxExpression */) { + else if (node.kind === 286 /* JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -91677,7 +93690,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 274 /* JsxElement */) { + if (node.kind === 276 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -91983,7 +93996,7 @@ var ts; return node; } switch (node.kind) { - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -91991,7 +94004,7 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); @@ -92080,12 +94093,13 @@ var ts; HierarchyFacts[HierarchyFacts["ForStatement"] = 2048] = "ForStatement"; HierarchyFacts[HierarchyFacts["ForInOrForOfStatement"] = 4096] = "ForInOrForOfStatement"; HierarchyFacts[HierarchyFacts["ConstructorWithCapturedSuper"] = 8192] = "ConstructorWithCapturedSuper"; + HierarchyFacts[HierarchyFacts["StaticInitializer"] = 16384] = "StaticInitializer"; // NOTE: do not add more ancestor flags without also updating AncestorFactsMask below. // NOTE: when adding a new ancestor flag, be sure to update the subtree flags below. // // Ancestor masks // - HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 16383] = "AncestorFactsMask"; + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 32767] = "AncestorFactsMask"; // We are always in *some* kind of block scope, but only specific block-scope containers are // top-level or Blocks. HierarchyFacts[HierarchyFacts["BlockScopeIncludes"] = 0] = "BlockScopeIncludes"; @@ -92095,16 +94109,16 @@ var ts; HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 8064] = "SourceFileExcludes"; // Functions, methods, and accessors are both new lexical scopes and new block scopes. HierarchyFacts[HierarchyFacts["FunctionIncludes"] = 65] = "FunctionIncludes"; - HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 16286] = "FunctionExcludes"; + HierarchyFacts[HierarchyFacts["FunctionExcludes"] = 32670] = "FunctionExcludes"; HierarchyFacts[HierarchyFacts["AsyncFunctionBodyIncludes"] = 69] = "AsyncFunctionBodyIncludes"; - HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 16278] = "AsyncFunctionBodyExcludes"; + HierarchyFacts[HierarchyFacts["AsyncFunctionBodyExcludes"] = 32662] = "AsyncFunctionBodyExcludes"; // Arrow functions are lexically scoped to their container, but are new block scopes. HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 66] = "ArrowFunctionIncludes"; HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 15232] = "ArrowFunctionExcludes"; // Constructors are both new lexical scopes and new block scopes. Constructors are also // always considered non-static members of a class. HierarchyFacts[HierarchyFacts["ConstructorIncludes"] = 73] = "ConstructorIncludes"; - HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 16278] = "ConstructorExcludes"; + HierarchyFacts[HierarchyFacts["ConstructorExcludes"] = 32662] = "ConstructorExcludes"; // 'do' and 'while' statements are not block scopes. We track that the subtree is contained // within an IterationStatement to indicate whether the embedded statement is an // IterationStatementBlock. @@ -92122,18 +94136,29 @@ var ts; HierarchyFacts[HierarchyFacts["BlockExcludes"] = 6976] = "BlockExcludes"; HierarchyFacts[HierarchyFacts["IterationStatementBlockIncludes"] = 512] = "IterationStatementBlockIncludes"; HierarchyFacts[HierarchyFacts["IterationStatementBlockExcludes"] = 7104] = "IterationStatementBlockExcludes"; + HierarchyFacts[HierarchyFacts["StaticInitializerIncludes"] = 16449] = "StaticInitializerIncludes"; + HierarchyFacts[HierarchyFacts["StaticInitializerExcludes"] = 32670] = "StaticInitializerExcludes"; // // Subtree facts // - HierarchyFacts[HierarchyFacts["NewTarget"] = 16384] = "NewTarget"; - HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 32768] = "CapturedLexicalThis"; + HierarchyFacts[HierarchyFacts["NewTarget"] = 32768] = "NewTarget"; + HierarchyFacts[HierarchyFacts["CapturedLexicalThis"] = 65536] = "CapturedLexicalThis"; // // Subtree masks // - HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -16384] = "SubtreeFactsMask"; + HierarchyFacts[HierarchyFacts["SubtreeFactsMask"] = -32768] = "SubtreeFactsMask"; HierarchyFacts[HierarchyFacts["ArrowFunctionSubtreeExcludes"] = 0] = "ArrowFunctionSubtreeExcludes"; - HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 49152] = "FunctionSubtreeExcludes"; + HierarchyFacts[HierarchyFacts["FunctionSubtreeExcludes"] = 98304] = "FunctionSubtreeExcludes"; })(HierarchyFacts || (HierarchyFacts = {})); + var SpreadSegmentKind; + (function (SpreadSegmentKind) { + SpreadSegmentKind[SpreadSegmentKind["None"] = 0] = "None"; + SpreadSegmentKind[SpreadSegmentKind["UnpackedSpread"] = 1] = "UnpackedSpread"; + SpreadSegmentKind[SpreadSegmentKind["PackedSpread"] = 2] = "PackedSpread"; + })(SpreadSegmentKind || (SpreadSegmentKind = {})); + function createSpreadSegment(kind, expression) { + return { kind: kind, expression: expression }; + } function transformES2015(context) { var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); @@ -92181,7 +94206,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */; return ancestorFacts; } /** @@ -92192,11 +94217,11 @@ var ts; * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 243 /* ReturnStatement */ + && node.kind === 245 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { @@ -92227,75 +94252,88 @@ var ts; function visitorWithUnusedExpressionResult(node) { return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ true) : node; } + function classWrapperStatementVisitor(node) { + if (shouldVisitNode(node)) { + var original = ts.getOriginalNode(node); + if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) { + var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */); + var result = visitorWorker(node, /*expressionResultIsUnused*/ false); + exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + return result; + } + return visitorWorker(node, /*expressionResultIsUnused*/ false); + } + return node; + } function callExpressionVisitor(node) { - if (node.kind === 105 /* SuperKeyword */) { + if (node.kind === 106 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return undefined; // elide static keyword - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: return visitClassDeclaration(node); - case 222 /* ClassExpression */: + case 224 /* ClassExpression */: return visitClassExpression(node); - case 161 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return visitArrowFunction(node); - case 209 /* FunctionExpression */: + case 211 /* FunctionExpression */: return visitFunctionExpression(node); - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 78 /* Identifier */: + case 79 /* Identifier */: return visitIdentifier(node); - case 251 /* VariableDeclarationList */: + case 253 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: return visitSwitchStatement(node); - case 259 /* CaseBlock */: + case 261 /* CaseBlock */: return visitCaseBlock(node); - case 231 /* Block */: + case 233 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 242 /* BreakStatement */: - case 241 /* ContinueStatement */: + case 244 /* BreakStatement */: + case 243 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: return visitLabeledStatement(node); - case 236 /* DoStatement */: - case 237 /* WhileStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ForStatement */: + case 240 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 240 /* ForOfStatement */: + case 242 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: return visitExpressionStatement(node); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 288 /* CatchClause */: + case 290 /* CatchClause */: return visitCatchClause(node); - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 204 /* CallExpression */: + case 206 /* CallExpression */: return visitCallExpression(node); - case 205 /* NewExpression */: + case 207 /* NewExpression */: return visitNewExpression(node); - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 341 /* CommaListExpression */: + case 346 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -92306,30 +94344,30 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 219 /* TemplateExpression */: + case 221 /* TemplateExpression */: return visitTemplateExpression(node); - case 220 /* YieldExpression */: + case 222 /* YieldExpression */: return visitYieldExpression(node); - case 221 /* SpreadElement */: + case 223 /* SpreadElement */: return visitSpreadElement(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return visitThisKeyword(node); - case 227 /* MetaProperty */: + case 229 /* MetaProperty */: return visitMetaProperty(node); - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return visitAccessorDeclaration(node); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return visitVariableStatement(node); - case 243 /* ReturnStatement */: + case 245 /* ReturnStatement */: return visitReturnStatement(node); - case 213 /* VoidExpression */: + case 215 /* VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -92388,8 +94426,8 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - if (hierarchyFacts & 2 /* ArrowFunction */) { - hierarchyFacts |= 32768 /* CapturedLexicalThis */; + if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { + hierarchyFacts |= 65536 /* CapturedLexicalThis */; } if (convertedLoopState) { if (hierarchyFacts & 2 /* ArrowFunction */) { @@ -92419,14 +94457,14 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 242 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 244 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 242 /* BreakStatement */) { + if (node.kind === 244 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -92437,7 +94475,7 @@ var ts; } } else { - if (node.kind === 242 /* BreakStatement */) { + if (node.kind === 244 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -92634,7 +94672,7 @@ var ts; function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(16278 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); + var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = factory.createFunctionDeclaration( @@ -92648,7 +94686,7 @@ var ts; ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; } /** @@ -92697,7 +94735,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -92835,11 +94873,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 243 /* ReturnStatement */) { + if (statement.kind === 245 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 235 /* IfStatement */) { + else if (statement.kind === 237 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -92847,7 +94885,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 231 /* Block */) { + else if (statement.kind === 233 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -93005,10 +95043,10 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. // TODO(rbuckton): Does this need to be parented? - var declarationName = parameter.name.kind === 78 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 78 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -93033,7 +95071,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 78 /* Identifier */) { + if (parameter.name.kind !== 79 /* Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); @@ -93049,7 +95087,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 210 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 212 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -93068,28 +95106,28 @@ var ts; ts.insertStatementAfterCustomPrologue(statements, captureThisStatement); } function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { - if (hierarchyFacts & 16384 /* NewTarget */) { + if (hierarchyFacts & 32768 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return statements; - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 167 /* Constructor */: + case 169 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 101 /* InstanceOfKeyword */, factory.getLocalName(node))), + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"), /*colonToken*/ undefined, factory.createVoidZero()); break; @@ -93121,20 +95159,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 230 /* SemicolonClassElement */: + case 232 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 167 /* Constructor */: + case 169 /* Constructor */: + case 168 /* ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -93255,8 +95294,8 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 8192 /* ContainsLexicalThis */) { - hierarchyFacts |= 32768 /* CapturedLexicalThis */; + if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { + hierarchyFacts |= 65536 /* CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; @@ -93270,9 +95309,6 @@ var ts; ts.setTextRange(func, node); ts.setOriginalNode(func, node); ts.setEmitFlags(func, 8 /* CapturesThis */); - if (hierarchyFacts & 32768 /* CapturedLexicalThis */) { - enableSubstitutionsForCapturedThis(); - } // If an arrow function contains exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; @@ -93285,16 +95321,16 @@ var ts; */ function visitFunctionExpression(node) { var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ - ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) - : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) + : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 16384 /* NewTarget */ + var name = hierarchyFacts & 32768 /* NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionExpression(node, /*modifiers*/ undefined, node.asteriskToken, name, @@ -93309,13 +95345,13 @@ var ts; function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 16384 /* NewTarget */ + var name = hierarchyFacts & 32768 /* NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration(node, /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, @@ -93332,15 +95368,15 @@ var ts; function transformFunctionLikeToExpression(node, location, name, container) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = container && ts.isClassLike(container) && !ts.hasSyntacticModifier(node, 32 /* Static */) - ? enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) - : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node) + ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) + : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 252 /* FunctionDeclaration */ || node.kind === 209 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 254 /* FunctionDeclaration */ || node.kind === 211 /* FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, @@ -93383,7 +95419,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 210 /* ArrowFunction */); + ts.Debug.assert(node.kind === 212 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -93518,7 +95554,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = factory.createBinaryExpression(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -93690,14 +95726,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 236 /* DoStatement */: - case 237 /* WhileStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 238 /* ForStatement */: + case 240 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 240 /* ForOfStatement */: + case 242 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -93883,7 +95919,7 @@ var ts; var property = properties[i]; if ((property.transformFlags & 524288 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 159 /* ComputedPropertyName */)) { + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 160 /* ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -93935,7 +95971,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -93999,11 +96035,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 238 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 239 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 240 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 236 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 237 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 240 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 241 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 242 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 238 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 239 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -94028,11 +96064,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 251 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 253 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -94303,7 +96339,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 62 /* EqualsToken */, source); + return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -94440,20 +96476,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -94529,7 +96565,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return factory.updateBlock(block, __spreadArray([statement], transformedStatements)); + return factory.updateBlock(block, __spreadArray([statement], transformedStatements, true)); } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a @@ -94556,17 +96592,17 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 168 /* GetAccessor */) { + if (node.kind === 170 /* GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -94599,7 +96635,7 @@ var ts; function visitArrayLiteralExpression(node) { if (ts.some(node.elements, ts.isSpreadElement)) { // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, !!node.multiLine, /*hasTrailingComma*/ !!node.elements.hasTrailingComma); + return transformAndSpreadElements(node.elements, /*isArgumentList*/ false, !!node.multiLine, /*hasTrailingComma*/ !!node.elements.hasTrailingComma); } return ts.visitEachChild(node, visitor, context); } @@ -94613,7 +96649,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 105 /* SuperKeyword */ || + if (expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -94661,7 +96697,7 @@ var ts; // visit the class body statements outside of any converted loop body. var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement); + var bodyStatements = ts.visitNodes(body.statements, classWrapperStatementVisitor, ts.isStatement); convertedLoopState = savedConvertedLoopState; var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer); var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); }); @@ -94686,6 +96722,9 @@ var ts; // }()) // var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); + if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) { + aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression); + } // The underlying call (3) is another IIFE that may contain a '_super' argument. var call = ts.cast(aliasAssignment ? ts.skipOuterExpressions(aliasAssignment.right) : initializer, ts.isCallExpression); var func = ts.cast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression); @@ -94741,10 +96780,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || - node.expression.kind === 105 /* SuperKeyword */ || + node.expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -94762,7 +96801,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 105 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -94774,9 +96813,9 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 105 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); + resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) @@ -94800,7 +96839,7 @@ var ts; // [output] // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() var _a = factory.createCallBinding(factory.createPropertyAccessExpression(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return factory.createNewExpression(factory.createFunctionApplyCall(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(factory.createNodeArray(__spreadArray([factory.createVoidZero()], node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + return factory.createNewExpression(factory.createFunctionApplyCall(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(factory.createNodeArray(__spreadArray([factory.createVoidZero()], node.arguments, true)), /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)), /*typeArguments*/ undefined, []); } return ts.visitEachChild(node, visitor, context); @@ -94809,12 +96848,12 @@ var ts; * Transforms an array of Expression nodes that contains a SpreadExpression. * * @param elements The array of Expression nodes. - * @param needsUniqueCopy A value indicating whether to ensure that the result is a fresh array. - * This should be `true` when spreading into an `ArrayLiteral`, and `false` when spreading into an + * @param isArgumentList A value indicating whether to ensure that the result is a fresh array. + * This should be `false` when spreading into an `ArrayLiteral`, and `true` when spreading into an * argument list. * @param multiLine A value indicating whether the result should be emitted on multiple lines. */ - function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { + function transformAndSpreadElements(elements, isArgumentList, multiLine, hasTrailingComma) { // When there is no leading SpreadElement: // // [source] @@ -94848,7 +96887,11 @@ var ts; // Map spans of spread expressions into their expressions and spans of other // expressions into an array literal. var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { + var segments = ts.flatten( + // As we visit each element, we return one of two functions to use as the "key": + // - `visitSpanOfSpreads` for one or more contiguous `...` spread expressions, i.e. `...a, ...b` in `[1, 2, ...a, ...b]` + // - `visitSpanOfNonSpreads` for one or more contiguous non-spread elements, i.e. `1, 2`, in `[1, 2, ...a, ...b]` + ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); if (segments.length === 1) { @@ -94857,20 +96900,20 @@ var ts; // a CallExpression or NewExpression. When using `--downlevelIteration`, we need // to coerce this into an array for use with `apply`, so we will use the code path // that follows instead. - if (!needsUniqueCopy && !compilerOptions.downlevelIteration - || ts.isPackedArrayLiteral(firstSegment) // see NOTE (above) - || ts.isCallToHelper(firstSegment, "___spreadArray")) { - return segments[0]; + if (isArgumentList && !compilerOptions.downlevelIteration + || ts.isPackedArrayLiteral(firstSegment.expression) // see NOTE (above) + || ts.isCallToHelper(firstSegment.expression, "___spreadArray")) { + return firstSegment.expression; } } var helpers = emitHelpers(); - var startsWithSpread = ts.isSpreadElement(elements[0]); + var startsWithSpread = segments[0].kind !== 0 /* None */; var expression = startsWithSpread ? factory.createArrayLiteralExpression() : - segments[0]; + segments[0].expression; for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) { - expression = helpers.createSpreadArrayHelper(expression, compilerOptions.downlevelIteration && !ts.isPackedArrayLiteral(segments[i]) ? // see NOTE (above) - helpers.createReadHelper(segments[i], /*count*/ undefined) : - segments[i]); + var segment = segments[i]; + // If this is for an argument list, it doesn't matter if the array is packed or sparse + expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList); } return expression; } @@ -94882,20 +96925,28 @@ var ts; function visitSpanOfSpreads(chunk) { return ts.map(chunk, visitExpressionOfSpread); } + function visitExpressionOfSpread(node) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + // We don't need to pack already packed array literals, or existing calls to the `__read` helper. + var isCallToReadHelper = ts.isCallToHelper(expression, "___read"); + var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */; + // We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`. + if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { + expression = emitHelpers().createReadHelper(expression, /*count*/ undefined); + // the `__read` helper returns a packed array, so we don't need to ensure a packed array + kind = 2 /* PackedSpread */; + } + return createSpreadSegment(kind, expression); + } function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { - return factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); + var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); + // We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to + // `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements` + return createSpreadSegment(0 /* None */, expression); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } - /** - * Transforms the expression of a SpreadExpression node. - * - * @param node A SpreadExpression node. - */ - function visitExpressionOfSpread(node) { - return ts.visitNode(node.expression, visitor, ts.isExpression); - } /** * Visits a template literal. * @@ -95023,8 +97074,8 @@ var ts; : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 102 /* NewKeyword */ && node.name.escapedText === "target") { - hierarchyFacts |= 16384 /* NewTarget */; + if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { + hierarchyFacts |= 32768 /* NewTarget */; return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); } return node; @@ -95039,7 +97090,7 @@ var ts; function onEmitNode(hint, node, emitCallback) { if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ + var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ : 65 /* FunctionIncludes */); previousOnEmitNode(hint, node, emitCallback); @@ -95055,7 +97106,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } /** @@ -95065,14 +97116,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(107 /* ThisKeyword */); - context.enableEmitNotification(167 /* Constructor */); - context.enableEmitNotification(166 /* MethodDeclaration */); - context.enableEmitNotification(168 /* GetAccessor */); - context.enableEmitNotification(169 /* SetAccessor */); - context.enableEmitNotification(210 /* ArrowFunction */); - context.enableEmitNotification(209 /* FunctionExpression */); - context.enableEmitNotification(252 /* FunctionDeclaration */); + context.enableSubstitution(108 /* ThisKeyword */); + context.enableEmitNotification(169 /* Constructor */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(170 /* GetAccessor */); + context.enableEmitNotification(171 /* SetAccessor */); + context.enableEmitNotification(212 /* ArrowFunction */); + context.enableEmitNotification(211 /* FunctionExpression */); + context.enableEmitNotification(254 /* FunctionDeclaration */); } } /** @@ -95113,10 +97164,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 199 /* BindingElement */: - case 253 /* ClassDeclaration */: - case 256 /* EnumDeclaration */: - case 250 /* VariableDeclaration */: + case 201 /* BindingElement */: + case 255 /* ClassDeclaration */: + case 258 /* EnumDeclaration */: + case 252 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -95129,9 +97180,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -95186,7 +97237,7 @@ var ts; return node; } function getClassMemberPrefix(node, member) { - return ts.hasSyntacticModifier(member, 32 /* Static */) + return ts.isStatic(member) ? factory.getInternalName(node) : factory.createPropertyAccessExpression(factory.getInternalName(node), "prototype"); } @@ -95198,19 +97249,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 234 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 236 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 204 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 206 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 105 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 221 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 223 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -95236,15 +97287,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(276 /* JsxOpeningElement */); - context.enableEmitNotification(277 /* JsxClosingElement */); - context.enableEmitNotification(275 /* JsxSelfClosingElement */); + context.enableEmitNotification(278 /* JsxOpeningElement */); + context.enableEmitNotification(279 /* JsxClosingElement */); + context.enableEmitNotification(277 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(202 /* PropertyAccessExpression */); - context.enableSubstitution(289 /* PropertyAssignment */); + context.enableSubstitution(204 /* PropertyAccessExpression */); + context.enableSubstitution(291 /* PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -95263,9 +97314,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 276 /* JsxOpeningElement */: - case 277 /* JsxClosingElement */: - case 275 /* JsxSelfClosingElement */: + case 278 /* JsxOpeningElement */: + case 279 /* JsxClosingElement */: + case 277 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -95325,7 +97376,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -95600,13 +97651,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 236 /* DoStatement */: + case 238 /* DoStatement */: return visitDoStatement(node); - case 237 /* WhileStatement */: + case 239 /* WhileStatement */: return visitWhileStatement(node); - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: return visitSwitchStatement(node); - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -95619,24 +97670,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 209 /* FunctionExpression */: + case 211 /* FunctionExpression */: return visitFunctionExpression(node); - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return visitAccessorDeclaration(node); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return visitVariableStatement(node); - case 238 /* ForStatement */: + case 240 /* ForStatement */: return visitForStatement(node); - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: return visitForInStatement(node); - case 242 /* BreakStatement */: + case 244 /* BreakStatement */: return visitBreakStatement(node); - case 241 /* ContinueStatement */: + case 243 /* ContinueStatement */: return visitContinueStatement(node); - case 243 /* ReturnStatement */: + case 245 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 524288 /* ContainsYield */) { @@ -95657,23 +97708,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return visitBinaryExpression(node); - case 341 /* CommaListExpression */: + case 346 /* CommaListExpression */: return visitCommaListExpression(node); - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: return visitConditionalExpression(node); - case 220 /* YieldExpression */: + case 222 /* YieldExpression */: return visitYieldExpression(node); - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 204 /* CallExpression */: + case 206 /* CallExpression */: return visitCallExpression(node); - case 205 /* NewExpression */: + case 207 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -95686,9 +97737,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 209 /* FunctionExpression */: + case 211 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -95896,7 +97947,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -95908,7 +97959,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -96155,13 +98206,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, factory.createArrayLiteralExpression(leadingElement - ? __spreadArray([leadingElement], initialElements) : initialElements)); + ? __spreadArray([leadingElement], initialElements, true) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? factory.createArrayConcatCall(temp, [factory.createArrayLiteralExpression(expressions, multiLine)]) - : ts.setTextRange(factory.createArrayLiteralExpression(leadingElement ? __spreadArray([leadingElement], expressions) : expressions, multiLine), location); + : ts.setTextRange(factory.createArrayLiteralExpression(leadingElement ? __spreadArray([leadingElement], expressions, true) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -96170,7 +98221,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? factory.createArrayConcatCall(temp, [factory.createArrayLiteralExpression(expressions, multiLine)]) - : factory.createArrayLiteralExpression(leadingElement ? __spreadArray([leadingElement], expressions) : expressions, multiLine)); + : factory.createArrayLiteralExpression(leadingElement ? __spreadArray([leadingElement], expressions, true) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -96302,35 +98353,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 231 /* Block */: + case 233 /* Block */: return transformAndEmitBlock(node); - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 235 /* IfStatement */: + case 237 /* IfStatement */: return transformAndEmitIfStatement(node); - case 236 /* DoStatement */: + case 238 /* DoStatement */: return transformAndEmitDoStatement(node); - case 237 /* WhileStatement */: + case 239 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 238 /* ForStatement */: + case 240 /* ForStatement */: return transformAndEmitForStatement(node); - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 241 /* ContinueStatement */: + case 243 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 242 /* BreakStatement */: + case 244 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 243 /* ReturnStatement */: + case 245 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 244 /* WithStatement */: + case 246 /* WithStatement */: return transformAndEmitWithStatement(node); - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 247 /* ThrowStatement */: + case 249 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 248 /* TryStatement */: + case 250 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -96760,7 +98811,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 286 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 288 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -96773,7 +98824,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 285 /* CaseClause */) { + if (clause.kind === 287 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -97087,7 +99138,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -97933,17 +99984,17 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(217 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(215 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(216 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(290 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(298 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(206 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(208 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(219 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(292 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(300 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. var currentModuleInfo; // The ExternalModuleInfo for the current file. - var noSubstitution; // Set of nodes for which substitution rules should be ignored. + var noSubstitution = []; // Set of nodes for which substitution rules should be ignored. var needUMDDynamicImportHelper; return ts.chainBundle(context, transformSourceFile); /** @@ -97984,7 +100035,7 @@ var ts; startLexicalEnvironment(); var statements = []; var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); - var statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict && !ts.isJsonSourceFile(node), sourceElementVisitor); + var statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict && !ts.isJsonSourceFile(node), topLevelVisitor); if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } @@ -97994,8 +100045,8 @@ var ts; ts.append(statements, factory.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames.slice(i, i + chunkSize), function (prev, nextId) { return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts.idText(nextId))), prev); }, factory.createVoidZero()))); } } - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts.isStatement)); + ts.addRange(statements, ts.visitNodes(node.statements, topLevelVisitor, ts.isStatement, statementOffset)); addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(statements), node.statements)); @@ -98037,14 +100088,14 @@ var ts; // define(mofactory.updateSourceFile", "module2"], function ... var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([ factory.createExpressionStatement(factory.createCallExpression(define, - /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : [])), [ + /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] factory.createArrayLiteralExpression(jsonSourceFile ? ts.emptyArray : __spreadArray(__spreadArray([ factory.createStringLiteral("require"), factory.createStringLiteral("exports") - ], aliasedModuleNames), unaliasedModuleNames)), + ], aliasedModuleNames, true), unaliasedModuleNames, true)), // Add the module body function argument: // // function (require, exports, module1, module2) ... @@ -98057,9 +100108,9 @@ var ts; /*typeParameters*/ undefined, __spreadArray([ factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ], importAliasNames), + ], importAliasNames, true), /*type*/ undefined, transformAsynchronousModuleBody(node)) - ]))) + ], false))) ]), /*location*/ node.statements)); ts.addEmitHelpers(updated, context.readEmitHelpers()); @@ -98093,13 +100144,13 @@ var ts; ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), - /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : [])), [ + /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ factory.createArrayLiteralExpression(__spreadArray(__spreadArray([ factory.createStringLiteral("require"), factory.createStringLiteral("exports") - ], aliasedModuleNames), unaliasedModuleNames)), + ], aliasedModuleNames, true), unaliasedModuleNames, true)), factory.createIdentifier("factory") - ]))) + ], false))) ]))) ], /*multiLine*/ true), @@ -98128,7 +100179,7 @@ var ts; /*typeParameters*/ undefined, __spreadArray([ factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ], importAliasNames), + ], importAliasNames, true), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), @@ -98205,7 +100256,7 @@ var ts; function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = factory.copyPrologue(node.statements, statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + var statementOffset = factory.copyPrologue(node.statements, statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, topLevelVisitor); if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } @@ -98213,11 +100264,11 @@ var ts; ts.append(statements, factory.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts.idText(nextId))), prev); }, factory.createVoidZero()))); } // Visit each statement of the module body. - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts.isStatement)); if (moduleKind === ts.ModuleKind.AMD) { ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport)); } - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, ts.visitNodes(node.statements, topLevelVisitor, ts.isStatement, statementOffset)); // Append the 'export =' statement if provided. addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); // End the lexical environment for the module body @@ -98239,7 +100290,7 @@ var ts; */ function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { - var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, moduleExpressionElementVisitor); + var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, visitor); if (expressionResult) { if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); @@ -98264,69 +100315,90 @@ var ts; * * @param node The node to visit. */ - function sourceElementVisitor(node) { + function topLevelVisitor(node) { switch (node.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return visitImportDeclaration(node); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: return visitExportDeclaration(node); - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: return visitExportAssignment(node); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return visitVariableStatement(node); - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: return visitClassDeclaration(node); - case 342 /* MergeDeclarationMarker */: + case 347 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 343 /* EndOfDeclarationMarker */: + case 348 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: - return ts.visitEachChild(node, moduleExpressionElementVisitor, context); + return visitor(node); } } - function moduleExpressionElementVisitor(node) { - // This visitor does not need to descend into the tree if there is no dynamic import or destructuring assignment, + function visitorWorker(node, valueIsDiscarded) { + // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & 4194304 /* ContainsDynamicImport */) && !(node.transformFlags & 2048 /* ContainsDestructuringAssignment */)) { + if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 2048 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { return node; } - if (ts.isImportCall(node)) { - return visitImportCallExpression(node); - } - else if (ts.isDestructuringAssignment(node)) { - return visitDestructuringAssignment(node); - } - else { - return ts.visitEachChild(node, moduleExpressionElementVisitor, context); + switch (node.kind) { + case 240 /* ForStatement */: + return visitForStatement(node); + case 236 /* ExpressionStatement */: + return visitExpressionStatement(node); + case 210 /* ParenthesizedExpression */: + return visitParenthesizedExpression(node, valueIsDiscarded); + case 345 /* PartiallyEmittedExpression */: + return visitPartiallyEmittedExpression(node, valueIsDiscarded); + case 206 /* CallExpression */: + if (ts.isImportCall(node)) { + return visitImportCallExpression(node); + } + break; + case 219 /* BinaryExpression */: + if (ts.isDestructuringAssignment(node)) { + return visitDestructuringAssignment(node, valueIsDiscarded); + } + break; + case 217 /* PrefixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: + return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + return visitorWorker(node, /*valueIsDiscarded*/ false); + } + function discardedValueVisitor(node) { + return visitorWorker(node, /*valueIsDiscarded*/ true); } function destructuringNeedsFlattening(node) { if (ts.isObjectLiteralExpression(node)) { for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 291 /* SpreadAssignment */: + case 293 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -98350,15 +100422,75 @@ var ts; } return false; } - function visitDestructuringAssignment(node) { + function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { - return ts.flattenDestructuringAssignment(node, moduleExpressionElementVisitor, context, 0 /* All */, /*needsValue*/ false, createAllExportExpressions); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); } - return ts.visitEachChild(node, moduleExpressionElementVisitor, context); + return ts.visitEachChild(node, visitor, context); + } + function visitForStatement(node) { + return factory.updateForStatement(node, ts.visitNode(node.initializer, discardedValueVisitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, discardedValueVisitor, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); + } + function visitExpressionStatement(node) { + return factory.updateExpressionStatement(node, ts.visitNode(node.expression, discardedValueVisitor, ts.isExpression)); + } + function visitParenthesizedExpression(node, valueIsDiscarded) { + return factory.updateParenthesizedExpression(node, ts.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts.isExpression)); + } + function visitPartiallyEmittedExpression(node, valueIsDiscarded) { + return factory.updatePartiallyEmittedExpression(node, ts.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts.isExpression)); + } + function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { + // When we see a prefix or postfix increment expression whose operand is an exported + // symbol, we should ensure all exports of that symbol are updated with the correct + // value. + // + // - We do not transform generated identifiers for any reason. + // - We do not transform identifiers tagged with the LocalName flag. + // - We do not transform identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only transform identifiers that are exported at the top level. + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var temp = void 0; + var expression = ts.visitNode(node.operand, visitor, ts.isExpression); + if (ts.isPrefixUnaryExpression(node)) { + expression = factory.updatePrefixUnaryExpression(node, expression); + } + else { + expression = factory.updatePostfixUnaryExpression(node, expression); + if (!valueIsDiscarded) { + temp = factory.createTempVariable(hoistVariableDeclaration); + expression = factory.createAssignment(temp, expression); + ts.setTextRange(expression, node); + } + expression = factory.createComma(expression, factory.cloneNode(node.operand)); + ts.setTextRange(expression, node); + } + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); + ts.setTextRange(expression, node); + } + if (temp) { + noSubstitution[ts.getNodeId(expression)] = true; + expression = factory.createComma(expression, temp); + ts.setTextRange(expression, node); + } + return expression; + } + } + return ts.visitEachChild(node, visitor, context); } function visitImportCallExpression(node) { var externalModuleName = ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions); - var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor); + var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); @@ -98690,10 +100822,10 @@ var ts; if (original && hasAssociatedEndOfDeclarationMarker(original)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), /*location*/ node, /*allowComments*/ true); + deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), ts.visitNode(node.expression, visitor), /*location*/ node, /*allowComments*/ true); } else { - statements = appendExportStatement(statements, factory.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), /*location*/ node, /*allowComments*/ true); + statements = appendExportStatement(statements, factory.createIdentifier("default"), ts.visitNode(node.expression, visitor), /*location*/ node, /*allowComments*/ true); } return ts.singleOrMany(statements); } @@ -98707,13 +100839,13 @@ var ts; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, ts.visitNodes(node.parameters, moduleExpressionElementVisitor), - /*type*/ undefined, ts.visitEachChild(node.body, moduleExpressionElementVisitor, context)), + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), + /*type*/ undefined, ts.visitEachChild(node.body, visitor, context)), /*location*/ node), /*original*/ node)); } else { - statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context)); + statements = ts.append(statements, ts.visitEachChild(node, visitor, context)); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -98735,10 +100867,10 @@ var ts; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration( /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, moduleExpressionElementVisitor), ts.visitNodes(node.members, moduleExpressionElementVisitor)), node), node)); + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); } else { - statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context)); + statements = ts.append(statements, ts.visitEachChild(node, visitor, context)); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -98775,7 +100907,7 @@ var ts; if (!ts.isBindingPattern(variable.name) && (ts.isArrowFunction(variable.initializer) || ts.isFunctionExpression(variable.initializer) || ts.isClassExpression(variable.initializer))) { var expression = factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), /*location*/ variable.name), factory.createIdentifier(ts.getTextOfIdentifierOrLiteral(variable.name))); - var updatedVariable = factory.createVariableDeclaration(variable.name, variable.exclamationToken, variable.type, ts.visitNode(variable.initializer, moduleExpressionElementVisitor)); + var updatedVariable = factory.createVariableDeclaration(variable.name, variable.exclamationToken, variable.type, ts.visitNode(variable.initializer, visitor)); variables = ts.append(variables, updatedVariable); expressions = ts.append(expressions, expression); removeCommentsOnExpressions = true; @@ -98797,7 +100929,7 @@ var ts; } } else { - statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context)); + statements = ts.append(statements, ts.visitEachChild(node, visitor, context)); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -98814,8 +100946,8 @@ var ts; if (exportedNames) { // For each additional export of the declaration, apply an export assignment. var expression = ts.isExportName(name) ? value : factory.createAssignment(name, value); - for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { - var exportName = exportedNames_1[_i]; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. ts.setEmitFlags(expression, 4 /* NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); @@ -98831,13 +100963,13 @@ var ts; */ function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { - return ts.flattenDestructuringAssignment(ts.visitNode(node, moduleExpressionElementVisitor), + return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), /*visitor*/ undefined, context, 0 /* All */, /*needsValue*/ false, createAllExportExpressions); } else { return factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), node.name), - /*location*/ node.name), node.initializer ? ts.visitNode(node.initializer, moduleExpressionElementVisitor) : factory.createVoidZero()); + /*location*/ node.name), node.initializer ? ts.visitNode(node.initializer, visitor) : factory.createVoidZero()); } } /** @@ -98854,7 +100986,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 233 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 235 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -98909,10 +101041,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 265 /* NamedImports */: + case 267 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -99108,8 +101240,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -99125,14 +101257,12 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 298 /* SourceFile */) { + if (node.kind === 300 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; - noSubstitution = []; previousOnEmitNode(hint, node, emitCallback); currentSourceFile = undefined; currentModuleInfo = undefined; - noSubstitution = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -99187,13 +101317,36 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 217 /* BinaryExpression */: + case 206 /* CallExpression */: + return substituteCallExpression(node); + case 208 /* TaggedTemplateExpression */: + return substituteTaggedTemplateExpression(node); + case 219 /* BinaryExpression */: return substituteBinaryExpression(node); - case 216 /* PostfixUnaryExpression */: - case 215 /* PrefixUnaryExpression */: - return substituteUnaryExpression(node); + } + return node; + } + function substituteCallExpression(node) { + if (ts.isIdentifier(node.expression)) { + var expression = substituteExpressionIdentifier(node.expression); + noSubstitution[ts.getNodeId(expression)] = true; + if (!ts.isIdentifier(expression)) { + return ts.addEmitFlags(factory.updateCallExpression(node, expression, + /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); + } + } + return node; + } + function substituteTaggedTemplateExpression(node) { + if (ts.isIdentifier(node.tag)) { + var tag = substituteExpressionIdentifier(node.tag); + noSubstitution[ts.getNodeId(tag)] = true; + if (!ts.isIdentifier(tag)) { + return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, + /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); + } } return node; } @@ -99214,7 +101367,7 @@ var ts; } else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 298 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 300 /* SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -99256,54 +101409,11 @@ var ts; if (exportedNames) { // For each additional export of the declaration, apply an export assignment. var expression = node; - for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { - var exportName = exportedNames_2[_i]; - // Mark the node to prevent triggering this rule again. - noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression, /*location*/ node); - } - return expression; - } - } - return node; - } - /** - * Substitution for a UnaryExpression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteUnaryExpression(node) { - // When we see a prefix or postfix increment expression whose operand is an exported - // symbol, we should ensure all exports of that symbol are updated with the correct - // value. - // - // - We do not substitute generated identifiers for any reason. - // - We do not substitute identifiers tagged with the LocalName flag. - // - We do not substitute identifiers that were originally the name of an enum or - // namespace due to how they are transformed in TypeScript. - // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) - && ts.isIdentifier(node.operand) - && !ts.isGeneratedIdentifier(node.operand) - && !ts.isLocalName(node.operand) - && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { - var exportedNames = getExports(node.operand); - if (exportedNames) { - var expression = node.kind === 216 /* PostfixUnaryExpression */ - ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), - /*location*/ node) - : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; // Mark the node to prevent triggering this rule again. noSubstitution[ts.getNodeId(expression)] = true; - expression = createExportExpression(exportName, expression); - } - if (node.kind === 216 /* PostfixUnaryExpression */) { - noSubstitution[ts.getNodeId(expression)] = true; - expression = node.operator === 45 /* PlusPlusToken */ - ? factory.createSubtract(expression, factory.createNumericLiteral(1)) - : factory.createAdd(expression, factory.createNumericLiteral(1)); + expression = createExportExpression(exportName, expression, /*location*/ node); } return expression; } @@ -99346,13 +101456,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(290 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(217 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(215 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(216 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(227 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(298 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(292 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(219 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(229 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(300 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -99518,7 +101626,7 @@ var ts; startLexicalEnvironment(); // Add any prologue directives. var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); - var statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict, sourceElementVisitor); + var statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict, topLevelVisitor); // var __moduleName = context_1 && context_1.id; statements.push(factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ @@ -99527,13 +101635,13 @@ var ts; /*type*/ undefined, factory.createLogicalAnd(contextObject, factory.createPropertyAccessExpression(contextObject, "id"))) ]))); // Visit the synthetic external helpers import declaration if present - ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement); + ts.visitNode(moduleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts.isStatement); // Visit the statements of the source file, emitting any transformations into // the `executeStatements` array. We do this *before* we fill the `setters` array // as we both emit transformations as well as aggregate some data used when creating // setters. This allows us to reduce the number of times we need to loop through the // statements of the source file. - var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); + var executeStatements = ts.visitNodes(node.statements, topLevelVisitor, ts.isStatement, statementOffset); // Emit early exports for function declarations. ts.addRange(statements, hoistedStatements); // We emit hoisted variables early to align roughly with our previous emit output. @@ -99576,7 +101684,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 268 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 270 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -99666,19 +101774,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -99735,18 +101843,18 @@ var ts; * * @param node The node to visit. */ - function sourceElementVisitor(node) { + function topLevelVisitor(node) { switch (node.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return visitImportDeclaration(node); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: return visitExportDeclaration(node); - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: return visitExportAssignment(node); default: - return nestedElementVisitor(node); + return topLevelNestedVisitor(node); } } /** @@ -99802,7 +101910,7 @@ var ts; // Elide `export=` as it is illegal in a SystemJS module. return undefined; } - var expression = ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression); + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var original = node.original; if (original && hasAssociatedEndOfDeclarationMarker(original)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -99821,11 +101929,11 @@ var ts; function visitFunctionDeclaration(node) { if (ts.hasSyntacticModifier(node, 1 /* Export */)) { hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), - /*typeParameters*/ undefined, ts.visitNodes(node.parameters, destructuringAndImportCallVisitor, ts.isParameterDeclaration), - /*type*/ undefined, ts.visitNode(node.body, destructuringAndImportCallVisitor, ts.isBlock))); + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), + /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock))); } else { - hoistedStatements = ts.append(hoistedStatements, ts.visitEachChild(node, destructuringAndImportCallVisitor, context)); + hoistedStatements = ts.append(hoistedStatements, ts.visitEachChild(node, visitor, context)); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -99848,9 +101956,9 @@ var ts; var name = factory.getLocalName(node); hoistVariableDeclaration(name); // Rewrite the class declaration into an assignment of a class expression. - statements = ts.append(statements, ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(name, ts.setTextRange(factory.createClassExpression(ts.visitNodes(node.decorators, destructuringAndImportCallVisitor, ts.isDecorator), + statements = ts.append(statements, ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(name, ts.setTextRange(factory.createClassExpression(ts.visitNodes(node.decorators, visitor, ts.isDecorator), /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); @@ -99869,7 +101977,7 @@ var ts; */ function visitVariableStatement(node) { if (!shouldHoistVariableDeclarationList(node.declarationList)) { - return ts.visitNode(node, destructuringAndImportCallVisitor, ts.isStatement); + return ts.visitNode(node, visitor, ts.isStatement); } var expressions; var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */); @@ -99923,7 +102031,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 298 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 300 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -99935,9 +102043,9 @@ var ts; function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0 /* All */, + ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, /*needsValue*/ false, createAssignment) - : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, destructuringAndImportCallVisitor, ts.isExpression)) : node.name; + : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name; } /** * Creates an assignment expression for an exported variable declaration. @@ -99987,7 +102095,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 233 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 235 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -100049,10 +102157,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 265 /* NamedImports */: + case 267 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -100230,48 +102338,48 @@ var ts; * * @param node The node to visit. */ - function nestedElementVisitor(node) { + function topLevelNestedVisitor(node) { switch (node.kind) { - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return visitVariableStatement(node); - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: return visitClassDeclaration(node); - case 238 /* ForStatement */: - return visitForStatement(node); - case 239 /* ForInStatement */: + case 240 /* ForStatement */: + return visitForStatement(node, /*isTopLevel*/ true); + case 241 /* ForInStatement */: return visitForInStatement(node); - case 240 /* ForOfStatement */: + case 242 /* ForOfStatement */: return visitForOfStatement(node); - case 236 /* DoStatement */: + case 238 /* DoStatement */: return visitDoStatement(node); - case 237 /* WhileStatement */: + case 239 /* WhileStatement */: return visitWhileStatement(node); - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: return visitLabeledStatement(node); - case 244 /* WithStatement */: + case 246 /* WithStatement */: return visitWithStatement(node); - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: return visitSwitchStatement(node); - case 259 /* CaseBlock */: + case 261 /* CaseBlock */: return visitCaseBlock(node); - case 285 /* CaseClause */: + case 287 /* CaseClause */: return visitCaseClause(node); - case 286 /* DefaultClause */: + case 288 /* DefaultClause */: return visitDefaultClause(node); - case 248 /* TryStatement */: + case 250 /* TryStatement */: return visitTryStatement(node); - case 288 /* CatchClause */: + case 290 /* CatchClause */: return visitCatchClause(node); - case 231 /* Block */: + case 233 /* Block */: return visitBlock(node); - case 342 /* MergeDeclarationMarker */: + case 347 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 343 /* EndOfDeclarationMarker */: + case 348 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: - return destructuringAndImportCallVisitor(node); + return visitor(node); } } /** @@ -100279,10 +102387,10 @@ var ts; * * @param node The node to visit. */ - function visitForStatement(node) { + function visitForStatement(node, isTopLevel) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); + node = factory.updateForStatement(node, ts.visitNode(node.initializer, isTopLevel ? visitForInitializer : discardedValueVisitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, discardedValueVisitor, ts.isExpression), ts.visitIterationBody(node.statement, isTopLevel ? topLevelNestedVisitor : visitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -100294,7 +102402,7 @@ var ts; function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); + node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, topLevelNestedVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -100306,7 +102414,7 @@ var ts; function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); + node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, topLevelNestedVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -100338,7 +102446,7 @@ var ts; return expressions ? factory.inlineExpressions(expressions) : factory.createOmittedExpression(); } else { - return ts.visitEachChild(node, nestedElementVisitor, context); + return ts.visitNode(node, discardedValueVisitor, ts.isExpression); } } /** @@ -100347,7 +102455,7 @@ var ts; * @param node The node to visit. */ function visitDoStatement(node) { - return factory.updateDoStatement(node, ts.visitIterationBody(node.statement, nestedElementVisitor, context), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); + return factory.updateDoStatement(node, ts.visitIterationBody(node.statement, topLevelNestedVisitor, context), ts.visitNode(node.expression, visitor, ts.isExpression)); } /** * Visits the body of a WhileStatement to hoist declarations. @@ -100355,7 +102463,7 @@ var ts; * @param node The node to visit. */ function visitWhileStatement(node) { - return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); + return factory.updateWhileStatement(node, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, topLevelNestedVisitor, context)); } /** * Visits the body of a LabeledStatement to hoist declarations. @@ -100363,7 +102471,7 @@ var ts; * @param node The node to visit. */ function visitLabeledStatement(node) { - return factory.updateLabeledStatement(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + return factory.updateLabeledStatement(node, node.label, ts.visitNode(node.statement, topLevelNestedVisitor, ts.isStatement, factory.liftToBlock)); } /** * Visits the body of a WithStatement to hoist declarations. @@ -100371,7 +102479,7 @@ var ts; * @param node The node to visit. */ function visitWithStatement(node) { - return factory.updateWithStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + return factory.updateWithStatement(node, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, topLevelNestedVisitor, ts.isStatement, factory.liftToBlock)); } /** * Visits the body of a SwitchStatement to hoist declarations. @@ -100379,7 +102487,7 @@ var ts; * @param node The node to visit. */ function visitSwitchStatement(node) { - return factory.updateSwitchStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock)); + return factory.updateSwitchStatement(node, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.caseBlock, topLevelNestedVisitor, ts.isCaseBlock)); } /** * Visits the body of a CaseBlock to hoist declarations. @@ -100389,7 +102497,7 @@ var ts; function visitCaseBlock(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause)); + node = factory.updateCaseBlock(node, ts.visitNodes(node.clauses, topLevelNestedVisitor, ts.isCaseOrDefaultClause)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -100399,7 +102507,7 @@ var ts; * @param node The node to visit. */ function visitCaseClause(node) { - return factory.updateCaseClause(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement)); + return factory.updateCaseClause(node, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNodes(node.statements, topLevelNestedVisitor, ts.isStatement)); } /** * Visits the body of a DefaultClause to hoist declarations. @@ -100407,7 +102515,7 @@ var ts; * @param node The node to visit. */ function visitDefaultClause(node) { - return ts.visitEachChild(node, nestedElementVisitor, context); + return ts.visitEachChild(node, topLevelNestedVisitor, context); } /** * Visits the body of a TryStatement to hoist declarations. @@ -100415,7 +102523,7 @@ var ts; * @param node The node to visit. */ function visitTryStatement(node) { - return ts.visitEachChild(node, nestedElementVisitor, context); + return ts.visitEachChild(node, topLevelNestedVisitor, context); } /** * Visits the body of a CatchClause to hoist declarations. @@ -100425,7 +102533,7 @@ var ts; function visitCatchClause(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock)); + node = factory.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, topLevelNestedVisitor, ts.isBlock)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -100437,7 +102545,7 @@ var ts; function visitBlock(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.visitEachChild(node, nestedElementVisitor, context); + node = ts.visitEachChild(node, topLevelNestedVisitor, context); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -100449,19 +102557,54 @@ var ts; * * @param node The node to visit. */ - function destructuringAndImportCallVisitor(node) { - if (ts.isDestructuringAssignment(node)) { - return visitDestructuringAssignment(node); - } - else if (ts.isImportCall(node)) { - return visitImportCallExpression(node); - } - else if ((node.transformFlags & 2048 /* ContainsDestructuringAssignment */) || (node.transformFlags & 4194304 /* ContainsDynamicImport */)) { - return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); - } - else { + function visitorWorker(node, valueIsDiscarded) { + if (!(node.transformFlags & (2048 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) { return node; } + switch (node.kind) { + case 240 /* ForStatement */: + return visitForStatement(node, /*isTopLevel*/ false); + case 236 /* ExpressionStatement */: + return visitExpressionStatement(node); + case 210 /* ParenthesizedExpression */: + return visitParenthesizedExpression(node, valueIsDiscarded); + case 345 /* PartiallyEmittedExpression */: + return visitPartiallyEmittedExpression(node, valueIsDiscarded); + case 219 /* BinaryExpression */: + if (ts.isDestructuringAssignment(node)) { + return visitDestructuringAssignment(node, valueIsDiscarded); + } + break; + case 206 /* CallExpression */: + if (ts.isImportCall(node)) { + return visitImportCallExpression(node); + } + break; + case 217 /* PrefixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: + return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visit nodes to flatten destructuring assignments to exported symbols. + * + * @param node The node to visit. + */ + function visitor(node) { + return visitorWorker(node, /*valueIsDiscarded*/ false); + } + function discardedValueVisitor(node) { + return visitorWorker(node, /*valueIsDiscarded*/ true); + } + function visitExpressionStatement(node) { + return factory.updateExpressionStatement(node, ts.visitNode(node.expression, discardedValueVisitor, ts.isExpression)); + } + function visitParenthesizedExpression(node, valueIsDiscarded) { + return factory.updateParenthesizedExpression(node, ts.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts.isExpression)); + } + function visitPartiallyEmittedExpression(node, valueIsDiscarded) { + return factory.updatePartiallyEmittedExpression(node, ts.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts.isExpression)); } function visitImportCallExpression(node) { // import("./blah") @@ -100475,7 +102618,7 @@ var ts; // }; // }); var externalModuleName = ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions); - var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), destructuringAndImportCallVisitor); + var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; return factory.createCallExpression(factory.createPropertyAccessExpression(contextObject, factory.createIdentifier("import")), @@ -100486,12 +102629,11 @@ var ts; * * @param node The node to visit. */ - function visitDestructuringAssignment(node) { + function visitDestructuringAssignment(node, valueIsDiscarded) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0 /* All */, - /*needsValue*/ true); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded); } - return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); + return ts.visitEachChild(node, visitor, context); } /** * Determines whether the target of a destructuring assignment refers to an exported symbol. @@ -100519,12 +102661,57 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 298 /* SourceFile */; + return container !== undefined && container.kind === 300 /* SourceFile */; } else { return false; } } + function visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded) { + // When we see a prefix or postfix increment expression whose operand is an exported + // symbol, we should ensure all exports of that symbol are updated with the correct + // value. + // + // - We do not transform generated identifiers for any reason. + // - We do not transform identifiers tagged with the LocalName flag. + // - We do not transform identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only transform identifiers that are exported at the top level. + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var temp = void 0; + var expression = ts.visitNode(node.operand, visitor, ts.isExpression); + if (ts.isPrefixUnaryExpression(node)) { + expression = factory.updatePrefixUnaryExpression(node, expression); + } + else { + expression = factory.updatePostfixUnaryExpression(node, expression); + if (!valueIsDiscarded) { + temp = factory.createTempVariable(hoistVariableDeclaration); + expression = factory.createAssignment(temp, expression); + ts.setTextRange(expression, node); + } + expression = factory.createComma(expression, factory.cloneNode(node.operand)); + ts.setTextRange(expression, node); + } + for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { + var exportName = exportedNames_4[_i]; + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (temp) { + expression = factory.createComma(expression, temp); + ts.setTextRange(expression, node); + } + return expression; + } + } + return ts.visitEachChild(node, visitor, context); + } // // Modifier Visitors // @@ -100535,8 +102722,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -100552,7 +102739,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 298 /* SourceFile */) { + if (node.kind === 300 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -100602,7 +102789,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -100637,14 +102824,11 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return substituteBinaryExpression(node); - case 215 /* PrefixUnaryExpression */: - case 216 /* PostfixUnaryExpression */: - return substituteUnaryExpression(node); - case 227 /* MetaProperty */: + case 229 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -100707,49 +102891,10 @@ var ts; if (exportedNames) { // For each additional export of the declaration, apply an export assignment. var expression = node; - for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { - var exportName = exportedNames_4[_i]; - expression = createExportExpression(exportName, preventSubstitution(expression)); - } - return expression; - } - } - return node; - } - /** - * Substitution for a UnaryExpression that may contain an imported or exported symbol. - * - * @param node The node to substitute. - */ - function substituteUnaryExpression(node) { - // When we see a prefix or postfix increment expression whose operand is an exported - // symbol, we should ensure all exports of that symbol are updated with the correct - // value. - // - // - We do not substitute generated identifiers for any reason. - // - We do not substitute identifiers tagged with the LocalName flag. - // - We do not substitute identifiers that were originally the name of an enum or - // namespace due to how they are transformed in TypeScript. - // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) - && ts.isIdentifier(node.operand) - && !ts.isGeneratedIdentifier(node.operand) - && !ts.isLocalName(node.operand) - && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { - var exportedNames = getExports(node.operand); - if (exportedNames) { - var expression = node.kind === 216 /* PostfixUnaryExpression */ - ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node) - : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 216 /* PostfixUnaryExpression */) { - expression = node.operator === 45 /* PlusPlusToken */ - ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1)) - : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1)); - } return expression; } } @@ -100773,7 +102918,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 298 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 300 /* SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -100813,8 +102958,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(298 /* SourceFile */); - context.enableSubstitution(78 /* Identifier */); + context.enableEmitNotification(300 /* SourceFile */); + context.enableSubstitution(79 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -100826,7 +102971,7 @@ var ts; if (!ts.isExternalModule(node) || ts.some(result.statements, ts.isExternalModuleIndicator)) { return result; } - return factory.updateSourceFile(result, ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], result.statements), [ts.createEmptyExports(factory)])), result.statements)); + return factory.updateSourceFile(result, ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], result.statements, true), [ts.createEmptyExports(factory)], false)), result.statements)); } return node; } @@ -100845,12 +102990,12 @@ var ts; } function visitor(node) { switch (node.kind) { - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: return visitExportAssignment(node); - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -100978,14 +103123,14 @@ var ts; } : undefined; } function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (ts.hasSyntacticModifier(node, 32 /* Static */)) { + if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : 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 === 253 /* ClassDeclaration */) { + else if (node.parent.kind === 255 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -101007,14 +103152,14 @@ var ts; } : undefined; } function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (ts.hasSyntacticModifier(node, 32 /* Static */)) { + if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 253 /* ClassDeclaration */) { + else if (node.parent.kind === 255 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -101061,7 +103206,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 250 /* VariableDeclaration */ || node.kind === 199 /* BindingElement */) { + if (node.kind === 252 /* VariableDeclaration */ || node.kind === 201 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -101070,17 +103215,17 @@ var ts; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 164 /* PropertyDeclaration */ || node.kind === 202 /* PropertyAccessExpression */ || node.kind === 163 /* PropertySignature */ || - (node.kind === 161 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 165 /* PropertyDeclaration */ || node.kind === 204 /* PropertyAccessExpression */ || node.kind === 164 /* PropertySignature */ || + (node.kind === 162 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. - if (ts.hasSyntacticModifier(node, 32 /* Static */)) { + if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : 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 === 253 /* ClassDeclaration */ || node.kind === 161 /* Parameter */) { + else if (node.parent.kind === 255 /* ClassDeclaration */ || node.kind === 162 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -101105,10 +103250,10 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 169 /* SetAccessor */) { + if (node.kind === 171 /* SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. - if (ts.hasSyntacticModifier(node, 32 /* Static */)) { + if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1; @@ -101120,7 +103265,7 @@ var ts; } } else { - if (ts.hasSyntacticModifier(node, 32 /* Static */)) { + if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -101144,34 +103289,34 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 171 /* ConstructSignature */: + case 173 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 170 /* CallSignature */: + case 172 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 172 /* IndexSignature */: + case 174 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - if (ts.hasSyntacticModifier(node, 32 /* Static */)) { + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : 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 === 253 /* ClassDeclaration */) { + else if (node.parent.kind === 255 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -101185,7 +103330,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -101210,38 +103355,38 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 167 /* Constructor */: + case 169 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 171 /* ConstructSignature */: - case 176 /* ConstructorType */: + case 173 /* ConstructSignature */: + case 178 /* ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.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 170 /* CallSignature */: + case 172 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.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 172 /* IndexSignature */: + case 174 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : 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 === 253 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 255 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -101254,15 +103399,15 @@ 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 252 /* FunctionDeclaration */: - case 175 /* FunctionType */: + case 254 /* FunctionDeclaration */: + case 177 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 169 /* SetAccessor */: - case 168 /* GetAccessor */: + case 171 /* SetAccessor */: + case 170 /* GetAccessor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -101276,39 +103421,39 @@ 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 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 254 /* InterfaceDeclaration */: + case 256 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 191 /* MappedType */: + case 193 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 176 /* ConstructorType */: - case 171 /* ConstructSignature */: + case 178 /* ConstructorType */: + case 173 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 170 /* CallSignature */: + case 172 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + if (ts.isStatic(node.parent)) { 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 === 253 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 255 /* 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 175 /* FunctionType */: - case 252 /* FunctionDeclaration */: + case 177 /* FunctionType */: + case 254 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 255 /* TypeAliasDeclaration */: + case 257 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -101325,7 +103470,7 @@ var ts; // Heritage clause is written by user so it can always be named if (ts.isClassDeclaration(node.parent.parent)) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 116 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0; @@ -101374,7 +103519,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 161 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 162 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -101433,7 +103578,8 @@ var ts; moduleResolverHost: host, trackReferencedAmbientModule: trackReferencedAmbientModule, trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode, - reportNonlocalAugmentation: reportNonlocalAugmentation + reportNonlocalAugmentation: reportNonlocalAugmentation, + reportNonSerializableProperty: reportNonSerializableProperty }; var errorNameNode; var errorFallbackNode; @@ -101491,8 +103637,10 @@ var ts; else { context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } + return true; } } + return false; } function trackExternalModuleSymbolOfImportTypeNode(symbol) { if (!isBundledEmit) { @@ -101501,33 +103649,40 @@ var ts; } function trackSymbol(symbol, enclosingDeclaration, meaning) { if (symbol.flags & 262144 /* TypeParameter */) - return; - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); + return false; + var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); + return issuedDiagnostic; } function reportPrivateInBaseOfClassExpression(propertyName) { if (errorNameNode || errorFallbackNode) { context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); } } + function errorDeclarationNameWithFallback() { + return errorNameNode ? ts.declarationNameToString(errorNameNode) : + errorFallbackNode && ts.getNameOfDeclaration(errorFallbackNode) ? ts.declarationNameToString(ts.getNameOfDeclaration(errorFallbackNode)) : + errorFallbackNode && ts.isExportAssignment(errorFallbackNode) ? errorFallbackNode.isExportEquals ? "export=" : "default" : + "(Missing)"; // same fallback declarationNameToString uses when node is zero-width (ie, nameless) + } function reportInaccessibleUniqueSymbolError() { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), "unique symbol")); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary, errorDeclarationNameWithFallback(), "unique symbol")); } } function reportCyclicStructureError() { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode))); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary, errorDeclarationNameWithFallback())); } } function reportInaccessibleThisError() { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), "this")); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary, errorDeclarationNameWithFallback(), "this")); } } function reportLikelyUnsafeImportRequiredError(specifier) { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, errorDeclarationNameWithFallback(), specifier)); } } function reportTruncationError() { @@ -101546,6 +103701,11 @@ var ts; } } } + function reportNonSerializableProperty(propertyName) { + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName)); + } + } function transformDeclarationsForJS(sourceFile, bundled) { var oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({ @@ -101559,10 +103719,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 298 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 300 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 299 /* Bundle */) { + if (node.kind === 301 /* Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -101585,14 +103745,14 @@ var ts; resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(133 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(134 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 301 /* InputFiles */) { + if (prepend.kind === 303 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -101641,7 +103801,7 @@ var ts; refs.forEach(referenceVisitor); emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], combinedStatements), [ts.createEmptyExports(factory)])), combinedStatements); + combinedStatements = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], combinedStatements, true), [ts.createEmptyExports(factory)], false)), combinedStatements); } } var updated = factory.updateSourceFile(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); @@ -101684,8 +103844,7 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { - var specifier = ts.moduleSpecifiers.getModuleSpecifier(options, currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, - /*preferences*/ undefined); + var specifier = ts.moduleSpecifiers.getModuleSpecifier(options, currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host); if (!ts.pathIsRelative(specifier)) { // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration // via a non-relative name, emit a type reference directive to that non-relative name, rather than @@ -101729,11 +103888,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { return name; } else { - if (name.kind === 198 /* ArrayBindingPattern */) { + if (name.kind === 200 /* ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -101741,7 +103900,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 223 /* OmittedExpression */) { + if (elem.kind === 225 /* OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -101779,19 +103938,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 161 /* Parameter */ && + var shouldUseResolverType = node.kind === 162 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(128 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(129 /* AnyKeyword */); } - if (node.kind === 169 /* SetAccessor */) { + if (node.kind === 171 /* SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return factory.createKeywordTypeNode(128 /* AnyKeyword */); + return factory.createKeywordTypeNode(129 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -101799,12 +103958,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 250 /* VariableDeclaration */ || node.kind === 199 /* BindingElement */) { + if (node.kind === 252 /* VariableDeclaration */ || node.kind === 201 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 161 /* Parameter */ - || node.kind === 164 /* PropertyDeclaration */ - || node.kind === 163 /* PropertySignature */) { + if (node.kind === 162 /* Parameter */ + || node.kind === 165 /* PropertyDeclaration */ + || node.kind === 164 /* PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -101815,30 +103974,41 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(128 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(129 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 252 /* FunctionDeclaration */: - case 257 /* ModuleDeclaration */: - case 254 /* InterfaceDeclaration */: - case 253 /* ClassDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 256 /* EnumDeclaration */: + case 254 /* FunctionDeclaration */: + case 259 /* ModuleDeclaration */: + case 256 /* InterfaceDeclaration */: + case 255 /* ClassDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 258 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 261 /* ImportEqualsDeclaration */: - case 262 /* ImportDeclaration */: - case 268 /* ExportDeclaration */: - case 267 /* ExportAssignment */: + case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportDeclaration */: + case 270 /* ExportDeclaration */: + case 269 /* ExportAssignment */: return false; + case 168 /* ClassStaticBlockDeclaration */: + return true; } return false; } + // If the ExpandoFunctionDeclaration have multiple overloads, then we only need to emit properties for the last one. + function shouldEmitFunctionProperties(input) { + var _a; + if (input.body) { + return true; + } + var overloadSignatures = (_a = input.symbol.declarations) === null || _a === void 0 ? void 0 : _a.filter(function (decl) { return ts.isFunctionDeclaration(decl) && !decl.body; }); + return !overloadSignatures || overloadSignatures.indexOf(input) === overloadSignatures.length - 1; + } function getBindingNameVisible(elem) { if (ts.isOmittedExpression(elem)) { return false; @@ -101915,7 +104085,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 257 /* ModuleDeclaration */ && parent.kind !== 196 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 259 /* ModuleDeclaration */ && parent.kind !== 198 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -101935,7 +104105,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 273 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 275 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -101962,7 +104132,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 264 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 266 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -102057,7 +104227,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 178 /* TypeLiteral */ || input.kind === 191 /* MappedType */) && input.parent.kind !== 255 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 180 /* TypeLiteral */ || input.kind === 193 /* MappedType */) && input.parent.kind !== 257 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasEffectiveModifier(input, 8 /* Private */)) { @@ -102078,21 +104248,21 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 224 /* ExpressionWithTypeArguments */: { + case 226 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 174 /* TypeReference */: { + case 176 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 171 /* ConstructSignature */: + case 173 /* ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 167 /* Constructor */: { + case 169 /* Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, @@ -102100,7 +104270,7 @@ var ts; /*body*/ undefined); return cleanup(ctor); } - case 166 /* MethodDeclaration */: { + case 167 /* MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -102110,7 +104280,7 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 168 /* GetAccessor */: { + case 170 /* GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -102119,7 +104289,7 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 169 /* SetAccessor */: { + case 171 /* SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -102127,31 +104297,31 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), /*body*/ undefined)); } - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 163 /* PropertySignature */: + case 164 /* PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 165 /* MethodSignature */: { + case 166 /* MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 170 /* CallSignature */: { + case 172 /* CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 172 /* IndexSignature */: { + case 174 /* IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(129 /* AnyKeyword */))); } - case 250 /* VariableDeclaration */: { + case 252 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -102159,13 +104329,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 160 /* TypeParameter */: { + case 161 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 185 /* ConditionalType */: { + case 187 /* ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -102177,13 +104347,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 175 /* FunctionType */: { + case 177 /* FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 176 /* ConstructorType */: { + case 178 /* ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 196 /* ImportType */: { + case 198 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -102215,7 +104385,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 166 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 167 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -102225,7 +104395,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 268 /* ExportDeclaration */: { + case 270 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -102235,13 +104405,13 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 267 /* ExportAssignment */: { + case 269 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 78 /* Identifier */) { + if (input.expression.kind === 79 /* Identifier */) { return input; } else { @@ -102253,7 +104423,7 @@ var ts; errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -102276,10 +104446,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 261 /* ImportEqualsDeclaration */: { + case 263 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 262 /* ImportDeclaration */: { + case 264 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -102300,20 +104470,20 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 255 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 257 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 254 /* InterfaceDeclaration */: { + case 256 /* InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 252 /* FunctionDeclaration */: { + case 254 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); - if (clean && resolver.isExpandoFunctionDeclaration(input)) { + if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); @@ -102335,7 +104505,7 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(92 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); @@ -102374,10 +104544,10 @@ var ts; return clean; } } - case 257 /* ModuleDeclaration */: { + case 259 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 258 /* ModuleBlock */) { + if (inner && inner.kind === 260 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -102393,7 +104563,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = factory.createNodeArray(__spreadArray(__spreadArray([], lateStatements), [ts.createEmptyExports(factory)])); + lateStatements = factory.createNodeArray(__spreadArray(__spreadArray([], lateStatements, true), [ts.createEmptyExports(factory)], false)); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -102420,7 +104590,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 253 /* ClassDeclaration */: { + case 255 /* ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -102433,7 +104603,7 @@ var ts; if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 78 /* Identifier */) { + if (param.name.kind === 79 /* Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -102475,7 +104645,7 @@ var ts; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 103 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = factory.createUniqueName(oldId + "_base", 16 /* Optimistic */); @@ -102485,16 +104655,16 @@ var ts; typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 93 /* ExtendsKeyword */) { + if (clause.token === 94 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 103 /* NullKeyword */; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -102505,10 +104675,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 233 /* VariableStatement */: { + case 235 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 256 /* EnumDeclaration */: { + case 258 /* EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -102527,7 +104697,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 257 /* ModuleDeclaration */) { + if (input.kind === 259 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -102550,7 +104720,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 223 /* OmittedExpression */) { + if (e.kind === 225 /* OmittedExpression */) { return; } if (e.name) { @@ -102600,7 +104770,7 @@ var ts; function ensureModifierFlags(node) { var mask = 27647 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 298 /* SourceFile */; + var parentIsFile = node.parent.kind === 300 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -102623,13 +104793,13 @@ var ts; } function transformHeritageClauses(nodes) { return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 93 /* ExtendsKeyword */ && t.expression.kind === 103 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 254 /* InterfaceDeclaration */) { + if (node.kind === 256 /* InterfaceDeclaration */) { return true; } return false; @@ -102654,7 +104824,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 168 /* GetAccessor */ + return accessor.kind === 170 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -102663,52 +104833,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 161 /* Parameter */: - case 250 /* VariableDeclaration */: + case 162 /* Parameter */: + case 252 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 252 /* FunctionDeclaration */: - case 257 /* ModuleDeclaration */: - case 261 /* ImportEqualsDeclaration */: - case 254 /* InterfaceDeclaration */: - case 253 /* ClassDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 256 /* EnumDeclaration */: - case 233 /* VariableStatement */: - case 262 /* ImportDeclaration */: - case 268 /* ExportDeclaration */: - case 267 /* ExportAssignment */: + case 254 /* FunctionDeclaration */: + case 259 /* ModuleDeclaration */: + case 263 /* ImportEqualsDeclaration */: + case 256 /* InterfaceDeclaration */: + case 255 /* ClassDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 258 /* EnumDeclaration */: + case 235 /* VariableStatement */: + case 264 /* ImportDeclaration */: + case 270 /* ExportDeclaration */: + case 269 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 171 /* ConstructSignature */: - case 167 /* Constructor */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 165 /* MethodSignature */: - case 170 /* CallSignature */: - case 172 /* IndexSignature */: - case 250 /* VariableDeclaration */: - case 160 /* TypeParameter */: - case 224 /* ExpressionWithTypeArguments */: - case 174 /* TypeReference */: - case 185 /* ConditionalType */: - case 175 /* FunctionType */: - case 176 /* ConstructorType */: - case 196 /* ImportType */: + case 173 /* ConstructSignature */: + case 169 /* Constructor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 172 /* CallSignature */: + case 174 /* IndexSignature */: + case 252 /* VariableDeclaration */: + case 161 /* TypeParameter */: + case 226 /* ExpressionWithTypeArguments */: + case 176 /* TypeReference */: + case 187 /* ConditionalType */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: + case 198 /* ImportType */: return true; } return false; @@ -102843,7 +105013,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(345 /* Count */); + var enabledSyntaxKindFeatures = new Array(350 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; @@ -102925,7 +105095,7 @@ var ts; var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 298 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 300 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -103098,7 +105268,7 @@ var ts; lexicalEnvironmentFunctionDeclarations || lexicalEnvironmentStatements) { if (lexicalEnvironmentFunctionDeclarations) { - statements = __spreadArray([], lexicalEnvironmentFunctionDeclarations); + statements = __spreadArray([], lexicalEnvironmentFunctionDeclarations, true); } if (lexicalEnvironmentVariableDeclarations) { var statement = factory.createVariableStatement( @@ -103113,10 +105283,10 @@ var ts; } if (lexicalEnvironmentStatements) { if (!statements) { - statements = __spreadArray([], lexicalEnvironmentStatements); + statements = __spreadArray([], lexicalEnvironmentStatements, true); } else { - statements = __spreadArray(__spreadArray([], statements), lexicalEnvironmentStatements); + statements = __spreadArray(__spreadArray([], statements, true), lexicalEnvironmentStatements, true); } } } @@ -103331,7 +105501,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 299 /* Bundle */) { + if (sourceFile.kind === 301 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -103698,7 +105868,7 @@ var ts; extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 298 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 300 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -103709,7 +105879,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -103721,8 +105891,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 299 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 298 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 301 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 300 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -103763,7 +105933,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 298 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 300 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -103929,7 +106099,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes), [ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -104074,9 +106244,9 @@ var ts; break; } switch (node.kind) { - case 298 /* SourceFile */: return printFile(node); - case 299 /* Bundle */: return printBundle(node); - case 300 /* UnparsedSource */: return printUnparsedSource(node); + case 300 /* SourceFile */: return printFile(node); + case 301 /* Bundle */: return printBundle(node); + case 302 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -104396,316 +106566,318 @@ var ts; case 17 /* TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: return emitQualifiedName(node); - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 160 /* TypeParameter */: + case 161 /* TypeParameter */: return emitTypeParameter(node); - case 161 /* Parameter */: + case 162 /* Parameter */: return emitParameter(node); - case 162 /* Decorator */: + case 163 /* Decorator */: return emitDecorator(node); // Type members - case 163 /* PropertySignature */: + case 164 /* PropertySignature */: return emitPropertySignature(node); - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 165 /* MethodSignature */: + case 166 /* MethodSignature */: return emitMethodSignature(node); - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 167 /* Constructor */: + case 168 /* ClassStaticBlockDeclaration */: + return emitClassStaticBlockDeclaration(node); + case 169 /* Constructor */: return emitConstructor(node); - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return emitAccessorDeclaration(node); - case 170 /* CallSignature */: + case 172 /* CallSignature */: return emitCallSignature(node); - case 171 /* ConstructSignature */: + case 173 /* ConstructSignature */: return emitConstructSignature(node); - case 172 /* IndexSignature */: + case 174 /* IndexSignature */: return emitIndexSignature(node); // Types - case 173 /* TypePredicate */: + case 175 /* TypePredicate */: return emitTypePredicate(node); - case 174 /* TypeReference */: + case 176 /* TypeReference */: return emitTypeReference(node); - case 175 /* FunctionType */: + case 177 /* FunctionType */: return emitFunctionType(node); - case 176 /* ConstructorType */: + case 178 /* ConstructorType */: return emitConstructorType(node); - case 177 /* TypeQuery */: + case 179 /* TypeQuery */: return emitTypeQuery(node); - case 178 /* TypeLiteral */: + case 180 /* TypeLiteral */: return emitTypeLiteral(node); - case 179 /* ArrayType */: + case 181 /* ArrayType */: return emitArrayType(node); - case 180 /* TupleType */: + case 182 /* TupleType */: return emitTupleType(node); - case 181 /* OptionalType */: + case 183 /* OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 183 /* UnionType */: + case 185 /* UnionType */: return emitUnionType(node); - case 184 /* IntersectionType */: + case 186 /* IntersectionType */: return emitIntersectionType(node); - case 185 /* ConditionalType */: + case 187 /* ConditionalType */: return emitConditionalType(node); - case 186 /* InferType */: + case 188 /* InferType */: return emitInferType(node); - case 187 /* ParenthesizedType */: + case 189 /* ParenthesizedType */: return emitParenthesizedType(node); - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 188 /* ThisType */: + case 190 /* ThisType */: return emitThisType(); - case 189 /* TypeOperator */: + case 191 /* TypeOperator */: return emitTypeOperator(node); - case 190 /* IndexedAccessType */: + case 192 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 191 /* MappedType */: + case 193 /* MappedType */: return emitMappedType(node); - case 192 /* LiteralType */: + case 194 /* LiteralType */: return emitLiteralType(node); - case 193 /* NamedTupleMember */: + case 195 /* NamedTupleMember */: return emitNamedTupleMember(node); - case 194 /* TemplateLiteralType */: + case 196 /* TemplateLiteralType */: return emitTemplateType(node); - case 195 /* TemplateLiteralTypeSpan */: + case 197 /* TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 196 /* ImportType */: + case 198 /* ImportType */: return emitImportTypeNode(node); // Binding patterns - case 197 /* ObjectBindingPattern */: + case 199 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 198 /* ArrayBindingPattern */: + case 200 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 199 /* BindingElement */: + case 201 /* BindingElement */: return emitBindingElement(node); // Misc - case 229 /* TemplateSpan */: + case 231 /* TemplateSpan */: return emitTemplateSpan(node); - case 230 /* SemicolonClassElement */: + case 232 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 231 /* Block */: + case 233 /* Block */: return emitBlock(node); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return emitVariableStatement(node); - case 232 /* EmptyStatement */: + case 234 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: return emitExpressionStatement(node); - case 235 /* IfStatement */: + case 237 /* IfStatement */: return emitIfStatement(node); - case 236 /* DoStatement */: + case 238 /* DoStatement */: return emitDoStatement(node); - case 237 /* WhileStatement */: + case 239 /* WhileStatement */: return emitWhileStatement(node); - case 238 /* ForStatement */: + case 240 /* ForStatement */: return emitForStatement(node); - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: return emitForInStatement(node); - case 240 /* ForOfStatement */: + case 242 /* ForOfStatement */: return emitForOfStatement(node); - case 241 /* ContinueStatement */: + case 243 /* ContinueStatement */: return emitContinueStatement(node); - case 242 /* BreakStatement */: + case 244 /* BreakStatement */: return emitBreakStatement(node); - case 243 /* ReturnStatement */: + case 245 /* ReturnStatement */: return emitReturnStatement(node); - case 244 /* WithStatement */: + case 246 /* WithStatement */: return emitWithStatement(node); - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: return emitSwitchStatement(node); - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: return emitLabeledStatement(node); - case 247 /* ThrowStatement */: + case 249 /* ThrowStatement */: return emitThrowStatement(node); - case 248 /* TryStatement */: + case 250 /* TryStatement */: return emitTryStatement(node); - case 249 /* DebuggerStatement */: + case 251 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 251 /* VariableDeclarationList */: + case 253 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: return emitClassDeclaration(node); - case 254 /* InterfaceDeclaration */: + case 256 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 255 /* TypeAliasDeclaration */: + case 257 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 258 /* ModuleBlock */: + case 260 /* ModuleBlock */: return emitModuleBlock(node); - case 259 /* CaseBlock */: + case 261 /* CaseBlock */: return emitCaseBlock(node); - case 260 /* NamespaceExportDeclaration */: + case 262 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return emitImportDeclaration(node); - case 263 /* ImportClause */: + case 265 /* ImportClause */: return emitImportClause(node); - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: return emitNamespaceImport(node); - case 270 /* NamespaceExport */: + case 272 /* NamespaceExport */: return emitNamespaceExport(node); - case 265 /* NamedImports */: + case 267 /* NamedImports */: return emitNamedImports(node); - case 266 /* ImportSpecifier */: + case 268 /* ImportSpecifier */: return emitImportSpecifier(node); - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: return emitExportAssignment(node); - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: return emitExportDeclaration(node); - case 269 /* NamedExports */: + case 271 /* NamedExports */: return emitNamedExports(node); - case 271 /* ExportSpecifier */: + case 273 /* ExportSpecifier */: return emitExportSpecifier(node); - case 272 /* MissingDeclaration */: + case 274 /* MissingDeclaration */: return; // Module references - case 273 /* ExternalModuleReference */: + case 275 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 276 /* JsxOpeningElement */: - case 279 /* JsxOpeningFragment */: + case 278 /* JsxOpeningElement */: + case 281 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 277 /* JsxClosingElement */: - case 280 /* JsxClosingFragment */: + case 279 /* JsxClosingElement */: + case 282 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 281 /* JsxAttribute */: + case 283 /* JsxAttribute */: return emitJsxAttribute(node); - case 282 /* JsxAttributes */: + case 284 /* JsxAttributes */: return emitJsxAttributes(node); - case 283 /* JsxSpreadAttribute */: + case 285 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 284 /* JsxExpression */: + case 286 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 285 /* CaseClause */: + case 287 /* CaseClause */: return emitCaseClause(node); - case 286 /* DefaultClause */: + case 288 /* DefaultClause */: return emitDefaultClause(node); - case 287 /* HeritageClause */: + case 289 /* HeritageClause */: return emitHeritageClause(node); - case 288 /* CatchClause */: + case 290 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 291 /* SpreadAssignment */: + case 293 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 292 /* EnumMember */: + case 294 /* EnumMember */: return emitEnumMember(node); // Unparsed - case 293 /* UnparsedPrologue */: + case 295 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 300 /* UnparsedSource */: - case 294 /* UnparsedPrepend */: + case 302 /* UnparsedSource */: + case 296 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 295 /* UnparsedText */: - case 296 /* UnparsedInternalText */: + case 297 /* UnparsedText */: + case 298 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 297 /* UnparsedSyntheticReference */: + case 299 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 298 /* SourceFile */: + case 300 /* SourceFile */: return emitSourceFile(node); - case 299 /* Bundle */: + case 301 /* Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 301 /* InputFiles */: + case 303 /* InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 302 /* JSDocTypeExpression */: + case 304 /* JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 303 /* JSDocNameReference */: + case 305 /* JSDocNameReference */: return emitJSDocNameReference(node); - case 304 /* JSDocAllType */: + case 307 /* JSDocAllType */: return writePunctuation("*"); - case 305 /* JSDocUnknownType */: + case 308 /* JSDocUnknownType */: return writePunctuation("?"); - case 306 /* JSDocNullableType */: + case 309 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 307 /* JSDocNonNullableType */: + case 310 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 308 /* JSDocOptionalType */: + case 311 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 309 /* JSDocFunctionType */: + case 312 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 182 /* RestType */: - case 310 /* JSDocVariadicType */: + case 184 /* RestType */: + case 313 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 311 /* JSDocNamepathType */: + case 314 /* JSDocNamepathType */: return; - case 312 /* JSDocComment */: + case 315 /* JSDocComment */: return emitJSDoc(node); - case 314 /* JSDocTypeLiteral */: + case 317 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 315 /* JSDocSignature */: + case 318 /* JSDocSignature */: return emitJSDocSignature(node); - case 317 /* JSDocTag */: - case 322 /* JSDocClassTag */: + case 322 /* JSDocTag */: + case 327 /* JSDocClassTag */: return emitJSDocSimpleTag(node); - case 318 /* JSDocAugmentsTag */: - case 319 /* JSDocImplementsTag */: + case 323 /* JSDocAugmentsTag */: + case 324 /* JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 320 /* JSDocAuthorTag */: - case 321 /* JSDocDeprecatedTag */: + case 325 /* JSDocAuthorTag */: + case 326 /* JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 323 /* JSDocPublicTag */: - case 324 /* JSDocPrivateTag */: - case 325 /* JSDocProtectedTag */: - case 326 /* JSDocReadonlyTag */: - case 327 /* JSDocOverrideTag */: + case 328 /* JSDocPublicTag */: + case 329 /* JSDocPrivateTag */: + case 330 /* JSDocProtectedTag */: + case 331 /* JSDocReadonlyTag */: + case 332 /* JSDocOverrideTag */: return; - case 328 /* JSDocCallbackTag */: + case 333 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 330 /* JSDocParameterTag */: - case 337 /* JSDocPropertyTag */: + case 335 /* JSDocParameterTag */: + case 342 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 329 /* JSDocEnumTag */: - case 331 /* JSDocReturnTag */: - case 332 /* JSDocThisTag */: - case 333 /* JSDocTypeTag */: + case 334 /* JSDocEnumTag */: + case 336 /* JSDocReturnTag */: + case 337 /* JSDocThisTag */: + case 338 /* JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 334 /* JSDocTemplateTag */: + case 339 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 335 /* JSDocTypedefTag */: + case 340 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 336 /* JSDocSeeTag */: + case 341 /* JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 339 /* NotEmittedStatement */: - case 343 /* EndOfDeclarationMarker */: - case 342 /* MergeDeclarationMarker */: + case 344 /* NotEmittedStatement */: + case 348 /* EndOfDeclarationMarker */: + case 347 /* MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { @@ -104732,86 +106904,86 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); // Expressions - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 204 /* CallExpression */: + case 206 /* CallExpression */: return emitCallExpression(node); - case 205 /* NewExpression */: + case 207 /* NewExpression */: return emitNewExpression(node); - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 207 /* TypeAssertionExpression */: + case 209 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 209 /* FunctionExpression */: + case 211 /* FunctionExpression */: return emitFunctionExpression(node); - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return emitArrowFunction(node); - case 211 /* DeleteExpression */: + case 213 /* DeleteExpression */: return emitDeleteExpression(node); - case 212 /* TypeOfExpression */: + case 214 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 213 /* VoidExpression */: + case 215 /* VoidExpression */: return emitVoidExpression(node); - case 214 /* AwaitExpression */: + case 216 /* AwaitExpression */: return emitAwaitExpression(node); - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 216 /* PostfixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return emitBinaryExpression(node); - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: return emitConditionalExpression(node); - case 219 /* TemplateExpression */: + case 221 /* TemplateExpression */: return emitTemplateExpression(node); - case 220 /* YieldExpression */: + case 222 /* YieldExpression */: return emitYieldExpression(node); - case 221 /* SpreadElement */: + case 223 /* SpreadElement */: return emitSpreadElement(node); - case 222 /* ClassExpression */: + case 224 /* ClassExpression */: return emitClassExpression(node); - case 223 /* OmittedExpression */: + case 225 /* OmittedExpression */: return; - case 225 /* AsExpression */: + case 227 /* AsExpression */: return emitAsExpression(node); - case 226 /* NonNullExpression */: + case 228 /* NonNullExpression */: return emitNonNullExpression(node); - case 227 /* MetaProperty */: + case 229 /* MetaProperty */: return emitMetaProperty(node); - case 228 /* SyntheticExpression */: + case 230 /* SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 274 /* JsxElement */: + case 276 /* JsxElement */: return emitJsxElement(node); - case 275 /* JsxSelfClosingElement */: + case 277 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 278 /* JsxFragment */: + case 280 /* JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 338 /* SyntaxList */: + case 343 /* SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 339 /* NotEmittedStatement */: + case 344 /* NotEmittedStatement */: return; - case 340 /* PartiallyEmittedExpression */: + case 345 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 341 /* CommaListExpression */: + case 346 /* CommaListExpression */: return emitCommaList(node); - case 342 /* MergeDeclarationMarker */: - case 343 /* EndOfDeclarationMarker */: + case 347 /* MergeDeclarationMarker */: + case 348 /* EndOfDeclarationMarker */: return; - case 344 /* SyntheticReferenceExpression */: + case 349 /* SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -104859,7 +107031,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 299 /* Bundle */ ? node : undefined; + var bundle = node.kind === 301 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -104959,7 +107131,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 297 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -104996,7 +107168,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -105032,7 +107204,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 309 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 312 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -105086,6 +107258,12 @@ var ts; emit(node.questionToken); emitSignatureAndBody(node, emitSignatureHead); } + function emitClassStaticBlockDeclaration(node) { + emitDecorators(node, node.decorators); + emitModifiers(node, node.modifiers); + writeKeyword("static"); + emitBlockFunctionBody(node.body); + } function emitConstructor(node) { emitModifiers(node, node.modifiers); writeKeyword("constructor"); @@ -105094,7 +107272,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 168 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 170 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -105291,7 +107469,7 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 142 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 143 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); @@ -105440,20 +107618,40 @@ var ts; emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { + var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + if (indirectCall) { + writePunctuation("("); + writeLiteral("0"); + writePunctuation(","); + writeSpace(); + } emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); + if (indirectCall) { + writePunctuation(")"); + } emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(102 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { + var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + if (indirectCall) { + writePunctuation("("); + writeLiteral("0"); + writePunctuation(","); + writeSpace(); + } emitExpression(node.tag, parenthesizer.parenthesizeLeftSideOfAccess); + if (indirectCall) { + writePunctuation(")"); + } emitTypeArguments(node, node.typeArguments); writeSpace(); emitExpression(node.template); @@ -105489,22 +107687,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(88 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(111 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(113 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(130 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(131 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -105529,7 +107727,7 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 215 /* PrefixUnaryExpression */ + return operand.kind === 217 /* PrefixUnaryExpression */ && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } @@ -105577,7 +107775,7 @@ var ts; var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(operatorToken.pos); - writeTokenNode(operatorToken, operatorToken.kind === 100 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); } @@ -105648,7 +107846,7 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(124 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } @@ -105725,7 +107923,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(98 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -105733,8 +107931,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(90 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 235 /* IfStatement */) { + emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 237 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -105744,14 +107942,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(114 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(89 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -105767,7 +107965,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -105779,25 +107977,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(100 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(157 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(158 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -105805,7 +108003,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 251 /* VariableDeclarationList */) { + if (node.kind === 253 /* VariableDeclarationList */) { emit(node); } else { @@ -105814,12 +108012,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(85 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(80 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -105842,18 +108040,18 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 284 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 286 /* JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function emitReturnStatement(node) { - emitTokenWithComment(104 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(115 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -105861,7 +108059,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(106 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -105876,12 +108074,12 @@ var ts; emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(108 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(110 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -105890,13 +108088,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(95 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(86 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -106117,21 +108315,21 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -106140,12 +108338,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(153 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -106153,7 +108351,7 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); @@ -106166,7 +108364,7 @@ var ts; function emitNamespaceImport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -106177,25 +108375,25 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(87 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression, node.isExportEquals ? - parenthesizer.getParenthesizeRightSideOfBinaryForOperator(62 /* EqualsToken */) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(149 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(150 /* TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { @@ -106207,18 +108405,18 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(153 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(126 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(140 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(141 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -106226,7 +108424,7 @@ var ts; function emitNamespaceExport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -106245,7 +108443,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -106347,7 +108545,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -106358,13 +108556,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(81 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(87 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -106392,7 +108590,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(82 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -106465,7 +108663,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 333 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 338 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -106510,7 +108708,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 302 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 304 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -106529,7 +108727,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 314 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 317 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -106656,16 +108854,16 @@ var ts; writeLine(); } } - for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { - var directive = files_1[_c]; + for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { + var directive = files_2[_c]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_25 = types; _d < types_25.length; _d++) { - var directive = types_25[_d]; + for (var _d = 0, types_24 = types; _d < types_24.length; _d++) { + var directive = types_24[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -106845,7 +109043,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node, parenthesizerRule); } @@ -107296,11 +109494,21 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & 65536 /* PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -107406,7 +109614,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 208 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 210 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -107476,84 +109684,84 @@ var ts; if (!node) return; switch (node.kind) { - case 231 /* Block */: + case 233 /* Block */: ts.forEach(node.statements, generateNames); break; - case 246 /* LabeledStatement */: - case 244 /* WithStatement */: - case 236 /* DoStatement */: - case 237 /* WhileStatement */: + case 248 /* LabeledStatement */: + case 246 /* WithStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: generateNames(node.statement); break; - case 235 /* IfStatement */: + case 237 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 238 /* ForStatement */: - case 240 /* ForOfStatement */: - case 239 /* ForInStatement */: + case 240 /* ForStatement */: + case 242 /* ForOfStatement */: + case 241 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 259 /* CaseBlock */: + case 261 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 285 /* CaseClause */: - case 286 /* DefaultClause */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 248 /* TryStatement */: + case 250 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 288 /* CatchClause */: + case 290 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: generateNames(node.declarationList); break; - case 251 /* VariableDeclarationList */: + case 253 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 250 /* VariableDeclaration */: - case 161 /* Parameter */: - case 199 /* BindingElement */: - case 253 /* ClassDeclaration */: + case 252 /* VariableDeclaration */: + case 162 /* Parameter */: + case 201 /* BindingElement */: + case 255 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 197 /* ObjectBindingPattern */: - case 198 /* ArrayBindingPattern */: + case 199 /* ObjectBindingPattern */: + case 200 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: generateNames(node.importClause); break; - case 263 /* ImportClause */: + case 265 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 270 /* NamespaceExport */: + case 272 /* NamespaceExport */: generateNameIfNeeded(node.name); break; - case 265 /* NamedImports */: + case 267 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 266 /* ImportSpecifier */: + case 268 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -107562,12 +109770,12 @@ var ts; if (!node) return; switch (node.kind) { - case 289 /* PropertyAssignment */: - case 290 /* ShorthandPropertyAssignment */: - case 164 /* PropertyDeclaration */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 291 /* PropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -107747,25 +109955,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 257 /* ModuleDeclaration */: - case 256 /* EnumDeclaration */: + case 259 /* ModuleDeclaration */: + case 258 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 262 /* ImportDeclaration */: - case 268 /* ExportDeclaration */: + case 264 /* ImportDeclaration */: + case 270 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 252 /* FunctionDeclaration */: - case 253 /* ClassDeclaration */: - case 267 /* ExportAssignment */: + case 254 /* FunctionDeclaration */: + case 255 /* ClassDeclaration */: + case 269 /* ExportAssignment */: return generateNameForExportDefault(); - case 222 /* ClassExpression */: + case 224 /* ClassExpression */: return generateNameForClassExpression(); - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -107846,7 +110054,7 @@ var ts; // Emit leading comments if the position is not synthesized and the node // has not opted out from emitting leading comments. if (!skipLeadingComments) { - emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 339 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 344 /* NotEmittedStatement */); } if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. @@ -107857,7 +110065,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 251 /* VariableDeclarationList */) { + if (node.kind === 253 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -107876,7 +110084,7 @@ var ts; declarationListContainerEnd = savedDeclarationListContainerEnd; // Emit trailing comments if the position is not synthesized and the node // has not opted out from emitting leading comments and is an emitted node. - if (!skipTrailingComments && node.kind !== 339 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 344 /* NotEmittedStatement */) { emitTrailingComments(end); } } @@ -107940,10 +110148,13 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -108148,7 +110359,7 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 339 /* NotEmittedStatement */ + if (node.kind !== 344 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); @@ -108166,7 +110377,7 @@ var ts; if (emitFlags & 64 /* NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 339 /* NotEmittedStatement */ + if (node.kind !== 344 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); @@ -108416,7 +110627,7 @@ var ts; var rootResult = tryReadDirectory(rootDir, rootDirPath); var rootSymLinkResult; if (rootResult !== undefined) { - return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath); + return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath, directoryExists); } return host.readDirectory(rootDir, extensions, excludes, includes, depth); function getFileSystemEntries(dir) { @@ -108564,6 +110775,17 @@ var ts; }); } ts.cleanExtendedConfigCache = cleanExtendedConfigCache; + /** + * Updates watchers based on the package json files used in module resolution + */ + function updatePackageJsonWatch(lookups, packageJsonWatches, createPackageJsonWatch) { + var newMap = new ts.Map(lookups); + ts.mutateMap(packageJsonWatches, newMap, { + createNewValue: createPackageJsonWatch, + onDeleteValue: ts.closeFileWatcher + }); + } + ts.updatePackageJsonWatch = updatePackageJsonWatch; /** * Updates the existing missing file watches with the new set of missing files after new program is created */ @@ -108638,7 +110860,7 @@ var ts; return false; // We want to ignore emit file check if file is not going to be emitted next to source file // In that case we follow config file inclusion rules - if (options.outFile || options.outDir) + if (ts.outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) { @@ -108765,7 +110987,7 @@ var ts; var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); log(triggerredInfo); var start = ts.timestamp(); - cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args)); + cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args, false)); var elapsed = ts.timestamp() - start; log("Elapsed:: " + elapsed + "ms " + triggerredInfo); }, flags, options, detailInfo1, detailInfo2); }; @@ -109137,7 +111359,7 @@ var ts; var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; var lineContent = file.text.slice(lineStart, lineEnd); - lineContent = lineContent.replace(/\s+$/g, ""); // trim from end + lineContent = ts.trimStringEnd(lineContent); // trim from end lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; @@ -109411,7 +111633,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? __spreadArray(__spreadArray([], configFileParseResult.options.configFile.parseDiagnostics), configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArray(__spreadArray([], configFileParseResult.options.configFile.parseDiagnostics, true), configFileParseResult.errors, true) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -109423,10 +111645,7 @@ var ts; return false; // If any compiler options change, we can't reuse old source file even if version match // The change in options like these could result in change in syntax tree or `sourceFile.bindDiagnostics`. - var oldOptions = program.getCompilerOptions(); - return !!ts.sourceFileAffectingCompilerOptions.some(function (option) { - return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option)); - }); + return ts.optionsHaveChanges(program.getCompilerOptions(), newOptions, ts.sourceFileAffectingCompilerOptions); } function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) { return { @@ -109521,6 +111740,7 @@ var ts; var sourceFileToPackageName = new ts.Map(); // Key is a file name. Value is the (non-empty, or undefined) list of files that redirect to it. var redirectTargetsMap = ts.createMultiMap(); + var usesUriStyleNodeCoreModules = false; /** * map with * - SourceFile if present @@ -109676,6 +111896,7 @@ var ts; getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getModuleResolutionCache: function () { return moduleResolutionCache; }, getFilesByNameMap: function () { return filesByName; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, @@ -109708,6 +111929,7 @@ var ts; getLibFileFromReference: getLibFileFromReference, sourceFileToPackageName: sourceFileToPackageName, redirectTargetsMap: redirectTargetsMap, + usesUriStyleNodeCoreModules: usesUriStyleNodeCoreModules, isEmittedFile: isEmittedFile, getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, @@ -109735,7 +111957,7 @@ var ts; return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray)); case 0 /* FilePreprocessingReferencedDiagnostic */: var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end; - return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray))); + return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false))); default: ts.Debug.assertNever(diagnostic); } @@ -109838,8 +112060,8 @@ var ts; // Initialize a checker so that all our files are bound. getTypeChecker(); classifiableNames = new ts.Set(); - for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { - var sourceFile = files_2[_i]; + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var sourceFile = files_3[_i]; (_a = sourceFile.classifiableNames) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return classifiableNames.add(value); }); } } @@ -109861,13 +112083,13 @@ var ts; // which per above occurred during the current program creation. // Since we assume the filesystem does not change during program creation, // it is safe to reuse resolutions from the earlier call. - var result_15 = []; + var result_14 = []; for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { var moduleName = moduleNames_1[_i]; var resolvedModule = file.resolvedModules.get(moduleName); - result_15.push(resolvedModule); + result_14.push(resolvedModule); } - return result_15; + return result_14; } // At this point, we know at least one of the following hold: // - file has local declarations for ambient modules @@ -109895,7 +112117,9 @@ var ts; var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName); if (oldResolvedModule) { if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory)); + ts.trace(host, oldResolvedModule.packageId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), oldResolvedModule.resolvedFileName, oldResolvedModule.packageId && ts.packageIdToString(oldResolvedModule.packageId)); } (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule; (reusedNames || (reusedNames = [])).push(moduleName); @@ -110008,9 +112232,6 @@ var ts; if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { return 0 /* Not */; } - if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) { - return 0 /* Not */; - } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { return 0 /* Not */; @@ -110085,7 +112306,7 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - return 0 /* Not */; + structureIsReused = 1 /* SafeModules */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -110170,7 +112391,7 @@ var ts; if (structureIsReused !== 2 /* Completely */) { return structureIsReused; } - if ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host)) { + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { return 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); @@ -110201,6 +112422,7 @@ var ts; resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; + usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules; return 2 /* Completely */; } function getEmitHost(writeFileCallback) { @@ -110413,7 +112635,7 @@ var ts; } } function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { - return ts.concatenate(filterSemanticDiagnotics(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken), options), getProgramDiagnostics(sourceFile)); + return ts.concatenate(filterSemanticDiagnostics(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken), options), getProgramDiagnostics(sourceFile)); } function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken) { return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedBindAndCheckDiagnosticsForFile, getBindAndCheckDiagnosticsForFileNoCache); @@ -110428,8 +112650,8 @@ var ts; var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) - var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || - sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ + || sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined); @@ -110503,22 +112725,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 161 /* Parameter */: - case 164 /* PropertyDeclaration */: - case 166 /* MethodDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 165 /* MethodSignature */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 209 /* FunctionExpression */: - case 252 /* FunctionDeclaration */: - case 210 /* ArrowFunction */: - case 250 /* VariableDeclaration */: + case 166 /* MethodSignature */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 211 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: + case 212 /* ArrowFunction */: + case 252 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -110526,58 +112748,58 @@ var ts; } } switch (node.kind) { - case 263 /* ImportClause */: + case 265 /* ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 287 /* HeritageClause */: + case 289 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 116 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 254 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(117 /* InterfaceKeyword */); + case 256 /* InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 257 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(140 /* NamespaceKeyword */) : ts.tokenToString(139 /* ModuleKeyword */); + case 259 /* ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(141 /* NamespaceKeyword */) : ts.tokenToString(140 /* ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 255 /* TypeAliasDeclaration */: + case 257 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 256 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91 /* EnumKeyword */)); + case 258 /* EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 226 /* NonNullExpression */: + case 228 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 225 /* AsExpression */: + case 227 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 207 /* TypeAssertionExpression */: + case 209 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -110586,53 +112808,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 166 /* MethodDeclaration */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 209 /* FunctionExpression */: - case 252 /* FunctionDeclaration */: - case 210 /* ArrowFunction */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 167 /* MethodDeclaration */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 211 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: + case 212 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 233 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 235 /* VariableStatement */); return "skip"; } break; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 123 /* StaticKeyword */) { + if (modifier.kind !== 124 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 161 /* Parameter */: + case 162 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 204 /* CallExpression */: - case 205 /* NewExpression */: - case 224 /* ExpressionWithTypeArguments */: - case 275 /* JsxSelfClosingElement */: - case 276 /* JsxOpeningElement */: - case 206 /* TaggedTemplateExpression */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: + case 226 /* ExpressionWithTypeArguments */: + case 277 /* JsxSelfClosingElement */: + case 278 /* JsxOpeningElement */: + case 208 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -110645,25 +112867,25 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 133 /* DeclareKeyword */: - case 125 /* AbstractKeyword */: - case 156 /* OverrideKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 134 /* DeclareKeyword */: + case 126 /* AbstractKeyword */: + case 157 /* OverrideKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 123 /* StaticKeyword */: - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 124 /* StaticKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: } } } @@ -110734,8 +112956,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 78 /* Identifier */ - ? b.kind === 78 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 79 /* Identifier */ + ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { @@ -110793,6 +113015,9 @@ var ts; // only through top - level external module names. Relative external module names are not permitted. if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) { imports = ts.append(imports, moduleNameExpr); + if (!usesUriStyleNodeCoreModules && currentNodeModulesDepth === 0 && !file.isDeclarationFile) { + usesUriStyleNodeCoreModules = ts.startsWith(moduleNameExpr.text, "node:"); + } } } else if (ts.isModuleDeclaration(node)) { @@ -111419,6 +113644,9 @@ var ts; if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } + if (options.exactOptionalPropertyTypes && !ts.getStrictOptionValue(options, "strictNullChecks")) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "exactOptionalPropertyTypes", "strictNullChecks"); + } if (options.isolatedModules) { if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); @@ -111456,8 +113684,8 @@ var ts; // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { var rootPaths = new ts.Set(rootNames.map(toPath)); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var file = files_3[_i]; + for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { + var file = files_4[_i]; // Ignore file that is not emitted if (ts.sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) { addProgramDiagnosticExplainingFile(file, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, [file.fileName, options.configFilePath || ""]); @@ -111687,7 +113915,7 @@ var ts; var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason); var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon); var redirectInfo = file && ts.explainIfFileIsRedirect(file); - var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray)); + var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false)); return location && isReferenceFileLocation(location) ? ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : ts.createCompilerDiagnosticFromMessageChain(chain, relatedInfo); @@ -111971,7 +114199,13 @@ var ts; if (host.getSymlinkCache) { return host.getSymlinkCache(); } - return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + if (!symlinks) { + symlinks = ts.createSymlinkCache(currentDirectory, getCanonicalFileName); + } + if (files && resolvedTypeReferenceDirectives && !symlinks.hasProcessedResolutions()) { + symlinks.setSymlinksFromResolutions(files, resolvedTypeReferenceDirectives); + } + return symlinks; } } ts.createProgram = createProgram; @@ -112141,7 +114375,7 @@ var ts; // get any preEmit diagnostics, not just the ones if (!options.noEmitOnError) return undefined; - var diagnostics = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], program.getOptionsDiagnostics(cancellationToken)), program.getSyntacticDiagnostics(sourceFile, cancellationToken)), program.getGlobalDiagnostics(cancellationToken)), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], program.getOptionsDiagnostics(cancellationToken), true), program.getSyntacticDiagnostics(sourceFile, cancellationToken), true), program.getGlobalDiagnostics(cancellationToken), true), program.getSemanticDiagnostics(sourceFile, cancellationToken), true); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { diagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); } @@ -112151,17 +114385,17 @@ var ts; if (!sourceFile && !ts.outFile(options)) { var emitResult = program.emitBuildInfo(writeFile, cancellationToken); if (emitResult.diagnostics) - diagnostics = __spreadArray(__spreadArray([], diagnostics), emitResult.diagnostics); + diagnostics = __spreadArray(__spreadArray([], diagnostics, true), emitResult.diagnostics, true); emittedFiles = emitResult.emittedFiles; } return { diagnostics: diagnostics, sourceMaps: undefined, emittedFiles: emittedFiles, emitSkipped: true }; } ts.handleNoEmitOptions = handleNoEmitOptions; /*@internal*/ - function filterSemanticDiagnotics(diagnostic, option) { + function filterSemanticDiagnostics(diagnostic, option) { return ts.filter(diagnostic, function (d) { return !d.skippedOn || !option[d.skippedOn]; }); } - ts.filterSemanticDiagnotics = filterSemanticDiagnotics; + ts.filterSemanticDiagnostics = filterSemanticDiagnostics; /* @internal */ function parseConfigHostFromCompilerHostLike(host, directoryStructureHost) { if (directoryStructureHost === void 0) { directoryStructureHost = host; } @@ -112283,21 +114517,86 @@ var ts; ts.getFileEmitOutput = getFileEmitOutput; var BuilderState; (function (BuilderState) { - /** - * Get the referencedFile from the imported module symbol - */ - function getReferencedFileFromImportedModuleSymbol(symbol) { - if (symbol.declarations && symbol.declarations[0]) { - var declarationSourceFile = ts.getSourceFileOfNode(symbol.declarations[0]); - return declarationSourceFile && declarationSourceFile.resolvedPath; + var manyToManyPathMapCount = 0; + function createManyToManyPathMap() { + function create(forward, reverse, deleted) { + var version = 0; + var map = { + id: manyToManyPathMapCount++, + version: function () { return version; }, + clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); }, + forEach: function (fn) { return forward.forEach(fn); }, + getKeys: function (v) { return reverse.get(v); }, + getValues: function (k) { return forward.get(k); }, + hasKey: function (k) { return forward.has(k); }, + keys: function () { return forward.keys(); }, + deletedKeys: function () { return deleted; }, + deleteKey: function (k) { + (deleted || (deleted = new ts.Set())).add(k); + var set = forward.get(k); + if (!set) { + return false; + } + set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); }); + forward.delete(k); + version++; + return true; + }, + set: function (k, vSet) { + var changed = !!(deleted === null || deleted === void 0 ? void 0 : deleted.delete(k)); + var existingVSet = forward.get(k); + forward.set(k, vSet); + existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) { + if (!vSet.has(v)) { + changed = true; + deleteFromMultimap(reverse, v, k); + } + }); + vSet.forEach(function (v) { + if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) { + changed = true; + addToMultimap(reverse, v, k); + } + }); + if (changed) { + version++; + } + return map; + }, + }; + return map; + } + return create(new ts.Map(), new ts.Map(), /*deleted*/ undefined); + } + BuilderState.createManyToManyPathMap = createManyToManyPathMap; + function addToMultimap(map, k, v) { + var set = map.get(k); + if (!set) { + set = new ts.Set(); + map.set(k, set); + } + set.add(v); + } + function deleteFromMultimap(map, k, v, removeEmpty) { + if (removeEmpty === void 0) { removeEmpty = true; } + var set = map.get(k); + if (set === null || set === void 0 ? void 0 : set.delete(v)) { + if (removeEmpty && !set.size) { + map.delete(k); + } + return true; } + return false; + } + function getReferencedFilesFromImportedModuleSymbol(symbol) { + return ts.mapDefined(symbol.declarations, function (declaration) { var _a; return (_a = ts.getSourceFileOfNode(declaration)) === null || _a === void 0 ? void 0 : _a.resolvedPath; }); } /** - * Get the referencedFile from the import name node from file + * Get the module source file and all augmenting files from the import name node from file */ - function getReferencedFileFromImportLiteral(checker, importName) { + function getReferencedFilesFromImportLiteral(checker, importName) { var symbol = checker.getSymbolAtLocation(importName); - return symbol && getReferencedFileFromImportedModuleSymbol(symbol); + return symbol && getReferencedFilesFromImportedModuleSymbol(symbol); } /** * Gets the path to reference file from file name, it could be resolvedPath if present otherwise path @@ -112317,10 +114616,8 @@ var ts; var checker = program.getTypeChecker(); for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { var importName = _a[_i]; - var declarationSourceFilePath = getReferencedFileFromImportLiteral(checker, importName); - if (declarationSourceFilePath) { - addReferencedFile(declarationSourceFilePath); - } + var declarationSourceFilePaths = getReferencedFilesFromImportLiteral(checker, importName); + declarationSourceFilePaths === null || declarationSourceFilePaths === void 0 ? void 0 : declarationSourceFilePaths.forEach(addReferencedFile); } } var sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath); @@ -112397,8 +114694,8 @@ var ts; */ function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { var fileInfos = new ts.Map(); - var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? new ts.Map() : undefined; - var exportedModulesMap = referencedMap ? new ts.Map() : undefined; + var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined; + var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined; var hasCalledUpdateShapeSignature = new ts.Set(); var useOldState = canReuseOldState(referencedMap, oldState); // Ensure source files have parent pointers set @@ -112415,7 +114712,7 @@ var ts; } // Copy old visible to outside files map if (useOldState) { - var exportedModules = oldState.exportedModulesMap.get(sourceFile.resolvedPath); + var exportedModules = oldState.exportedModulesMap.getValues(sourceFile.resolvedPath); if (exportedModules) { exportedModulesMap.set(sourceFile.resolvedPath, exportedModules); } @@ -112444,11 +114741,12 @@ var ts; * Creates a clone of the state */ function clone(state) { + var _a, _b; // Dont need to backup allFiles info since its cache anyway return { fileInfos: new ts.Map(state.fileInfos), - referencedMap: state.referencedMap && new ts.Map(state.referencedMap), - exportedModulesMap: state.exportedModulesMap && new ts.Map(state.exportedModulesMap), + referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(), + exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(), hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature), useFileVersionAsSignature: state.useFileVersionAsSignature, }; @@ -112494,7 +114792,8 @@ var ts; /** * Returns if the shape of the signature has changed since last emit */ - function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) { + function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) { + if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; } ts.Debug.assert(!!sourceFile); ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state"); // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate @@ -112506,7 +114805,7 @@ var ts; return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; - if (!sourceFile.isDeclarationFile && !state.useFileVersionAsSignature) { + if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) { var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken, /*customTransformers*/ undefined, @@ -112525,8 +114824,13 @@ var ts; latestSignature = sourceFile.version; if (exportedModulesMapCache && latestSignature !== prevSignature) { // All the references in this file are exported - var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; - exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); + var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined; + if (references) { + exportedModulesMapCache.set(sourceFile.resolvedPath, references); + } + else { + exportedModulesMapCache.deleteKey(sourceFile.resolvedPath); + } } } cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature); @@ -112538,18 +114842,23 @@ var ts; */ function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) { if (!exportedModulesFromDeclarationEmit) { - exportedModulesMapCache.set(sourceFile.resolvedPath, false); + exportedModulesMapCache.deleteKey(sourceFile.resolvedPath); return; } var exportedModules; - exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)); }); - exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules || false); - function addExportedModule(exportedModulePath) { - if (exportedModulePath) { + exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); }); + if (exportedModules) { + exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules); + } + else { + exportedModulesMapCache.deleteKey(sourceFile.resolvedPath); + } + function addExportedModule(exportedModulePaths) { + if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) { if (!exportedModules) { exportedModules = new ts.Set(); } - exportedModules.add(exportedModulePath); + exportedModulePaths.forEach(function (path) { return exportedModules.add(path); }); } } } @@ -112558,16 +114867,25 @@ var ts; * This should be called whenever it is safe to commit the state of the builder */ function updateExportedFilesMapFromCache(state, exportedModulesMapCache) { + var _a; if (exportedModulesMapCache) { ts.Debug.assert(!!state.exportedModulesMap); - exportedModulesMapCache.forEach(function (exportedModules, path) { - if (exportedModules) { - state.exportedModulesMap.set(path, exportedModules); - } - else { - state.exportedModulesMap.delete(path); + var cacheId = exportedModulesMapCache.id; + var cacheVersion = exportedModulesMapCache.version(); + if (state.previousCache) { + if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) { + // If this is the same cache at the same version as last time this BuilderState + // was updated, there's no need to update again + return; } - }); + state.previousCache.id = cacheId; + state.previousCache.version = cacheVersion; + } + else { + state.previousCache = { id: cacheId, version: cacheVersion }; + } + (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); }); + exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); }); } } BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache; @@ -112591,7 +114909,7 @@ var ts; var path = queue.pop(); if (!seenMap.has(path)) { seenMap.add(path); - var references = state.referencedMap.get(path); + var references = state.referencedMap.getValues(path); if (references) { var iterator = references.keys(); for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) { @@ -112617,10 +114935,8 @@ var ts; * Gets the files referenced by the the file path */ function getReferencedByPaths(state, referencedFilePath) { - return ts.arrayFrom(ts.mapDefinedIterator(state.referencedMap.entries(), function (_a) { - var filePath = _a[0], referencesInFile = _a[1]; - return referencesInFile.has(referencedFilePath) ? filePath : undefined; - })); + var keys = state.referencedMap.getKeys(referencedFilePath); + return keys ? ts.arrayFrom(keys.keys()) : []; } BuilderState.getReferencedByPaths = getReferencedByPaths; /** @@ -112650,7 +114966,7 @@ var ts; */ function isFileAffectingGlobalScope(sourceFile) { return containsGlobalScopeAugmentation(sourceFile) || - !ts.isExternalOrCommonJsModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + !ts.isExternalOrCommonJsModule(sourceFile) && !ts.isJsonSourceFile(sourceFile) && !containsOnlyAmbientModules(sourceFile); } /** * Gets all files of the program excluding the default library file @@ -112786,7 +115102,7 @@ var ts; // versions dont match oldInfo.version !== info.version || // Referenced files changed - !hasSameKeys(newReferences = referencedMap && referencedMap.get(sourceFilePath), oldReferencedMap && oldReferencedMap.get(sourceFilePath)) || + !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) || // Referenced file was deleted in the new program newReferences && ts.forEachKey(newReferences, function (path) { return !state.fileInfos.has(path) && oldState.fileInfos.has(path); })) { // Register file as changed file and do not copy semantic diagnostics, since all changed files need to be re-evaluated @@ -112862,6 +115178,7 @@ var ts; * Creates a clone of the state */ function cloneBuilderProgramState(state) { + var _a; var newState = ts.BuilderState.clone(state); newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile); newState.changedFilesSet = new ts.Set(state.changedFilesSet); @@ -112869,7 +115186,7 @@ var ts; newState.affectedFilesIndex = state.affectedFilesIndex; newState.currentChangedFilePath = state.currentChangedFilePath; newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures); - newState.currentAffectedFilesExportedModulesMap = state.currentAffectedFilesExportedModulesMap && new ts.Map(state.currentAffectedFilesExportedModulesMap); + newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone(); newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles); newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles; newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState); @@ -112937,8 +115254,7 @@ var ts; if (!state.currentAffectedFilesSignatures) state.currentAffectedFilesSignatures = new ts.Map(); if (state.exportedModulesMap) { - if (!state.currentAffectedFilesExportedModulesMap) - state.currentAffectedFilesExportedModulesMap = new ts.Map(); + state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()); } state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap); state.currentChangedFilePath = nextKey.value; @@ -113018,14 +115334,15 @@ var ts; // we need to update the signature to reflect correctness of the signature(which is output d.ts emit) of this file // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build - ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); + // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. + ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, + /* useFileVersionAsSignature */ true); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } - return false; } /** * Removes semantic diagnostics for path and @@ -113048,6 +115365,7 @@ var ts; * Iterate on referencing modules that export entities from affected file */ function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { + var _a, _b; // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) { @@ -113065,8 +115383,8 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - var result = fn(state, currentPath); - if (result && isChangedSignature(state, currentPath)) { + fn(state, currentPath); + if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); } @@ -113077,17 +115395,15 @@ var ts; var seenFileAndExportsOfFile = new ts.Set(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { - return exportedModules && - exportedModules.has(affectedFile.resolvedPath) && - forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); - })) { - return; - } + (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { + return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); + }); // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { - return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it - exportedModules.has(affectedFile.resolvedPath) && + (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { + var _a; + // If the cache had an updated value, skip + return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && + !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn); }); } @@ -113095,43 +115411,37 @@ var ts; * Iterate on files referencing referencedPath */ function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) { - return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) { - return referencesInFile.has(referencedPath) && forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn); + var _a; + (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) { + return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn); }); } /** * fn on file and iterate on anything that exports this file */ function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) { + var _a, _b, _c; if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) { - return false; - } - if (fn(state, filePath)) { - // If there are no more diagnostics from old cache, done - return true; + return; } + fn(state, filePath); ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected - if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { - return exportedModules && - exportedModules.has(filePath) && - forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); - })) { - return true; - } + (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { + return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); + }); // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected - if (ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { - return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it - exportedModules.has(filePath) && + (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) { + var _a; + // If the cache had an updated value, skip + return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && + !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) && forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn); - })) { - return true; - } + }); // Remove diagnostics of files that import this file (without going to exports of referencing files) - return !!ts.forEachEntry(state.referencedMap, function (referencesInFile, referencingFilePath) { - return referencesInFile.has(filePath) && - !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file + (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) { + return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file fn(state, referencingFilePath); } // Dont add to seen since this is not yet done with the export removal ); @@ -113193,7 +115503,7 @@ var ts; var cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path); // Report the bind and check diagnostics from the cache if we already have those diagnostics present if (cachedDiagnostics) { - return ts.filterSemanticDiagnotics(cachedDiagnostics, state.compilerOptions); + return ts.filterSemanticDiagnostics(cachedDiagnostics, state.compilerOptions); } } // Diagnostics werent cached, get them from program, and cache the result @@ -113201,7 +115511,7 @@ var ts; if (state.semanticDiagnosticsPerFile) { state.semanticDiagnosticsPerFile.set(path, diagnostics); } - return ts.filterSemanticDiagnotics(diagnostics, state.compilerOptions); + return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions); } /** * Gets the program information to be emitted in buildInfo so that we can use it to create new program @@ -113236,19 +115546,24 @@ var ts; if (state.referencedMap) { referencedMap = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive).map(function (key) { return [ toFileId(key), - toFileIdListId(state.referencedMap.get(key)) + toFileIdListId(state.referencedMap.getValues(key)) ]; }); } var exportedModulesMap; if (state.exportedModulesMap) { exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) { - var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); + var _a; + if (state.currentAffectedFilesExportedModulesMap) { + if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) { + return undefined; + } + var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key); + if (newValue) { + return [toFileId(key), toFileIdListId(newValue)]; + } + } // Not in temporary cache, use existing value - if (newValue === undefined) - return [toFileId(key), toFileIdListId(state.exportedModulesMap.get(key))]; - // Value in cache and has updated value map, use that - else if (newValue) - return [toFileId(key), toFileIdListId(newValue)]; + return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))]; }); } var semanticDiagnosticsPerFile; @@ -113316,8 +115631,14 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } @@ -113419,8 +115740,9 @@ var ts; newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; oldState = undefined; - var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics); - builderProgram.getState = function () { return state; }; + var getState = function () { return state; }; + var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics); + builderProgram.getState = getState; builderProgram.backupState = function () { ts.Debug.assert(backupState === undefined); backupState = cloneBuilderProgramState(state); @@ -113655,8 +115977,8 @@ var ts; var state = { fileInfos: fileInfos, compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, - referencedMap: toMapOfReferencedSet(program.referencedMap), - exportedModulesMap: toMapOfReferencedSet(program.exportedModulesMap), + referencedMap: toManyToManyPathMap(program.referencedMap), + exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap), semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true, affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }), @@ -113699,20 +116021,28 @@ var ts; function toFilePathsSet(fileIdsListId) { return filePathsSetList[fileIdsListId - 1]; } - function toMapOfReferencedSet(referenceMap) { - return referenceMap && ts.arrayToMap(referenceMap, function (value) { return toFilePath(value[0]); }, function (value) { return toFilePathsSet(value[1]); }); + function toManyToManyPathMap(referenceMap) { + if (!referenceMap) { + return undefined; + } + var map = ts.BuilderState.createManyToManyPathMap(); + referenceMap.forEach(function (_a) { + var fileId = _a[0], fileIdListId = _a[1]; + return map.set(toFilePath(fileId), toFilePathsSet(fileIdListId)); + }); + return map; } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { + function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) { return { getState: ts.notImplemented, backupState: ts.noop, restoreState: ts.noop, getProgram: getProgram, - getProgramOrUndefined: function () { return state.program; }, - releaseProgram: function () { return state.program = undefined; }, - getCompilerOptions: function () { return state.compilerOptions; }, + getProgramOrUndefined: function () { return getState().program; }, + releaseProgram: function () { return getState().program = undefined; }, + getCompilerOptions: function () { return getState().compilerOptions; }, getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); }, getSourceFiles: function () { return getProgram().getSourceFiles(); }, getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); }, @@ -113728,7 +116058,7 @@ var ts; close: ts.noop, }; function getProgram() { - return ts.Debug.checkDefined(state.program); + return ts.Debug.checkDefined(getState().program); } } ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram; @@ -113745,7 +116075,7 @@ var ts; ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram; function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) { var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics; - return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics); + return ts.createRedirectedBuilderProgram(function () { return ({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }); }, newConfigFileParsingDiagnostics); } ts.createAbstractBuilder = createAbstractBuilder; })(ts || (ts = {})); @@ -113846,6 +116176,7 @@ var ts; // TypeRoot watches for the types that get added as part of getAutomaticTypeDirectiveNames var typeRootsWatches = new ts.Map(); return { + getModuleResolutionCache: function () { return moduleResolutionCache; }, startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions, finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions, // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update @@ -113969,7 +116300,7 @@ var ts; return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache); } function resolveNamesWithLocalCache(_a) { - var _b; + var _b, _c, _d; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, new ts.Map()).get(path); @@ -114002,9 +116333,24 @@ var ts; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; + var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved, name, containingFile, ts.getDirectoryPath(containingFile), resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } } else { - resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference); + resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -114018,6 +116364,23 @@ var ts; logChanges = false; } } + else { + var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } + } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); resolvedModules.push(getResolutionWithResolvedFileName(resolution)); @@ -114463,7 +116826,7 @@ var ts; var ts; (function (ts) { var moduleSpecifiers; - (function (moduleSpecifiers) { + (function (moduleSpecifiers_1) { var RelativePreference; (function (RelativePreference) { RelativePreference[RelativePreference["Relative"] = 0] = "Relative"; @@ -114506,41 +116869,68 @@ var ts; }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) { - var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier)); + var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier), {}); if (res === oldImportSpecifier) return undefined; return res; } - moduleSpecifiers.updateModuleSpecifier = updateModuleSpecifier; + moduleSpecifiers_1.updateModuleSpecifier = updateModuleSpecifier; // Note: importingSourceFile is just for usesJsExtensionOnImports - function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences) { - if (preferences === void 0) { preferences = {}; } - return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(preferences, compilerOptions, importingSourceFile)); + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) { + return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences({}, compilerOptions, importingSourceFile), {}); } - moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; - function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host) { + moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, preferences) { var info = getInfo(importingSourceFileName, host); - var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host); + var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host, preferences); return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions, /*packageNameOnly*/ true); }); } - moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; - function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences) { + moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName; + function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences, userPreferences) { var info = getInfo(importingSourceFileName, host); - var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host); + var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences); return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); } + function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences) { + return tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile, host, userPreferences)[0]; + } + moduleSpecifiers_1.tryGetModuleSpecifiersFromCache = tryGetModuleSpecifiersFromCache; + function tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile, host, userPreferences) { + var _a; + var moduleSourceFile = ts.getSourceFileOfModule(moduleSymbol); + if (!moduleSourceFile) { + return ts.emptyArray; + } + var cache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); + var cached = cache === null || cache === void 0 ? void 0 : cache.get(importingSourceFile.path, moduleSourceFile.path, userPreferences); + return [cached === null || cached === void 0 ? void 0 : cached.moduleSpecifiers, moduleSourceFile, cached === null || cached === void 0 ? void 0 : cached.modulePaths, cache]; + } /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences) { + return getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences).moduleSpecifiers; + } + moduleSpecifiers_1.getModuleSpecifiers = getModuleSpecifiers; + function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences) { + var computedWithoutCache = false; var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol, checker); if (ambient) - return [ambient]; + return { moduleSpecifiers: [ambient], computedWithoutCache: computedWithoutCache }; + // eslint-disable-next-line prefer-const + var _a = tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile, host, userPreferences), specifiers = _a[0], moduleSourceFile = _a[1], modulePaths = _a[2], cache = _a[3]; + if (specifiers) + return { moduleSpecifiers: specifiers, computedWithoutCache: computedWithoutCache }; + if (!moduleSourceFile) + return { moduleSpecifiers: ts.emptyArray, computedWithoutCache: computedWithoutCache }; + computedWithoutCache = true; + modulePaths || (modulePaths = getAllModulePathsWorker(importingSourceFile.path, moduleSourceFile.originalFileName, host)); + var result = computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences); + cache === null || cache === void 0 ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, modulePaths, result); + return { moduleSpecifiers: result, computedWithoutCache: computedWithoutCache }; + } + moduleSpecifiers_1.getModuleSpecifiersWithCacheInfo = getModuleSpecifiersWithCacheInfo; + function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences) { var info = getInfo(importingSourceFile.path, host); - var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - if (!moduleSourceFile) { - return []; - } - var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) { if (reason.kind !== ts.FileIncludeKind.Import || reason.file !== importingSourceFile.path) @@ -114551,8 +116941,10 @@ var ts; specifier : undefined; }); }); - if (existingSpecifier) - return [existingSpecifier]; + if (existingSpecifier) { + var moduleSpecifiers_2 = [existingSpecifier]; + return moduleSpecifiers_2; + } var importedFileIsInNodeModules = ts.some(modulePaths, function (p) { return p.isInNodeModules; }); // Module specifier priority: // 1. "Bare package specifiers" (e.g. "@foo/bar") resulting from a path through node_modules to a package.json's "types" entry @@ -114594,7 +116986,6 @@ var ts; (nodeModulesSpecifiers === null || nodeModulesSpecifiers === void 0 ? void 0 : nodeModulesSpecifiers.length) ? nodeModulesSpecifiers : ts.Debug.checkDefined(relativeSpecifiers); } - moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers; // importingSourceFileName is separate because getEditsForFileRename may need to specify an updated path function getInfo(importingSourceFileName, host) { var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true); @@ -114671,7 +117062,7 @@ var ts; } return count; } - moduleSpecifiers.countPathComponents = countPathComponents; + moduleSpecifiers_1.countPathComponents = countPathComponents; function usesJsExtensionOnImports(_a) { var imports = _a.imports; return ts.firstDefined(imports, function (_a) { @@ -114691,25 +117082,23 @@ var ts; }); } function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) { + var _a; var getCanonicalFileName = ts.hostGetCanonicalFileName(host); var cwd = host.getCurrentDirectory(); var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined; var importedPath = ts.toPath(importedFileName, cwd, getCanonicalFileName); var redirects = host.redirectTargetsMap.get(importedPath) || ts.emptyArray; - var importedFileNames = __spreadArray(__spreadArray(__spreadArray([], (referenceRedirect ? [referenceRedirect] : ts.emptyArray)), [importedFileName]), redirects); + var importedFileNames = __spreadArray(__spreadArray(__spreadArray([], (referenceRedirect ? [referenceRedirect] : ts.emptyArray), true), [importedFileName], false), redirects, true); var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath); if (!preferSymlinks) { // Symlinks inside ignored paths are already filtered out of the symlink cache, // so we only need to remove them from the realpath filenames. - var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); - if (result_16) - return result_16; - } - var links = host.getSymlinkCache - ? host.getSymlinkCache() - : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd); - var symlinkedDirectories = links.getSymlinkedDirectoriesByRealpath(); + var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); + if (result_15) + return result_15; + } + var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath(); var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd); var result = symlinkedDirectories && ts.forEachAncestorDirectory(ts.getDirectoryPath(fullImportedFileName), function (realPathDirectory) { var symlinkDirectories = symlinkedDirectories.get(ts.ensureTrailingDirectorySeparator(ts.toPath(realPathDirectory, cwd, getCanonicalFileName))); @@ -114727,10 +117116,10 @@ var ts; for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) { var symlinkDirectory = symlinkDirectories_1[_i]; var option = ts.resolvePath(symlinkDirectory, relative); - var result_17 = cb(option, target === referenceRedirect); + var result_16 = cb(option, target === referenceRedirect); shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths - if (result_17) - return result_17; + if (result_16) + return result_16; } }); }); @@ -114738,20 +117127,28 @@ var ts; ? ts.forEach(targets, function (p) { return shouldFilterIgnoredPaths && ts.containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect); }) : undefined); } - moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule; + moduleSpecifiers_1.forEachFileNameOfModule = forEachFileNameOfModule; /** * Looks for existing imports that use symlinks to this module. * Symlinks will be returned first so they are preferred over the real path. */ - function getAllModulePaths(importingFileName, importedFileName, host) { + function getAllModulePaths(importingFilePath, importedFileName, host, preferences, importedFilePath) { var _a; + if (importedFilePath === void 0) { importedFilePath = ts.toPath(importedFileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); } var cache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); - var getCanonicalFileName = ts.hostGetCanonicalFileName(host); if (cache) { - var cached = cache.get(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName)); - if (typeof cached === "object") - return cached; + var cached = cache.get(importingFilePath, importedFilePath, preferences); + if (cached === null || cached === void 0 ? void 0 : cached.modulePaths) + return cached.modulePaths; + } + var modulePaths = getAllModulePathsWorker(importingFilePath, importedFileName, host); + if (cache) { + cache.setModulePaths(importingFilePath, importedFilePath, preferences, modulePaths); } + return modulePaths; + } + function getAllModulePathsWorker(importingFileName, importedFileName, host) { + var getCanonicalFileName = ts.hostGetCanonicalFileName(host); var allFileNames = new ts.Map(); var importedFileFromNodeModules = false; forEachFileNameOfModule(importingFileName, importedFileName, host, @@ -114763,7 +117160,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_26 = function (directory) { + var _loop_31 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -114787,7 +117184,7 @@ var ts; }; var out_directory_1; for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { - var state_9 = _loop_26(directory); + var state_9 = _loop_31(directory); directory = out_directory_1; if (state_9 === "break") break; @@ -114798,9 +117195,6 @@ var ts; remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators); sortedPaths.push.apply(sortedPaths, remainingPaths); } - if (cache) { - cache.set(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName), sortedPaths); - } return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) { @@ -115056,7 +117450,11 @@ var ts; } } function getJSExtensionForFile(fileName, options) { - var ext = ts.extensionFromPath(fileName); + var _a; + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + } + function tryGetJSExtensionForFile(fileName, options) { + var ext = ts.tryGetExtensionFromPath(fileName); switch (ext) { case ".ts" /* Ts */: case ".d.ts" /* Dts */: @@ -115067,12 +117465,11 @@ var ts; case ".jsx" /* Jsx */: case ".json" /* Json */: return ext; - case ".tsbuildinfo" /* TsBuildInfo */: - return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported:: FileName:: " + fileName); default: - return ts.Debug.assertNever(ext); + return undefined; } } + moduleSpecifiers_1.tryGetJSExtensionForFile = tryGetJSExtensionForFile; function getRelativePathIfInDirectory(path, directoryPath, getCanonicalFileName) { var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); return ts.isRootedDiskPath(relativePath) ? undefined : relativePath; @@ -115089,12 +117486,12 @@ var ts; getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); }, getNewLine: function () { return ts.sys.newLine; }, getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames) - } : undefined; // TODO: GH#18217 + } : undefined; /** * Create a function that reports error by writing to the system and handles the formating of the diagnostic */ function createDiagnosticReporter(system, pretty) { - var host = system === ts.sys ? sysFormatDiagnosticsHost : { + var host = system === ts.sys && sysFormatDiagnosticsHost ? sysFormatDiagnosticsHost : { getCurrentDirectory: function () { return system.getCurrentDirectory(); }, getNewLine: function () { return system.newLine; }, getCanonicalFileName: ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames), @@ -115440,6 +117837,7 @@ var ts; ConfigFileOfReferencedProject: "Config file of referened project", ExtendedConfigOfReferencedProject: "Extended config file of referenced project", WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", + PackageJson: "package.json file", }; function createWatchFactory(host, options) { var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; @@ -115514,7 +117912,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArray([compilerHost], args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArray([compilerHost], args, false)); if (result) { result.version = computeHash(result.text); } @@ -115678,12 +118076,14 @@ var ts; var builderProgram; var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc var missingFilesMap; // Map of file watchers for the missing files + var packageJsonMap; // map of watchers for package json files used in module resolution var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file var timerToUpdateProgram; // timer callback to recompile the program var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations var parsedConfigs; // Parsed commandline and watching cached for referenced projects var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation + var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations @@ -115727,7 +118127,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, __spreadArray([fileName, toPath(fileName)], args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArray([fileName, toPath(fileName)], args, false)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -115821,6 +118221,10 @@ var ts; }); parsedConfigs = undefined; } + if (packageJsonMap) { + ts.clearMap(packageJsonMap, ts.closeFileWatcher); + packageJsonMap = undefined; + } } function getCurrentBuilderProgram() { return builderProgram; @@ -115834,12 +118238,12 @@ var ts; var program = getCurrentBuilderProgram(); if (hasChangedCompilerOptions) { newLine = updateNewLine(); - if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) { + if (program && (changesAffectResolution || ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) { resolutionCache.clear(); } } // All resolutions are invalid if user provided resolutions - var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); + var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution); if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); @@ -115849,6 +118253,7 @@ var ts; else { createNewProgram(hasInvalidatedResolution); } + changesAffectResolution = false; // reset for next sync if (host.afterProgramCreate && program !== builderProgram) { host.afterProgramCreate(builderProgram); } @@ -115868,9 +118273,15 @@ var ts; compilerHost.hasInvalidatedResolution = hasInvalidatedResolution; compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames; builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); + // map package json cache entries to their realpaths so we don't try to watch across symlinks + var packageCacheEntries = ts.map(resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache().entries(), function (_a) { + var path = _a[0], data = _a[1]; + return [compilerHost.realpath ? toPath(compilerHost.realpath(path)) : path, data]; + }); resolutionCache.finishCachingPerDirectoryResolution(); // Update watches ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath); + ts.updatePackageJsonWatch(packageCacheEntries, packageJsonMap || (packageJsonMap = new ts.Map()), watchPackageJsonLookupPath); if (needsUpdateInTypeRootWatch) { resolutionCache.updateTypeRootsWatch(); } @@ -116172,6 +118583,21 @@ var ts; ts.noopFileWatcher : watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); } + function watchPackageJsonLookupPath(packageJsonPath) { + // If the package.json is pulled into the compilation itself (eg, via json imports), don't add a second watcher here + return sourceFilesCache.has(packageJsonPath) ? + ts.noopFileWatcher : + watchFilePath(packageJsonPath, packageJsonPath, onPackageJsonChange, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); + } + function onPackageJsonChange(fileName, eventKind, path) { + updateCachedSystemWithFile(fileName, path, eventKind); + // package.json changes invalidate module resolution and can change the set of loaded files + // so if we witness a change to one, we have to do a full reload + reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + changesAffectResolution = true; + // Update the program + scheduleProgramUpdate(); + } function onMissingFileChange(fileName, eventKind, missingFilePath) { updateCachedSystemWithFile(fileName, missingFilePath, eventKind); if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) { @@ -116515,6 +118941,8 @@ var ts; allWatchedInputFiles: new ts.Map(), allWatchedConfigFiles: new ts.Map(), allWatchedExtendedConfigFiles: new ts.Map(), + allWatchedPackageJsonFiles: new ts.Map(), + lastCachedPackageJsonLookups: new ts.Map(), timerToBuildInvalidatedProject: undefined, reportFileChangeDetected: false, watchFile: watchFile, @@ -116638,6 +119066,7 @@ var ts; }); ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + ts.mutateMapSkippingNewValues(state.allWatchedPackageJsonFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); } return state.buildOrder = buildOrder; } @@ -116670,7 +119099,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArray([compilerHost], args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArray([compilerHost], args, false)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -116826,7 +119255,7 @@ var ts; }, emit: function (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { if (targetSourceFile || emitOnlyDtsFiles) { - return withProgramOrUndefined(function (program) { return program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); }); + return withProgramOrUndefined(function (program) { var _a, _b; return program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers || ((_b = (_a = state.host).getCustomTransformers) === null || _b === void 0 ? void 0 : _b.call(_a, project))); }); } executeSteps(BuildStep.SemanticDiagnostics, cancellationToken); if (step === BuildStep.EmitBuildInfo) { @@ -116888,6 +119317,10 @@ var ts; (_b = state.typeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.update(config.options); // Create program program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences); + state.lastCachedPackageJsonLookups.set(projectPath, state.moduleResolutionCache && ts.map(state.moduleResolutionCache.getPackageJsonInfoCache().entries(), function (_a) { + var path = _a[0], data = _a[1]; + return [state.host.realpath ? toPath(state, state.host.realpath(path)) : path, data]; + })); if (state.watch) { state.builderPrograms.set(projectPath, program); } @@ -116904,13 +119337,14 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertIsDefined(program); - handleDiagnostics(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], program.getConfigFileParsingDiagnostics()), program.getOptionsDiagnostics(cancellationToken)), program.getGlobalDiagnostics(cancellationToken)), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], program.getConfigFileParsingDiagnostics(), true), program.getOptionsDiagnostics(cancellationToken), true), program.getGlobalDiagnostics(cancellationToken), true), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken), true), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.checkDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); } function emit(writeFileCallback, cancellationToken, customTransformers) { var _a; + var _b, _c; ts.Debug.assertIsDefined(program); ts.Debug.assert(step === BuildStep.Emit); // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly @@ -116921,7 +119355,7 @@ var ts; var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics, /*write*/ undefined, /*reportSummary*/ undefined, function (name, text, writeByteOrderMark) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, cancellationToken, - /*emitOnlyDts*/ false, customTransformers).emitResult; + /*emitOnlyDts*/ false, customTransformers || ((_c = (_b = state.host).getCustomTransformers) === null || _c === void 0 ? void 0 : _c.call(_b, project))).emitResult; // Don't emit .d.ts if there are decl file errors if (declDiagnostics) { program.restoreState(); @@ -116967,7 +119401,7 @@ var ts; var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken); if (emitResult.diagnostics.length) { reportErrors(state, emitResult.diagnostics); - state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath)), emitResult.diagnostics)); + state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath), true), emitResult.diagnostics, true)); buildResult = BuildResultFlags.EmitErrors & buildResult; } if (emitResult.emittedFiles && state.write) { @@ -117003,6 +119437,7 @@ var ts; return emitDiagnostics; } function emitBundle(writeFileCallback, customTransformers) { + var _a, _b; ts.Debug.assert(kind === InvalidatedProjectKind.UpdateBundle); if (state.options.dry) { reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, project); @@ -117018,7 +119453,7 @@ var ts; var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) { var refName = resolveProjectName(state, ref.path); return parseConfigFile(state, refName, toResolvedConfigFilePath(state, refName)); - }, customTransformers); + }, customTransformers || ((_b = (_a = state.host).getCustomTransformers) === null || _b === void 0 ? void 0 : _b.call(_a, project))); if (ts.isString(outputFiles)) { reportStatus(state, ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, project, relName(state, outputFiles)); step = BuildStep.BuildInvalidatedProjectOfBundle; @@ -117117,12 +119552,14 @@ var ts; watchExtendedConfigFiles(state, projectPath, config); watchWildCardDirectories(state, project, projectPath, config); watchInputFiles(state, project, projectPath, config); + watchPackageJsonFiles(state, project, projectPath, config); } else if (reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) { // Update file names config.fileNames = ts.getFileNamesFromConfigSpecs(config.options.configFile.configFileSpecs, ts.getDirectoryPath(project), config.options, state.parseConfigFileHost); ts.updateErrorForNoInputFiles(config.fileNames, project, config.options.configFile.configFileSpecs, config.errors, ts.canJsonReportNoInputFiles(config.raw)); watchInputFiles(state, project, projectPath, config); + watchPackageJsonFiles(state, project, projectPath, config); } var status = getUpToDateStatus(state, config, projectPath); verboseReportProjectStatus(state, project, status); @@ -117365,6 +119802,13 @@ var ts; var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); }); if (extendedConfigStatus) return extendedConfigStatus; + // Check package file time + var dependentPackageFileStatus = ts.forEach(state.lastCachedPackageJsonLookups.get(resolvedPath) || ts.emptyArray, function (_a) { + var path = _a[0]; + return checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName); + }); + if (dependentPackageFileStatus) + return dependentPackageFileStatus; } if (!force && !state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); @@ -117411,6 +119855,8 @@ var ts; return actual; } function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) { + if (proj.options.noEmit) + return priorNewestUpdateTime; var host = state.host; var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames()); if (!skipOutputs || outputs.length !== skipOutputs.size) { @@ -117674,6 +120120,14 @@ var ts; onDeleteValue: ts.closeFileWatcher, }); } + function watchPackageJsonFiles(state, resolved, resolvedPath, parsed) { + if (!state.watch || !state.lastCachedPackageJsonLookups) + return; + ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), { + createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); }, + onDeleteValue: ts.closeFileWatcher, + }); + } function startWatching(state, buildOrder) { if (!state.watchAllProjectsPending) return; @@ -117690,6 +120144,8 @@ var ts; watchWildCardDirectories(state, resolved, resolvedPath, cfg); // Watch input files watchInputFiles(state, resolved, resolvedPath, cfg); + // Watch package json files + watchPackageJsonFiles(state, resolved, resolvedPath, cfg); } } } @@ -117698,6 +120154,7 @@ var ts; ts.clearMap(state.allWatchedExtendedConfigFiles, ts.closeFileWatcherOf); ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); }); ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); }); + ts.clearMap(state.allWatchedPackageJsonFiles, function (watchedPacageJsonFiles) { return ts.clearMap(watchedPacageJsonFiles, ts.closeFileWatcher); }); } function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) { var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions); @@ -117730,7 +120187,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArray([message], args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArray([message], args, false))); } function reportWatchStatus(state, message) { var _a, _b; @@ -117738,7 +120195,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - (_b = (_a = state.hostWithWatch).onWatchStatusChange) === null || _b === void 0 ? void 0 : _b.call(_a, ts.createCompilerDiagnostic.apply(void 0, __spreadArray([message], args)), state.host.getNewLine(), state.baseCompilerOptions); + (_b = (_a = state.hostWithWatch).onWatchStatusChange) === null || _b === void 0 ? void 0 : _b.call(_a, ts.createCompilerDiagnostic.apply(void 0, __spreadArray([message], args, false)), state.host.getNewLine(), state.baseCompilerOptions); } function reportErrors(_a, errors) { var host = _a.host; @@ -117912,8 +120369,9 @@ var ts; return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; - JsTyping.nodeCoreModuleList = [ + var unprefixedNodeCoreModuleList = [ "assert", + "assert/strict", "async_hooks", "buffer", "child_process", @@ -117922,14 +120380,18 @@ var ts; "constants", "crypto", "dgram", + "diagnostics_channel", "dns", + "dns/promises", "domain", "events", "fs", + "fs/promises", "http", "https", "http2", "inspector", + "module", "net", "os", "path", @@ -117940,16 +120402,24 @@ var ts; "readline", "repl", "stream", + "stream/promises", "string_decoder", "timers", + "timers/promises", "tls", + "trace_events", "tty", "url", "util", + "util/types", "v8", "vm", + "wasi", + "worker_threads", "zlib" ]; + JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:" + name; }); + JsTyping.nodeCoreModuleList = __spreadArray(__spreadArray([], unprefixedNodeCoreModuleList, true), JsTyping.prefixedNodeCoreModuleList, true); JsTyping.nodeCoreModules = new ts.Set(JsTyping.nodeCoreModuleList); function nonRelativeModuleNameForTypingCache(moduleName) { return JsTyping.nodeCoreModules.has(moduleName) ? "node" : moduleName; @@ -118275,6 +120745,21 @@ var ts; SemanticClassificationFormat["Original"] = "original"; SemanticClassificationFormat["TwentyTwenty"] = "2020"; })(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {})); + var CompletionTriggerKind; + (function (CompletionTriggerKind) { + /** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */ + CompletionTriggerKind[CompletionTriggerKind["Invoked"] = 1] = "Invoked"; + /** Completion was triggered by a trigger character. */ + CompletionTriggerKind[CompletionTriggerKind["TriggerCharacter"] = 2] = "TriggerCharacter"; + /** Completion was re-triggered as the current completion list is incomplete. */ + CompletionTriggerKind[CompletionTriggerKind["TriggerForIncompleteCompletions"] = 3] = "TriggerForIncompleteCompletions"; + })(CompletionTriggerKind = ts.CompletionTriggerKind || (ts.CompletionTriggerKind = {})); + var InlayHintKind; + (function (InlayHintKind) { + InlayHintKind["Type"] = "Type"; + InlayHintKind["Parameter"] = "Parameter"; + InlayHintKind["Enum"] = "Enum"; + })(InlayHintKind = ts.InlayHintKind || (ts.InlayHintKind = {})); var HighlightSpanKind; (function (HighlightSpanKind) { HighlightSpanKind["none"] = "none"; @@ -118435,7 +120920,10 @@ var ts; * interface Y { foo:number; } */ ScriptElementKind["memberVariableElement"] = "property"; - /** class X { constructor() { } } */ + /** + * class X { constructor() { } } + * class X { static { } } + */ ScriptElementKind["constructorImplementationElement"] = "constructor"; /** interface Y { ():number; } */ ScriptElementKind["callSignatureElement"] = "call"; @@ -118557,37 +121045,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 161 /* Parameter */: - case 199 /* BindingElement */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 289 /* PropertyAssignment */: - case 290 /* ShorthandPropertyAssignment */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 288 /* CatchClause */: - case 281 /* JsxAttribute */: + case 162 /* Parameter */: + case 201 /* BindingElement */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 291 /* PropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 290 /* CatchClause */: + case 283 /* JsxAttribute */: return 1 /* Value */; - case 160 /* TypeParameter */: - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 178 /* TypeLiteral */: + case 161 /* TypeParameter */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 180 /* TypeLiteral */: return 2 /* Type */; - case 335 /* JSDocTypedefTag */: + case 340 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 292 /* EnumMember */: - case 253 /* ClassDeclaration */: + case 294 /* EnumMember */: + case 255 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -118597,16 +121085,16 @@ var ts; else { return 4 /* Namespace */; } - case 256 /* EnumDeclaration */: - case 265 /* NamedImports */: - case 266 /* ImportSpecifier */: - case 261 /* ImportEqualsDeclaration */: - case 262 /* ImportDeclaration */: - case 267 /* ExportAssignment */: - case 268 /* ExportDeclaration */: + case 258 /* EnumDeclaration */: + case 267 /* NamedImports */: + case 268 /* ImportSpecifier */: + case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportDeclaration */: + case 269 /* ExportAssignment */: + case 270 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 298 /* SourceFile */: + case 300 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; @@ -118614,23 +121102,32 @@ var ts; ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); - if (node.kind === 298 /* SourceFile */) { + var parent = node.parent; + if (node.kind === 300 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 267 /* ExportAssignment */ - || node.parent.kind === 273 /* ExternalModuleReference */ - || node.parent.kind === 266 /* ImportSpecifier */ - || node.parent.kind === 263 /* ImportClause */ - || ts.isImportEqualsDeclaration(node.parent) && node === node.parent.name) { + else if (ts.isExportAssignment(parent) + || ts.isExportSpecifier(parent) + || ts.isExternalModuleReference(parent) + || ts.isImportSpecifier(parent) + || ts.isImportClause(parent) + || ts.isImportEqualsDeclaration(parent) && node === parent.name) { + var decl = parent; + while (decl) { + if (ts.isImportEqualsDeclaration(decl) || ts.isImportClause(decl) || ts.isExportDeclaration(decl)) { + return decl.isTypeOnly ? 2 /* Type */ : 7 /* All */; + } + decl = decl.parent; + } return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { return getMeaningFromRightHandSideOfImportEquals(node); } else if (ts.isDeclarationName(node)) { - return getMeaningFromDeclaration(node.parent); + return getMeaningFromDeclaration(parent); } - else if (ts.isEntityName(node) && (ts.isJSDocNameReference(node.parent) || ts.isJSDocLink(node.parent))) { + else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { return 7 /* All */; } else if (isTypeReference(node)) { @@ -118639,11 +121136,11 @@ var ts; else if (isNamespaceReference(node)) { return 4 /* Namespace */; } - else if (ts.isTypeParameterDeclaration(node.parent)) { - ts.Debug.assert(ts.isJSDocTemplateTag(node.parent.parent)); // Else would be handled by isDeclarationName + else if (ts.isTypeParameterDeclaration(parent)) { + ts.Debug.assert(ts.isJSDocTemplateTag(parent.parent)); // Else would be handled by isDeclarationName return 2 /* Type */; } - else if (ts.isLiteralTypeNode(node.parent)) { + else if (ts.isLiteralTypeNode(parent)) { // This might be T["name"], which is actually referencing a property and not a type. So allow both meanings. return 2 /* Type */ | 1 /* Value */; } @@ -118656,11 +121153,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 158 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 261 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 159 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 263 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 158 /* QualifiedName */) { + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -118672,27 +121169,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 158 /* QualifiedName */) { - while (root.parent && root.parent.kind === 158 /* QualifiedName */) { + if (root.parent.kind === 159 /* QualifiedName */) { + while (root.parent && root.parent.kind === 159 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 174 /* TypeReference */ && !isLastClause; + return root.parent.kind === 176 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 202 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 202 /* PropertyAccessExpression */) { + if (root.parent.kind === 204 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 204 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 224 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 287 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 226 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 289 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 253 /* ClassDeclaration */ && root.parent.parent.token === 116 /* ImplementsKeyword */) || - (decl.kind === 254 /* InterfaceDeclaration */ && root.parent.parent.token === 93 /* ExtendsKeyword */); + return (decl.kind === 255 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || + (decl.kind === 256 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); } return false; } @@ -118701,17 +121198,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 188 /* ThisType */: + case 190 /* ThisType */: return true; } switch (node.parent.kind) { - case 174 /* TypeReference */: + case 176 /* TypeReference */: return true; - case 196 /* ImportType */: + case 198 /* ImportType */: return !node.parent.isTypeOf; - case 224 /* ExpressionWithTypeArguments */: + case 226 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -118778,7 +121275,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 246 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 248 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -118839,22 +121336,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 289 /* PropertyAssignment */: - case 292 /* EnumMember */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 257 /* ModuleDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 291 /* PropertyAssignment */: + case 294 /* EnumMember */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 259 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 159 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return true; - case 192 /* LiteralType */: - return node.parent.parent.kind === 190 /* IndexedAccessType */; + case 194 /* LiteralType */: + return node.parent.parent.kind === 192 /* IndexedAccessType */; default: return false; } @@ -118878,17 +121375,17 @@ var ts; return undefined; } switch (node.kind) { - case 298 /* SourceFile */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 256 /* EnumDeclaration */: - case 257 /* ModuleDeclaration */: + case 300 /* SourceFile */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 258 /* EnumDeclaration */: + case 259 /* ModuleDeclaration */: return node; } } @@ -118896,54 +121393,56 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 298 /* SourceFile */: + case 300 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: return "class" /* classElement */; - case 254 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 255 /* TypeAliasDeclaration */: - case 328 /* JSDocCallbackTag */: - case 335 /* JSDocTypedefTag */: + case 256 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 257 /* TypeAliasDeclaration */: + case 333 /* JSDocCallbackTag */: + case 340 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 256 /* EnumDeclaration */: return "enum" /* enumElement */; - case 250 /* VariableDeclaration */: + case 258 /* EnumDeclaration */: return "enum" /* enumElement */; + case 252 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 199 /* BindingElement */: + case 201 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 210 /* ArrowFunction */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: return "function" /* functionElement */; - case 168 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 169 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: + case 170 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 171 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: var initializer = node.initializer; return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 290 /* ShorthandPropertyAssignment */: - case 291 /* SpreadAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 292 /* ShorthandPropertyAssignment */: + case 293 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 172 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 171 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 170 /* CallSignature */: return "call" /* callSignatureElement */; - case 167 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 160 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 292 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 161 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 261 /* ImportEqualsDeclaration */: - case 266 /* ImportSpecifier */: - case 271 /* ExportSpecifier */: - case 264 /* NamespaceImport */: - case 270 /* NamespaceExport */: + case 174 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 173 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 172 /* CallSignature */: return "call" /* callSignatureElement */; + case 169 /* Constructor */: + case 168 /* ClassStaticBlockDeclaration */: + return "constructor" /* constructorImplementationElement */; + case 161 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 294 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 162 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 263 /* ImportEqualsDeclaration */: + case 268 /* ImportSpecifier */: + case 273 /* ExportSpecifier */: + case 266 /* NamespaceImport */: + case 272 /* NamespaceExport */: return "alias" /* alias */; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -118970,9 +121469,9 @@ var ts; return "" /* unknown */; } } - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: var scriptKind = getNodeKind(node.expression); // If the expression didn't come back with something (like it does for an identifiers) return scriptKind === "" /* unknown */ ? "const" /* constElement */ : scriptKind; @@ -118990,12 +121489,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 78 /* Identifier */: + case 79 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 161 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 162 /* Parameter */; default: return false; } @@ -119060,42 +121559,42 @@ var ts; return false; } switch (n.kind) { - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 256 /* EnumDeclaration */: - case 201 /* ObjectLiteralExpression */: - case 197 /* ObjectBindingPattern */: - case 178 /* TypeLiteral */: - case 231 /* Block */: - case 258 /* ModuleBlock */: - case 259 /* CaseBlock */: - case 265 /* NamedImports */: - case 269 /* NamedExports */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 258 /* EnumDeclaration */: + case 203 /* ObjectLiteralExpression */: + case 199 /* ObjectBindingPattern */: + case 180 /* TypeLiteral */: + case 233 /* Block */: + case 260 /* ModuleBlock */: + case 261 /* CaseBlock */: + case 267 /* NamedImports */: + case 271 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 288 /* CatchClause */: + case 290 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 205 /* NewExpression */: + case 207 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 204 /* CallExpression */: - case 208 /* ParenthesizedExpression */: - case 187 /* ParenthesizedType */: + case 206 /* CallExpression */: + case 210 /* ParenthesizedExpression */: + case 189 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 175 /* FunctionType */: - case 176 /* ConstructorType */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 171 /* ConstructSignature */: - case 170 /* CallSignature */: - case 210 /* ArrowFunction */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 173 /* ConstructSignature */: + case 172 /* CallSignature */: + case 212 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -119105,65 +121604,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 235 /* IfStatement */: + case 237 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 200 /* ArrayLiteralExpression */: - case 198 /* ArrayBindingPattern */: - case 203 /* ElementAccessExpression */: - case 159 /* ComputedPropertyName */: - case 180 /* TupleType */: + case 202 /* ArrayLiteralExpression */: + case 200 /* ArrayBindingPattern */: + case 205 /* ElementAccessExpression */: + case 160 /* ComputedPropertyName */: + case 182 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 172 /* IndexSignature */: + case 174 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 285 /* CaseClause */: - case 286 /* DefaultClause */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 237 /* WhileStatement */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 239 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 236 /* DoStatement */: + case 238 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 114 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 177 /* TypeQuery */: + case 179 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 212 /* TypeOfExpression */: - case 211 /* DeleteExpression */: - case 213 /* VoidExpression */: - case 220 /* YieldExpression */: - case 221 /* SpreadElement */: + case 214 /* TypeOfExpression */: + case 213 /* DeleteExpression */: + case 215 /* VoidExpression */: + case 222 /* YieldExpression */: + case 223 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 219 /* TemplateExpression */: + case 221 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 229 /* TemplateSpan */: + case 231 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 268 /* ExportDeclaration */: - case 262 /* ImportDeclaration */: + case 270 /* ExportDeclaration */: + case 264 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 218 /* ConditionalExpression */: + case 220 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -119223,13 +121722,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 87 /* DefaultKeyword */; + return node.kind === 88 /* DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 83 /* ClassKeyword */; + return node.kind === 84 /* ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 97 /* FunctionKeyword */; + return node.kind === 98 /* FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -119238,7 +121737,7 @@ var ts; if (ts.isClassDeclaration(node)) { // for class and function declarations, use the `default` modifier // when the declaration is unnamed. - var defaultModifier = ts.find(node.modifiers, isDefaultModifier); + var defaultModifier = node.modifiers && ts.find(node.modifiers, isDefaultModifier); if (defaultModifier) return defaultModifier; } @@ -119282,6 +121781,10 @@ var ts; if (contextualType) { return contextualType; } + var parent = node.parent; + if (parent && ts.isBinaryExpression(parent) && isEqualityOperatorKind(parent.operatorToken.kind)) { + return checker.getTypeAtLocation(node === parent.left ? parent.right : parent.left); + } var ancestorTypeNode = getAncestorTypeNode(node); return ancestorTypeNode && checker.getTypeAtLocation(ancestorTypeNode); } @@ -119289,11 +121792,11 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: return getAdjustedLocationForClass(node); - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -119383,30 +121886,30 @@ var ts; // // NOTE: If the node is a modifier, we don't adjust its location if it is the `default` modifier as that is handled // specially by `getSymbolAtLocation`. - if (ts.isModifier(node) && (forRename || node.kind !== 87 /* DefaultKeyword */) ? ts.contains(parent.modifiers, node) : - node.kind === 83 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 97 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 117 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 91 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 149 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 140 /* NamespaceKeyword */ || node.kind === 139 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 99 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 134 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 146 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? ts.contains(parent.modifiers, node) : + node.kind === 84 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : + node.kind === 98 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : + node.kind === 118 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : + node.kind === 92 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : + node.kind === 150 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 141 /* NamespaceKeyword */ || node.kind === 140 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 135 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 147 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 112 /* VarKeyword */ || node.kind === 84 /* ConstKeyword */ || node.kind === 118 /* LetKeyword */) && + if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 149 /* TypeKeyword */) { + if (node.kind === 150 /* TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -119432,7 +121935,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 126 /* AsKeyword */) { + if (node.kind === 127 /* AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -119448,13 +121951,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 99 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 92 /* ExportKeyword */) { + if (node.kind === 93 /* ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -119473,12 +121976,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 143 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 144 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 153 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 154 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -119486,13 +121989,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 93 /* ExtendsKeyword */ || node.kind === 116 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 93 /* ExtendsKeyword */) { + if (node.kind === 94 /* ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -119503,20 +122006,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 135 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 136 /* InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 100 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 138 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 138 /* KeyOfKeyword */ && + if (node.kind === 139 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 139 /* KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 142 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 142 /* ReadonlyKeyword */ && + if (node.kind === 143 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 143 /* ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -119531,29 +122034,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 102 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 113 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 111 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 130 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 124 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 88 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 131 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 100 /* InKeyword */ || node.kind === 101 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 126 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 100 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 157 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || + node.kind === 158 /* OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -119723,7 +122226,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 298 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 300 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // 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. @@ -119796,17 +122299,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 284 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 286 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 284 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 286 /* JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 277 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 279 /* JsxClosingElement */) { return true; } return false; @@ -119837,17 +122340,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 275 /* JsxSelfClosingElement */ && node.kind <= 284 /* JsxExpression */ + if (node.kind >= 277 /* JsxSelfClosingElement */ && node.kind <= 286 /* JsxExpression */ || node.kind === 11 /* JsxText */ || node.kind === 29 /* LessThanToken */ || node.kind === 31 /* GreaterThanToken */ - || node.kind === 78 /* Identifier */ + || node.kind === 79 /* Identifier */ || node.kind === 19 /* CloseBraceToken */ || node.kind === 18 /* OpenBraceToken */ || node.kind === 43 /* SlashToken */) { node = node.parent; } - else if (node.kind === 274 /* JsxElement */) { + else if (node.kind === 276 /* JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -119986,16 +122489,16 @@ var ts; break; case 38 /* EqualsGreaterThanToken */: // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: // falls through - case 111 /* TypeOfKeyword */: - case 93 /* ExtendsKeyword */: - case 138 /* KeyOfKeyword */: + case 112 /* TypeOfKeyword */: + case 94 /* ExtendsKeyword */: + case 139 /* KeyOfKeyword */: case 24 /* DotToken */: case 51 /* BarToken */: case 57 /* QuestionToken */: @@ -120045,7 +122548,7 @@ var ts; result.push("protected" /* protectedMemberModifier */); if (flags & 4 /* Public */) result.push("public" /* publicMemberModifier */); - if (flags & 32 /* Static */) + if (flags & 32 /* Static */ || ts.isClassStaticBlockDeclaration(node)) result.push("static" /* staticModifier */); if (flags & 128 /* Abstract */) result.push("abstract" /* abstractModifier */); @@ -120055,16 +122558,16 @@ var ts; result.push("deprecated" /* deprecatedModifier */); if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); - if (node.kind === 267 /* ExportAssignment */) + if (node.kind === 269 /* ExportAssignment */) result.push("export" /* exportedModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 174 /* TypeReference */ || node.kind === 204 /* CallExpression */) { + if (node.kind === 176 /* TypeReference */ || node.kind === 206 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 253 /* ClassDeclaration */ || node.kind === 254 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 255 /* ClassDeclaration */ || node.kind === 256 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -120084,7 +122587,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 77 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -120094,9 +122597,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: return true; } return false; @@ -120109,18 +122612,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 200 /* ArrayLiteralExpression */ || - node.kind === 201 /* ObjectLiteralExpression */) { + if (node.kind === 202 /* ArrayLiteralExpression */ || + node.kind === 203 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 217 /* BinaryExpression */ && + if (node.parent.kind === 219 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 62 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 240 /* ForOfStatement */ && + if (node.parent.kind === 242 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -120128,7 +122631,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 289 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 291 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -120190,32 +122693,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 128 /* AnyKeyword */, - 127 /* AssertsKeyword */, - 155 /* BigIntKeyword */, - 131 /* BooleanKeyword */, - 94 /* FalseKeyword */, - 135 /* InferKeyword */, - 138 /* KeyOfKeyword */, - 141 /* NeverKeyword */, - 103 /* NullKeyword */, - 144 /* NumberKeyword */, - 145 /* ObjectKeyword */, - 142 /* ReadonlyKeyword */, - 147 /* StringKeyword */, - 148 /* SymbolKeyword */, - 109 /* TrueKeyword */, - 113 /* VoidKeyword */, - 150 /* UndefinedKeyword */, - 151 /* UniqueKeyword */, - 152 /* UnknownKeyword */, + 129 /* AnyKeyword */, + 128 /* AssertsKeyword */, + 156 /* BigIntKeyword */, + 132 /* BooleanKeyword */, + 95 /* FalseKeyword */, + 136 /* InferKeyword */, + 139 /* KeyOfKeyword */, + 142 /* NeverKeyword */, + 104 /* NullKeyword */, + 145 /* NumberKeyword */, + 146 /* ObjectKeyword */, + 143 /* ReadonlyKeyword */, + 148 /* StringKeyword */, + 149 /* SymbolKeyword */, + 110 /* TrueKeyword */, + 114 /* VoidKeyword */, + 151 /* UndefinedKeyword */, + 152 /* UniqueKeyword */, + 153 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 149 /* TypeKeyword */; + return node.kind === 150 /* TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; /** True if the symbol is for an external module, as opposed to a namespace. */ @@ -120248,7 +122751,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 159 /* ComputedPropertyName */ + return name.kind === 160 /* ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name); @@ -120277,7 +122780,6 @@ var ts; getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache) || program.getSymlinkCache, getModuleSpecifierCache: ts.maybeBind(host, host.getModuleSpecifierCache), getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), - getSourceFiles: function () { return program.getSourceFiles(); }, redirectTargetsMap: program.redirectTargetsMap, getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); }, isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); }, @@ -120346,7 +122848,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 78 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -120390,7 +122892,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 233 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 235 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate); var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports]; if (!existingImportStatements.length) { @@ -120468,7 +122970,7 @@ var ts; // Display-part writer helpers // #region function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 161 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 162 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -120516,7 +123018,7 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -120679,7 +123181,10 @@ var ts; ts.linkPart = linkPart; function buildLinkParts(link, checker) { var _a; - var parts = [linkPart("{@link ")]; + var prefix = ts.isJSDocLink(link) ? "link" + : ts.isJSDocLinkCode(link) ? "linkcode" + : "linkplain"; + var parts = [linkPart("{@" + prefix + " ")]; if (!link.name) { if (link.text) { parts.push(linkTextPart(link.text)); @@ -120695,7 +123200,7 @@ var ts; } } else { - parts.push(linkTextPart(ts.getTextOfNode(link.name) + link.text)); + parts.push(linkTextPart(ts.getTextOfNode(link.name) + " " + link.text)); } } parts.push(linkPart("}")); @@ -120824,9 +123329,13 @@ var ts; } ts.getSynthesizedDeepCloneWithReplacements = getSynthesizedDeepCloneWithReplacements; function getSynthesizedDeepCloneWorker(node, replaceNode) { - var visited = replaceNode ? - ts.visitEachChild(node, function (n) { return getSynthesizedDeepCloneWithReplacements(n, /*includeTrivia*/ true, replaceNode); }, ts.nullTransformationContext) : - ts.visitEachChild(node, getSynthesizedDeepClone, ts.nullTransformationContext); + var nodeClone = replaceNode + ? function (n) { return getSynthesizedDeepCloneWithReplacements(n, /*includeTrivia*/ true, replaceNode); } + : getSynthesizedDeepClone; + var nodesClone = replaceNode + ? function (ns) { return ns && getSynthesizedDeepClonesWithReplacements(ns, /*includeTrivia*/ true, replaceNode); } + : function (ns) { return ns && getSynthesizedDeepClones(ns); }; + var visited = ts.visitEachChild(node, nodeClone, ts.nullTransformationContext, nodesClone, nodeClone); if (visited === node) { // This only happens for leaf nodes - internal nodes always see their children change. var clone_1 = ts.isStringLiteral(node) ? ts.setOriginalNode(ts.factory.createStringLiteralFromNode(node), node) : @@ -120834,8 +123343,8 @@ var ts; ts.factory.cloneNode(node); return ts.setTextRange(clone_1, node); } - // PERF: As an optimization, rather than calling getSynthesizedClone, we'll update - // the new node created by visitEachChild with the extra changes getSynthesizedClone + // PERF: As an optimization, rather than calling factory.cloneNode, we'll update + // the new node created by visitEachChild with the extra changes factory.cloneNode // would have made. visited.parent = undefined; return visited; @@ -120995,15 +123504,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 205 /* NewExpression */: + case 207 /* NewExpression */: return checker.getContextualType(parent); - case 217 /* BinaryExpression */: { + case 219 /* BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 285 /* CaseClause */: + case 287 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -121033,8 +123542,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 219 /* TemplateExpression */: - case 206 /* TaggedTemplateExpression */: + case 221 /* TemplateExpression */: + case 208 /* TaggedTemplateExpression */: return true; default: return false; @@ -121057,6 +123566,7 @@ var ts; var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, reportPrivateInBaseOfClassExpression: notAccessible, @@ -121067,41 +123577,41 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 170 /* CallSignature */ - || kind === 171 /* ConstructSignature */ - || kind === 172 /* IndexSignature */ - || kind === 163 /* PropertySignature */ - || kind === 165 /* MethodSignature */; + return kind === 172 /* CallSignature */ + || kind === 173 /* ConstructSignature */ + || kind === 174 /* IndexSignature */ + || kind === 164 /* PropertySignature */ + || kind === 166 /* MethodSignature */; } ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 252 /* FunctionDeclaration */ - || kind === 167 /* Constructor */ - || kind === 166 /* MethodDeclaration */ - || kind === 168 /* GetAccessor */ - || kind === 169 /* SetAccessor */; + return kind === 254 /* FunctionDeclaration */ + || kind === 169 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 170 /* GetAccessor */ + || kind === 171 /* SetAccessor */; } ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 257 /* ModuleDeclaration */; + return kind === 259 /* ModuleDeclaration */; } ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 233 /* VariableStatement */ - || kind === 234 /* ExpressionStatement */ - || kind === 236 /* DoStatement */ - || kind === 241 /* ContinueStatement */ - || kind === 242 /* BreakStatement */ - || kind === 243 /* ReturnStatement */ - || kind === 247 /* ThrowStatement */ - || kind === 249 /* DebuggerStatement */ - || kind === 164 /* PropertyDeclaration */ - || kind === 255 /* TypeAliasDeclaration */ - || kind === 262 /* ImportDeclaration */ - || kind === 261 /* ImportEqualsDeclaration */ - || kind === 268 /* ExportDeclaration */ - || kind === 260 /* NamespaceExportDeclaration */ - || kind === 267 /* ExportAssignment */; + return kind === 235 /* VariableStatement */ + || kind === 236 /* ExpressionStatement */ + || kind === 238 /* DoStatement */ + || kind === 243 /* ContinueStatement */ + || kind === 244 /* BreakStatement */ + || kind === 245 /* ReturnStatement */ + || kind === 249 /* ThrowStatement */ + || kind === 251 /* DebuggerStatement */ + || kind === 165 /* PropertyDeclaration */ + || kind === 257 /* TypeAliasDeclaration */ + || kind === 264 /* ImportDeclaration */ + || kind === 263 /* ImportEqualsDeclaration */ + || kind === 270 /* ExportDeclaration */ + || kind === 262 /* NamespaceExportDeclaration */ + || kind === 269 /* ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); @@ -121131,7 +123641,7 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 236 /* DoStatement */) { + if (node.kind === 238 /* DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); @@ -121286,9 +123796,7 @@ var ts; [8 /* OptionalDependencies */, info.optionalDependencies], [4 /* PeerDependencies */, info.peerDependencies], ]; - return __assign(__assign({}, info), { parseable: !!content, fileName: fileName, - get: get, - has: function (dependencyName, inGroups) { + return __assign(__assign({}, info), { parseable: !!content, fileName: fileName, get: get, has: function (dependencyName, inGroups) { return !!get(dependencyName, inGroups); } }); function get(dependencyName, inGroups) { @@ -121305,7 +123813,7 @@ var ts; } } ts.createPackageJsonInfo = createPackageJsonInfo; - function createPackageJsonImportFilter(fromFile, host) { + function createPackageJsonImportFilter(fromFile, preferences, host) { var packageJsons = ((host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || getPackageJsonsVisibleToFile(fromFile.fileName, host)).filter(function (p) { return p.parseable; }); var usesNodeCoreModules; return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; @@ -121373,7 +123881,7 @@ var ts; if (!ts.stringContains(importedFileName, "node_modules")) { return undefined; } - var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, preferences); if (!specifier) { return undefined; } @@ -121535,6 +124043,24 @@ var ts; return ts.isInJSFile(declaration) || !ts.findAncestor(declaration, ts.isGlobalScopeAugmentation); } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; + function isDeprecatedDeclaration(decl) { + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + } + ts.isDeprecatedDeclaration = isDeprecatedDeclaration; + function shouldUseUriStyleNodeCoreModules(file, program) { + var decisionFromFile = ts.firstDefined(file.imports, function (node) { + if (ts.JsTyping.nodeCoreModules.has(node.text)) { + return ts.startsWith(node.text, "node:"); + } + }); + return decisionFromFile !== null && decisionFromFile !== void 0 ? decisionFromFile : program.usesUriStyleNodeCoreModules; + } + ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules; + // #endregion +})(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { var ImportKind; (function (ImportKind) { ImportKind[ImportKind["Named"] = 0] = "Named"; @@ -121549,49 +124075,68 @@ var ts; ExportKind[ExportKind["ExportEquals"] = 2] = "ExportEquals"; ExportKind[ExportKind["UMD"] = 3] = "UMD"; })(ExportKind = ts.ExportKind || (ts.ExportKind = {})); - function createExportMapCache() { - var cache; - var projectVersion; + function createCacheableExportInfoMap(host) { + var exportInfoId = 1; + var exportInfo = ts.createMultiMap(); + var symbols = new ts.Map(); var usableByFileName; - var wrapped = { - isEmpty: function () { - return !cache; - }, + var cache = { + isUsableByFile: function (importingFile) { return importingFile === usableByFileName; }, + isEmpty: function () { return !exportInfo.size; }, clear: function () { - cache = undefined; - projectVersion = undefined; + exportInfo.clear(); + symbols.clear(); + usableByFileName = undefined; }, - set: function (suggestions, version) { - cache = suggestions; - if (version) { - projectVersion = version; - } + add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, scriptTarget, checker) { + if (importingFile !== usableByFileName) { + cache.clear(); + usableByFileName = importingFile; + } + var isDefault = exportKind === 1 /* Default */; + var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol; + // A re-export merged with an export from a module augmentation can result in `symbol` + // being an external module symbol; the name it is re-exported by will be `symbolTableKey` + // (which comes from the keys of `moduleSymbol.exports`.) + var importedName = ts.isExternalModuleSymbol(namedSymbol) + ? ts.unescapeLeadingUnderscores(symbolTableKey) + : ts.getNameForExportedSymbol(namedSymbol, scriptTarget); + var moduleName = ts.stripQuotes(moduleSymbol.name); + var id = exportInfoId++; + var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol; + var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol; + if (!storedSymbol || !storedModuleSymbol) + symbols.set(id, [symbol, moduleSymbol]); + exportInfo.add(key(importedName, symbol, moduleName, checker), { + id: id, + symbolTableKey: symbolTableKey, + symbolName: importedName, + moduleName: moduleName, + moduleFile: moduleFile, + moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, + exportKind: exportKind, + targetFlags: ts.skipAlias(symbol, checker).flags, + isFromPackageJson: isFromPackageJson, + symbol: storedSymbol, + moduleSymbol: storedModuleSymbol, + }); }, - get: function (file, checker, version) { - if (usableByFileName && file !== usableByFileName) { - return undefined; - } - if (version && projectVersion === version) { - return cache; - } - cache === null || cache === void 0 ? void 0 : cache.forEach(function (infos) { - var _a, _b, _c; - for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { - var info = infos_1[_i]; - // If the symbol/moduleSymbol was a merged symbol, it will have a new identity - // in the checker, even though the symbols to merge are the same (guaranteed by - // cache invalidation in synchronizeHostData). - if ((_a = info.symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) { - info.symbol = checker.getMergedSymbol(info.exportKind === 1 /* Default */ - ? (_b = info.symbol.declarations[0].localSymbol) !== null && _b !== void 0 ? _b : info.symbol.declarations[0].symbol - : info.symbol.declarations[0].symbol); - } - if ((_c = info.moduleSymbol.declarations) === null || _c === void 0 ? void 0 : _c.length) { - info.moduleSymbol = checker.getMergedSymbol(info.moduleSymbol.declarations[0].symbol); - } - } + get: function (importingFile, importedName, symbol, moduleName, checker) { + if (importingFile !== usableByFileName) + return; + var result = exportInfo.get(key(importedName, symbol, moduleName, checker)); + return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo); + }, + forEach: function (importingFile, action) { + if (importingFile !== usableByFileName) + return; + exportInfo.forEach(function (info, key) { + var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName; + action(info.map(rehydrateCachedInfo), symbolName, !!ambientModuleName); }); - return cache; + }, + releaseSymbols: function () { + symbols.clear(); }, onFileChanged: function (oldSourceFile, newSourceFile, typeAcquisitionEnabled) { if (fileIsGlobalOnly(oldSourceFile) && fileIsGlobalOnly(newSourceFile)) { @@ -121601,13 +124146,13 @@ var ts; if (usableByFileName && usableByFileName !== newSourceFile.path || // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. - typeAcquisitionEnabled && consumesNodeCoreModules(oldSourceFile) !== consumesNodeCoreModules(newSourceFile) || + typeAcquisitionEnabled && ts.consumesNodeCoreModules(oldSourceFile) !== ts.consumesNodeCoreModules(newSourceFile) || // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. // Changes elsewhere in the file can change the *type* of an export in a module augmentation, // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. !ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || !ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { - this.clear(); + cache.clear(); return true; } usableByFileName = newSourceFile.path; @@ -121615,9 +124160,63 @@ var ts; }, }; if (ts.Debug.isDebugging) { - Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); + Object.defineProperty(cache, "__cache", { get: function () { return exportInfo; } }); + } + return cache; + function rehydrateCachedInfo(info) { + if (info.symbol && info.moduleSymbol) + return info; + var id = info.id, exportKind = info.exportKind, targetFlags = info.targetFlags, isFromPackageJson = info.isFromPackageJson, moduleFileName = info.moduleFileName; + var _a = symbols.get(id) || ts.emptyArray, cachedSymbol = _a[0], cachedModuleSymbol = _a[1]; + if (cachedSymbol && cachedModuleSymbol) { + return { + symbol: cachedSymbol, + moduleSymbol: cachedModuleSymbol, + moduleFileName: moduleFileName, + exportKind: exportKind, + targetFlags: targetFlags, + isFromPackageJson: isFromPackageJson, + }; + } + var checker = (isFromPackageJson + ? host.getPackageJsonAutoImportProvider() + : host.getCurrentProgram()).getTypeChecker(); + var moduleSymbol = info.moduleSymbol || cachedModuleSymbol || ts.Debug.checkDefined(info.moduleFile + ? checker.getMergedSymbol(info.moduleFile.symbol) + : checker.tryFindAmbientModule(info.moduleName)); + var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportEquals */ + ? checker.resolveExternalModuleSymbol(moduleSymbol) + : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '" + info.symbolName + "' by key '" + info.symbolTableKey + "' in module " + moduleSymbol.name); + symbols.set(id, [symbol, moduleSymbol]); + return { + symbol: symbol, + moduleSymbol: moduleSymbol, + moduleFileName: moduleFileName, + exportKind: exportKind, + targetFlags: targetFlags, + isFromPackageJson: isFromPackageJson, + }; + } + function key(importedName, symbol, moduleName, checker) { + var unquoted = ts.stripQuotes(moduleName); + var moduleKey = ts.isExternalModuleNameRelative(unquoted) ? "/" : unquoted; + var target = ts.skipAlias(symbol, checker); + return importedName + "|" + createSymbolKey(target) + "|" + moduleKey; + } + function parseKey(key) { + var symbolName = key.substring(0, key.indexOf("|")); + var moduleKey = key.substring(key.lastIndexOf("|") + 1); + var ambientModuleName = moduleKey === "/" ? undefined : moduleKey; + return { symbolName: symbolName, ambientModuleName: ambientModuleName }; + } + function createSymbolKey(symbol) { + var key = symbol.name; + while (symbol.parent) { + key += "," + symbol.parent.name; + symbol = symbol.parent; + } + return key; } - return wrapped; function fileIsGlobalOnly(file) { return !file.commonJsModuleIndicator && !file.externalModuleIndicator && !file.moduleAugmentations && !file.ambientModuleNames; } @@ -121644,44 +124243,14 @@ var ts; return true; } } - ts.createExportMapCache = createExportMapCache; - function createModuleSpecifierCache() { - var cache; - var importingFileName; - var wrapped = { - get: function (fromFileName, toFileName) { - if (!cache || fromFileName !== importingFileName) - return undefined; - return cache.get(toFileName); - }, - set: function (fromFileName, toFileName, moduleSpecifiers) { - if (cache && fromFileName !== importingFileName) { - cache.clear(); - } - importingFileName = fromFileName; - (cache || (cache = new ts.Map())).set(toFileName, moduleSpecifiers); - }, - clear: function () { - cache = undefined; - importingFileName = undefined; - }, - count: function () { - return cache ? cache.size : 0; - } - }; - if (ts.Debug.isDebugging) { - Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); - } - return wrapped; - } - ts.createModuleSpecifierCache = createModuleSpecifierCache; - function isImportableFile(program, from, to, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) { + ts.createCacheableExportInfoMap = createCacheableExportInfoMap; + function isImportableFile(program, from, to, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) { var _a; if (from === to) return false; - var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path); - if (cachedResult !== undefined) { - return !!cachedResult; + var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path, preferences); + if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isAutoImportable) !== undefined) { + return cachedResult.isAutoImportable; } var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); @@ -121694,9 +124263,9 @@ var ts; isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); }); if (packageJsonFilter) { - var isImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); - moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.set(from.path, to.path, isImportable); - return isImportable; + var isAutoImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); + moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setIsAutoImportable(from.path, to.path, preferences, isAutoImportable); + return isAutoImportable; } return hasImportablePath; } @@ -121713,7 +124282,126 @@ var ts; || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); } - // #endregion + function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) { + var _a, _b; + forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); + var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)); + if (autoImportProvider) { + var start = ts.timestamp(); + forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start)); + } + } + ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; + function forEachExternalModule(checker, allSourceFiles, cb) { + for (var _i = 0, _a = checker.getAmbientModules(); _i < _a.length; _i++) { + var ambient = _a[_i]; + if (!ts.stringContains(ambient.name, "*")) { + cb(ambient, /*sourceFile*/ undefined); + } + } + for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) { + var sourceFile = allSourceFiles_1[_b]; + if (ts.isExternalOrCommonJsModule(sourceFile)) { + cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile); + } + } + } + function getExportInfoMap(importingFile, host, program, cancellationToken) { + var _a, _b, _c, _d, _e; + var start = ts.timestamp(); + // Pulling the AutoImportProvider project will trigger its updateGraph if pending, + // which will invalidate the export map cache if things change, so pull it before + // checking the cache. + (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host); + var cache = ((_b = host.getCachedExportInfoMap) === null || _b === void 0 ? void 0 : _b.call(host)) || createCacheableExportInfoMap({ + getCurrentProgram: function () { return program; }, + getPackageJsonAutoImportProvider: function () { var _a; return (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host); }, + }); + if (cache.isUsableByFile(importingFile.path)) { + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "getExportInfoMap: cache hit"); + return cache; + } + (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results"); + var compilerOptions = program.getCompilerOptions(); + var scriptTarget = ts.getEmitScriptTarget(compilerOptions); + var moduleCount = 0; + forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) { + if (++moduleCount % 100 === 0) + cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested(); + var seenExports = new ts.Map(); + var checker = program.getTypeChecker(); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + // Note: I think we shouldn't actually see resolved module symbols here, but weird merges + // can cause it to happen: see 'completionsImport_mergedReExport.ts' + if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { + cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, scriptTarget, checker); + } + checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { + if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, exported)) { + cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, scriptTarget, checker); + } + }); + }); + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + return cache; + } + ts.getExportInfoMap = getExportInfoMap; + function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(moduleSymbol, checker); + if (!exported) + return undefined; + var symbol = exported.symbol, exportKind = exported.exportKind; + var info = getDefaultExportInfoWorker(symbol, checker, compilerOptions); + return info && __assign({ symbol: symbol, exportKind: exportKind }, info); + } + ts.getDefaultLikeExportInfo = getDefaultLikeExportInfo; + function isImportableSymbol(symbol, checker) { + return !checker.isUndefinedSymbol(symbol) && !checker.isUnknownSymbol(symbol) && !ts.isKnownSymbol(symbol) && !ts.isPrivateIdentifierSymbol(symbol); + } + function getDefaultLikeExportWorker(moduleSymbol, checker) { + var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) + return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ }; + var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); + if (defaultExport) + return { symbol: defaultExport, exportKind: 1 /* Default */ }; + } + function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { + var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); + if (localSymbol) + return { symbolForMeaning: localSymbol, name: localSymbol.name }; + var name = getNameForExportDefault(defaultExport); + if (name !== undefined) + return { symbolForMeaning: defaultExport, name: name }; + if (defaultExport.flags & 2097152 /* Alias */) { + var aliased = checker.getImmediateAliasedSymbol(defaultExport); + if (aliased && aliased.parent) { + // - `aliased` will be undefined if the module is exporting an unresolvable name, + // but we can still offer completions for it. + // - `aliased.parent` will be undefined if the module is exporting `globalThis.something`, + // or another expression that resolves to a global. + return getDefaultExportInfoWorker(aliased, checker, compilerOptions); + } + } + if (defaultExport.escapedName !== "default" /* Default */ && + defaultExport.escapedName !== "export=" /* ExportEquals */) { + return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; + } + return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; + } + function getNameForExportDefault(symbol) { + return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { + var _a; + if (ts.isExportAssignment(declaration)) { + return (_a = ts.tryCast(ts.skipOuterExpressions(declaration.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; + } + else if (ts.isExportSpecifier(declaration)) { + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); + return declaration.propertyName && declaration.propertyName.text; + } + }); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -121796,13 +124484,13 @@ var ts; function handleToken() { switch (token) { case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; case 29 /* LessThanToken */: - if (lastNonTriviaToken === 78 /* Identifier */) { + if (lastNonTriviaToken === 79 /* Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; @@ -121815,16 +124503,16 @@ var ts; angleBracketStack--; } break; - case 128 /* AnyKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: + case 129 /* AnyKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* 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 = 78 /* Identifier */; + token = 79 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -121863,14 +124551,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 78 /* Identifier */; + token = 79 /* Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.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 = 78 /* Identifier */; + token = 79 /* Identifier */; } } } @@ -121884,19 +124572,19 @@ 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 = ts.arrayToNumericMap([ - 78 /* Identifier */, + 79 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 107 /* ThisKeyword */, + 108 /* ThisKeyword */, 45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 109 /* TrueKeyword */, - 94 /* FalseKeyword */, + 110 /* TrueKeyword */, + 95 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -122008,10 +124696,10 @@ var ts; return true; } switch (keyword2) { - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - case 132 /* ConstructorKeyword */: - case 123 /* StaticKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + case 133 /* ConstructorKeyword */: + case 124 /* StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -122056,9 +124744,9 @@ var ts; case 31 /* GreaterThanToken */: case 32 /* LessThanEqualsToken */: case 33 /* GreaterThanEqualsToken */: - case 101 /* InstanceOfKeyword */: - case 100 /* InKeyword */: - case 126 /* AsKeyword */: + case 102 /* InstanceOfKeyword */: + case 101 /* InKeyword */: + case 127 /* AsKeyword */: case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: @@ -122068,23 +124756,23 @@ var ts; case 51 /* BarToken */: case 55 /* AmpersandAmpersandToken */: case 56 /* BarBarToken */: - case 73 /* BarEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 62 /* EqualsToken */: + case 74 /* BarEqualsToken */: + case 73 /* AmpersandEqualsToken */: + case 78 /* CaretEqualsToken */: + case 70 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 64 /* PlusEqualsToken */: + case 65 /* MinusEqualsToken */: + case 66 /* AsteriskEqualsToken */: + case 68 /* SlashEqualsToken */: + case 69 /* PercentEqualsToken */: + case 63 /* EqualsToken */: case 27 /* CommaToken */: case 60 /* QuestionQuestionToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return true; default: return false; @@ -122110,7 +124798,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 77 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -122129,7 +124817,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 78 /* Identifier */: + case 79 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -122154,13 +124842,13 @@ 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 257 /* ModuleDeclaration */: - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 252 /* FunctionDeclaration */: - case 222 /* ClassExpression */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 259 /* ModuleDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 254 /* FunctionDeclaration */: + case 224 /* ClassExpression */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -122382,46 +125070,46 @@ var ts; pos = tag.tagName.end; var commentStart = tag.tagName.end; switch (tag.kind) { - case 330 /* JSDocParameterTag */: + case 335 /* JSDocParameterTag */: var param = tag; processJSDocParameterTag(param); commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end; break; - case 337 /* JSDocPropertyTag */: + case 342 /* JSDocPropertyTag */: var prop = tag; commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 334 /* JSDocTemplateTag */: + case 339 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; commentStart = tag.typeParameters.end; break; - case 335 /* JSDocTypedefTag */: + case 340 /* JSDocTypedefTag */: var type = tag; - commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 302 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 304 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; break; - case 328 /* JSDocCallbackTag */: + case 333 /* JSDocCallbackTag */: commentStart = tag.typeExpression.end; break; - case 333 /* JSDocTypeTag */: + case 338 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = tag.typeExpression.end; break; - case 332 /* JSDocThisTag */: - case 329 /* JSDocEnumTag */: + case 337 /* JSDocThisTag */: + case 334 /* JSDocEnumTag */: commentStart = tag.typeExpression.end; break; - case 331 /* JSDocReturnTag */: + case 336 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; - case 336 /* JSDocSeeTag */: + case 341 /* JSDocSeeTag */: commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; break; - case 318 /* JSDocAugmentsTag */: - case 319 /* JSDocImplementsTag */: + case 323 /* JSDocAugmentsTag */: + case 324 /* JSDocImplementsTag */: commentStart = tag.class.end; break; } @@ -122457,7 +125145,8 @@ var ts; } function tryClassifyTripleSlashComment(start, width) { var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; - var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + // Require a leading whitespace character (the parser already does) to prevent terrible backtracking performance + var attributeRegex = /(\s)(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; var text = sourceFile.text.substr(start, width); var match = tripleSlashXMLCommentRegEx.exec(text); if (!match) { @@ -122485,25 +125174,25 @@ var ts; if (!attrMatch) { break; } - var newAttrPos = pos + attrMatch.index; + var newAttrPos = pos + attrMatch.index + attrMatch[1].length; // whitespace if (newAttrPos > attrPos) { pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name - attrPos += attrMatch[1].length; - if (attrMatch[2].length) { - pushCommentRange(attrPos, attrMatch[2].length); // whitespace - attrPos += attrMatch[2].length; + pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[2].length; + if (attrMatch[3].length) { + pushCommentRange(attrPos, attrMatch[3].length); // whitespace + attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = - attrPos += attrMatch[3].length; - if (attrMatch[4].length) { - pushCommentRange(attrPos, attrMatch[4].length); // whitespace - attrPos += attrMatch[4].length; + pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + attrPos += attrMatch[4].length; + if (attrMatch[5].length) { + pushCommentRange(attrPos, attrMatch[5].length); // whitespace + attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value - attrPos += attrMatch[5].length; + pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[6].length; } pos += match[4].length; if (pos > attrPos) { @@ -122577,22 +125266,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 276 /* JsxOpeningElement */: + case 278 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 277 /* JsxClosingElement */: + case 279 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 275 /* JsxSelfClosingElement */: + case 277 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 281 /* JsxAttribute */: + case 283 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -122619,19 +125308,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 62 /* EqualsToken */) { + if (tokenKind === 63 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 250 /* VariableDeclaration */ || - parent.kind === 164 /* PropertyDeclaration */ || - parent.kind === 161 /* Parameter */ || - parent.kind === 281 /* JsxAttribute */) { + if (parent.kind === 252 /* VariableDeclaration */ || + parent.kind === 165 /* PropertyDeclaration */ || + parent.kind === 162 /* Parameter */ || + parent.kind === 283 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 217 /* BinaryExpression */ || - parent.kind === 215 /* PrefixUnaryExpression */ || - parent.kind === 216 /* PostfixUnaryExpression */ || - parent.kind === 218 /* ConditionalExpression */) { + if (parent.kind === 219 /* BinaryExpression */ || + parent.kind === 217 /* PrefixUnaryExpression */ || + parent.kind === 218 /* PostfixUnaryExpression */ || + parent.kind === 220 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -122644,7 +125333,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 281 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 283 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -122657,35 +125346,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 78 /* Identifier */) { + else if (tokenKind === 79 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 160 /* TypeParameter */: + case 161 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 254 /* InterfaceDeclaration */: + case 256 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 161 /* Parameter */: + case 162 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -122787,13 +125476,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 257 /* ModuleDeclaration */: - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 252 /* FunctionDeclaration */: - case 222 /* ClassExpression */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 259 /* ModuleDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 254 /* FunctionDeclaration */: + case 224 /* ClassExpression */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -122806,7 +125495,7 @@ var ts; if (ts.isJsxExpression(node)) { inJSXElement = false; } - if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node)) { + if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node) && !ts.isInfinityOrNaNString(node.escapedText)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { if (symbol.flags & 2097152 /* Alias */) { @@ -122939,25 +125628,25 @@ var ts; return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node); } var tokenFromDeclarationMapping = new ts.Map([ - [250 /* VariableDeclaration */, 7 /* variable */], - [161 /* Parameter */, 6 /* parameter */], - [164 /* PropertyDeclaration */, 9 /* property */], - [257 /* ModuleDeclaration */, 3 /* namespace */], - [256 /* EnumDeclaration */, 1 /* enum */], - [292 /* EnumMember */, 8 /* enumMember */], - [253 /* ClassDeclaration */, 0 /* class */], - [166 /* MethodDeclaration */, 11 /* member */], - [252 /* FunctionDeclaration */, 10 /* function */], - [209 /* FunctionExpression */, 10 /* function */], - [165 /* MethodSignature */, 11 /* member */], - [168 /* GetAccessor */, 9 /* property */], - [169 /* SetAccessor */, 9 /* property */], - [163 /* PropertySignature */, 9 /* property */], - [254 /* InterfaceDeclaration */, 2 /* interface */], - [255 /* TypeAliasDeclaration */, 5 /* type */], - [160 /* TypeParameter */, 4 /* typeParameter */], - [289 /* PropertyAssignment */, 9 /* property */], - [290 /* ShorthandPropertyAssignment */, 9 /* property */] + [252 /* VariableDeclaration */, 7 /* variable */], + [162 /* Parameter */, 6 /* parameter */], + [165 /* PropertyDeclaration */, 9 /* property */], + [259 /* ModuleDeclaration */, 3 /* namespace */], + [258 /* EnumDeclaration */, 1 /* enum */], + [294 /* EnumMember */, 8 /* enumMember */], + [255 /* ClassDeclaration */, 0 /* class */], + [167 /* MethodDeclaration */, 11 /* member */], + [254 /* FunctionDeclaration */, 10 /* function */], + [211 /* FunctionExpression */, 10 /* function */], + [166 /* MethodSignature */, 11 /* member */], + [170 /* GetAccessor */, 9 /* property */], + [171 /* SetAccessor */, 9 /* property */], + [164 /* PropertySignature */, 9 /* property */], + [256 /* InterfaceDeclaration */, 2 /* interface */], + [257 /* TypeAliasDeclaration */, 5 /* type */], + [161 /* TypeParameter */, 4 /* typeParameter */], + [291 /* PropertyAssignment */, 9 /* property */], + [292 /* ShorthandPropertyAssignment */, 9 /* property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -123064,10 +125753,10 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 192 /* LiteralType */: { + case 194 /* LiteralType */: { var grandParent = walkUpParentheses(parent.parent); switch (grandParent.kind) { - case 174 /* TypeReference */: { + case 176 /* TypeReference */: { var typeReference_1 = grandParent; var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); if (typeArgument) { @@ -123075,7 +125764,7 @@ var ts; } return undefined; } - case 190 /* IndexedAccessType */: + case 192 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -123087,9 +125776,9 @@ var ts; return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 196 /* ImportType */: + case 198 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; - case 183 /* UnionType */: { + case 185 /* UnionType */: { if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; } @@ -123101,7 +125790,7 @@ var ts; return undefined; } } - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -123118,7 +125807,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 203 /* ElementAccessExpression */: { + case 205 /* ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -123131,19 +125820,19 @@ var ts; } return undefined; } - case 204 /* CallExpression */: - case 205 /* NewExpression */: - if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { + case 206 /* CallExpression */: + case 207 /* NewExpression */: + if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } - // falls through (is `require("")` or `import("")`) - case 262 /* ImportDeclaration */: - case 268 /* ExportDeclaration */: - case 273 /* ExternalModuleReference */: + // falls through (is `require("")` or `require(""` or `import("")`) + case 264 /* ImportDeclaration */: + case 270 /* ExportDeclaration */: + case 275 /* ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); @@ -123162,9 +125851,9 @@ var ts; } function walkUpParentheses(node) { switch (node.kind) { - case 187 /* ParenthesizedType */: + case 189 /* ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -123241,12 +125930,13 @@ var ts; ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } - function getExtensionOptions(compilerOptions, includeExtensions) { - if (includeExtensions === void 0) { includeExtensions = false; } - return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensions: includeExtensions }; + function getExtensionOptions(compilerOptions, includeExtensionsOption) { + if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; } + return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensionsOption: includeExtensionsOption }; } function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) { - var extensionOptions = getExtensionOptions(compilerOptions, preferences.importModuleSpecifierEnding === "js"); + var includeExtensions = preferences.importModuleSpecifierEnding === "js" ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */; + var extensionOptions = getExtensionOptions(compilerOptions, includeExtensions); if (compilerOptions.rootDirs) { return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } @@ -123272,7 +125962,7 @@ var ts; return ts.containsPath(rootDirectory, scriptDirectory, basePath, ignoreCase) ? scriptDirectory.substr(rootDirectory.length) : undefined; }); // TODO: GH#18217 // Now find a path for each potential directory that is to be merged with the one containing the script - return ts.deduplicate(__spreadArray(__spreadArray([], rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })), [scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); + return ts.deduplicate(__spreadArray(__spreadArray([], rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), true), [scriptDirectory], false), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); @@ -123280,11 +125970,17 @@ var ts; var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase); return ts.flatMap(baseDirectories, function (baseDirectory) { return getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude); }); } + var IncludeExtensionsOption; + (function (IncludeExtensionsOption) { + IncludeExtensionsOption[IncludeExtensionsOption["Exclude"] = 0] = "Exclude"; + IncludeExtensionsOption[IncludeExtensionsOption["Include"] = 1] = "Include"; + IncludeExtensionsOption[IncludeExtensionsOption["ModuleSpecifierCompletion"] = 2] = "ModuleSpecifierCompletion"; + })(IncludeExtensionsOption || (IncludeExtensionsOption = {})); /** * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. */ function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) { - var extensions = _a.extensions, includeExtensions = _a.includeExtensions; + var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption; if (result === void 0) { result = []; } if (fragment === undefined) { fragment = ""; @@ -123312,7 +126008,7 @@ var ts; if (files) { /** * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg: * * both foo.ts and foo.tsx become foo */ @@ -123323,8 +126019,20 @@ var ts; if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { continue; } - var foundFileName = includeExtensions || ts.fileExtensionIs(filePath, ".json" /* Json */) ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); + var foundFileName = void 0; + var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings()); + if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIs(filePath, ".json" /* Json */)) { + foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath)); + foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); + } + else if (includeExtensionsOption === 2 /* ModuleSpecifierCompletion */ && outputExtension) { + foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension); + foundFiles.set(foundFileName, outputExtension); + } + else { + foundFileName = ts.getBaseFileName(filePath); + foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); + } } foundFiles.forEach(function (ext, foundFile) { result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); @@ -123449,8 +126157,8 @@ var ts; if (!host.readDirectory) { return undefined; } - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (!parsed) { + var parsed = ts.tryParsePattern(pattern); + if (parsed === undefined || ts.isString(parsed)) { return undefined; } // The prefix has two effective parts: the directory path and the base component after the filepath that is not a @@ -123479,7 +126187,7 @@ var ts; var name = trimPrefixAndSuffix(dir); return name === undefined ? undefined : directoryResult(name); }); - return __spreadArray(__spreadArray([], matches), directories); + return __spreadArray(__spreadArray([], matches, true), directories, true); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); @@ -123518,7 +126226,7 @@ var ts; } var prefix = match[1], kind = match[2], toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, /*includeExtensions*/ true), host, sourceFile.path) + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) : ts.Debug.fail(); return addReplacementSpans(toComplete, range.pos + prefix.length, names); @@ -123619,6 +126327,15 @@ var ts; function containsSlash(fragment) { return ts.stringContains(fragment, ts.directorySeparator); } + /** + * Matches + * require("" + * require("") + */ + function isRequireCallArgument(node) { + return ts.isCallExpression(node.parent) && ts.firstOrUndefined(node.parent.arguments) === node + && ts.isIdentifier(node.parent.expression) && node.parent.expression.escapedText === "require"; + } })(StringCompletions = Completions.StringCompletions || (Completions.StringCompletions = {})); })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); @@ -123627,17 +126344,45 @@ var ts; (function (ts) { var Completions; (function (Completions) { + // Exported only for tests + Completions.moduleSpecifierResolutionLimit = 100; + Completions.moduleSpecifierResolutionCacheAttemptLimit = 1000; + // NOTE: Make sure that each entry has the exact same number of digits + // since many implementations will sort by string contents, + // where "10" is considered less than "2". var SortText; (function (SortText) { - SortText["LocalDeclarationPriority"] = "0"; - SortText["LocationPriority"] = "1"; - SortText["OptionalMember"] = "2"; - SortText["MemberDeclaredBySpreadAssignment"] = "3"; - SortText["SuggestedClassMembers"] = "4"; - SortText["GlobalsOrKeywords"] = "5"; - SortText["AutoImportSuggestions"] = "6"; - SortText["JavascriptIdentifiers"] = "7"; + SortText["LocalDeclarationPriority"] = "10"; + SortText["LocationPriority"] = "11"; + SortText["OptionalMember"] = "12"; + SortText["MemberDeclaredBySpreadAssignment"] = "13"; + SortText["SuggestedClassMembers"] = "14"; + SortText["GlobalsOrKeywords"] = "15"; + SortText["AutoImportSuggestions"] = "16"; + SortText["JavascriptIdentifiers"] = "17"; + SortText["DeprecatedLocalDeclarationPriority"] = "18"; + SortText["DeprecatedLocationPriority"] = "19"; + SortText["DeprecatedOptionalMember"] = "20"; + SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "21"; + SortText["DeprecatedSuggestedClassMembers"] = "22"; + SortText["DeprecatedGlobalsOrKeywords"] = "23"; + SortText["DeprecatedAutoImportSuggestions"] = "24"; })(SortText = Completions.SortText || (Completions.SortText = {})); + var SortTextId; + (function (SortTextId) { + SortTextId[SortTextId["LocalDeclarationPriority"] = 10] = "LocalDeclarationPriority"; + SortTextId[SortTextId["LocationPriority"] = 11] = "LocationPriority"; + SortTextId[SortTextId["OptionalMember"] = 12] = "OptionalMember"; + SortTextId[SortTextId["MemberDeclaredBySpreadAssignment"] = 13] = "MemberDeclaredBySpreadAssignment"; + SortTextId[SortTextId["SuggestedClassMembers"] = 14] = "SuggestedClassMembers"; + SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords"; + SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions"; + // Don't use these directly. + SortTextId[SortTextId["_JavaScriptIdentifiers"] = 17] = "_JavaScriptIdentifiers"; + SortTextId[SortTextId["_DeprecatedStart"] = 18] = "_DeprecatedStart"; + SortTextId[SortTextId["_First"] = 10] = "_First"; + SortTextId[SortTextId["DeprecatedOffset"] = 8] = "DeprecatedOffset"; + })(SortTextId || (SortTextId = {})); /** * Special values for `CompletionInfo['source']` used to disambiguate * completion items with the same `name`. (Each completion item must @@ -123707,11 +126452,48 @@ var ts; GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success"; GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail"; })(GlobalsSearch || (GlobalsSearch = {})); - function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter) { - var typeChecker = program.getTypeChecker(); - var compilerOptions = program.getCompilerOptions(); - var contextToken = ts.findPrecedingToken(position, sourceFile); - if (triggerCharacter && !ts.isInString(sourceFile, position, contextToken) && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) { + function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) { + var _a, _b, _c; + var start = ts.timestamp(); + var resolutionLimitExceeded = false; + var ambientCount = 0; + var resolvedCount = 0; + var resolvedFromCacheCount = 0; + var cacheAttemptCount = 0; + var result = cb({ tryResolve: tryResolve, resolutionLimitExceeded: function () { return resolutionLimitExceeded; } }); + var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : ""; + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, logPrefix + ": resolved " + resolvedCount + " module specifiers, plus " + ambientCount + " ambient and " + resolvedFromCacheCount + " from cache" + hitRateMessage); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (resolutionLimitExceeded ? "incomplete" : "complete")); + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start)); + return result; + function tryResolve(exportInfo, isFromAmbientModule) { + if (isFromAmbientModule) { + var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences); + if (result_1) { + ambientCount++; + } + return result_1; + } + var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit; + var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit; + var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache) + ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, shouldGetModuleSpecifierFromCache) + : undefined; + if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) { + resolutionLimitExceeded = true; + } + resolvedCount += (result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0; + resolvedFromCacheCount += exportInfo.length - resolvedCount; + if (shouldGetModuleSpecifierFromCache) { + cacheAttemptCount++; + } + return result; + } + } + function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken) { + var _a; + var previousToken = getRelevantTokens(position, sourceFile).previousToken; + if (triggerCharacter && !ts.isInString(sourceFile, position, previousToken) && !isValidTrigger(sourceFile, triggerCharacter, previousToken, position)) { return undefined; } if (triggerCharacter === " ") { @@ -123721,21 +126503,39 @@ var ts; } return undefined; } - var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences); + // If the request is a continuation of an earlier `isIncomplete` response, + // we can continue it from the cached previous response. + var typeChecker = program.getTypeChecker(); + var compilerOptions = program.getCompilerOptions(); + var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined; + if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { + var incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken); + if (incompleteContinuation) { + return incompleteContinuation; + } + } + else { + incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.clear(); + } + var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken, typeChecker, compilerOptions, host, log, preferences); if (stringCompletions) { return stringCompletions; } - if (contextToken && ts.isBreakOrContinueStatement(contextToken.parent) - && (contextToken.kind === 80 /* BreakKeyword */ || contextToken.kind === 85 /* ContinueKeyword */ || contextToken.kind === 78 /* Identifier */)) { - return getLabelCompletionAtPosition(contextToken.parent); + if (previousToken && ts.isBreakOrContinueStatement(previousToken.parent) + && (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) { + return getLabelCompletionAtPosition(previousToken.parent); } - var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined, host); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined, host, cancellationToken); if (!completionData) { return undefined; } switch (completionData.kind) { case 0 /* Data */: - return completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences); + var response = completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences); + if (response === null || response === void 0 ? void 0 : response.isIncomplete) { + incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response); + } + return response; case 1 /* JsDocTagName */: // If the current position is a jsDoc tag name, only tag names should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagNameCompletions()); @@ -123751,6 +126551,48 @@ var ts; } } Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function continuePreviousIncompleteResponse(cache, file, location, program, host, preferences, cancellationToken) { + var _a; + var previousResponse = cache.get(); + if (!previousResponse) + return undefined; + var lowerCaseTokenText = location.text.toLowerCase(); + var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken); + var checker = program.getTypeChecker(); + var autoImportProvider = (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host); + var autoImportProviderChecker = autoImportProvider === null || autoImportProvider === void 0 ? void 0 : autoImportProvider.getTypeChecker(); + var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences, + /*isForImportStatementCompletion*/ false, function (context) { + var entries = ts.mapDefined(previousResponse.entries, function (entry) { + if (!entry.hasAction || !entry.source || !entry.data || entry.data.moduleSpecifier) { + // Not an auto import or already resolved; keep as is + return entry; + } + if (!charactersFuzzyMatchInString(entry.name, lowerCaseTokenText)) { + // No longer matches typed characters; filter out + return undefined; + } + var _a = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)), symbol = _a.symbol, origin = _a.origin; + var info = exportMap.get(file.path, entry.name, symbol, origin.moduleSymbol.name, origin.isFromPackageJson ? autoImportProviderChecker : checker); + var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name))); + if (!result) + return entry; + var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); + // Mutating for performance... feels sketchy but nobody else uses the cache, + // so why bother allocating a bunch of new objects? + entry.data = originToCompletionEntryData(newOrigin); + entry.source = getSourceFromOrigin(newOrigin); + entry.sourceDisplay = [ts.textPart(newOrigin.moduleSpecifier)]; + return entry; + }); + if (!context.resolutionLimitExceeded()) { + previousResponse.isIncomplete = undefined; + } + return entries; + }); + previousResponse.entries = newEntries; + return previousResponse; + } function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } @@ -123769,10 +126611,10 @@ var ts; } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 78 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences) { - var symbols = completionData.symbols, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap; + var symbols = completionData.symbols, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); @@ -123783,7 +126625,7 @@ var ts; var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217 } else { @@ -123791,7 +126633,7 @@ var ts; return undefined; } getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); } if (keywordFilters !== 0 /* None */) { var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); @@ -123808,6 +126650,7 @@ var ts; } return { isGlobalCompletion: isInSnippetScope, + isIncomplete: preferences.allowIncompleteCompletions && hasUnresolvedAutoImports ? true : undefined, isMemberCompletion: isMemberCompletionKind(completionKind), isNewIdentifierLocation: isNewIdentifierLocation, optionalReplacementSpan: getOptionalReplacementSpan(location), @@ -123831,12 +126674,12 @@ var ts; // We wanna walk up the tree till we find a JSX closing element var jsxClosingElement = ts.findAncestor(location, function (node) { switch (node.kind) { - case 277 /* JsxClosingElement */: + case 279 /* JsxClosingElement */: return true; case 43 /* SlashToken */: case 31 /* GreaterThanToken */: - case 78 /* Identifier */: - case 202 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 204 /* PropertyAccessExpression */: return false; default: return "quit"; @@ -123903,6 +126746,7 @@ var ts; var data; var isSnippet; var sourceDisplay; + var hasAction; var insertQuestionDot = origin && originIsNullableMember(origin); var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { @@ -123947,22 +126791,18 @@ var ts; replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } if (originIsResolvedExport(origin)) { - ts.Debug.assertIsDefined(importCompletionNode); - (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan); sourceDisplay = [ts.textPart(origin.moduleSpecifier)]; - isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; + if (importCompletionNode) { + (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan); + isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; + } } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } if (originIsExport(origin) || originIsResolvedExport(origin)) { - data = { - exportName: origin.exportName, - fileName: origin.fileName, - ambientModuleName: origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name), - isPackageJsonImport: origin.isFromPackageJson ? true : undefined, - moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined, - }; + data = originToCompletionEntryData(origin); + hasAction = !importCompletionNode; } // TODO(drosen): Right now we just permit *all* semantic meanings when calling // 'getSymbolKind' which is permissible given that it is backwards compatible; but @@ -123977,17 +126817,26 @@ var ts; kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol), sortText: sortText, source: getSourceFromOrigin(origin), - hasAction: origin && originIsExport(origin) || undefined, + hasAction: hasAction ? true : undefined, isRecommended: isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker) || undefined, insertText: insertText, replacementSpan: replacementSpan, sourceDisplay: sourceDisplay, isSnippet: isSnippet, isPackageJsonImport: originIsPackageJsonImport(origin) || undefined, - isImportStatementCompletion: originIsResolvedExport(origin) || undefined, + isImportStatementCompletion: !!importCompletionNode || undefined, data: data, }; } + function originToCompletionEntryData(origin) { + return { + exportName: origin.exportName, + fileName: origin.fileName, + ambientModuleName: origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name), + isPackageJsonImport: origin.isFromPackageJson ? true : undefined, + moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined, + }; + } function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences) { var sourceFile = importCompletionNode.getSourceFile(); var replacementSpan = ts.createTextSpanFromNode(importCompletionNode, sourceFile); @@ -123996,12 +126845,12 @@ var ts; origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : 0 /* Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; - var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options); + var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true); var suffix = useSemicolons ? ";" : ""; switch (importKind) { case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; - case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import * as " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import * as " + name + " from " + quotedModuleSpecifier + suffix }; case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import { " + name + tabStop + " } from " + quotedModuleSpecifier + suffix }; } } @@ -124026,7 +126875,8 @@ var ts; return CompletionSource.ThisProperty; } } - function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) { + function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) { + var _a; var start = ts.timestamp(); var variableDeclaration = getVariableDeclaration(location); var useSemicolons = ts.probablyUsesSemicolons(sourceFile); @@ -124039,11 +126889,13 @@ var ts; var symbol = symbols[i]; var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); - if (!info || uniques.get(info.name) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { + if (!info || uniques.get(info.name) || kind === 1 /* Global */ && symbolToSortTextIdMap && !shouldIncludeSymbol(symbol, symbolToSortTextIdMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; - var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences); + var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */; + var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString(); + var entry = createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences); if (!entry) { continue; } @@ -124060,7 +126912,7 @@ var ts; has: function (name) { return uniques.has(name); }, add: function (name) { return uniques.set(name, true); }, }; - function shouldIncludeSymbol(symbol, symbolToSortTextMap) { + function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) { if (!ts.isSourceFile(location)) { // export = /**/ here we want to get all meanings, so any symbol is ok if (ts.isExportAssignment(location.parent)) { @@ -124081,9 +126933,9 @@ var ts; // Auto Imports are not available for scripts so this conditional is always false if (!!sourceFile.externalModuleIndicator && !compilerOptions.allowUmdGlobalAccess - && symbolToSortTextMap[ts.getSymbolId(symbol)] === SortText.GlobalsOrKeywords - && (symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === SortText.AutoImportSuggestions - || symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === SortText.LocationPriority)) { + && symbolToSortTextIdMap[ts.getSymbolId(symbol)] === 15 /* GlobalsOrKeywords */ + && (symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 16 /* AutoImportSuggestions */ + || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) { return false; } // Continue with origin symbol @@ -124199,7 +127051,7 @@ var ts; } case "symbol": { var symbol = symbolCompletion.symbol, location = symbolCompletion.location, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken; - var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, typeChecker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, entryId.data), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, entryId.data), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -124228,16 +127080,22 @@ var ts; return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source, sourceDisplay: source }; } Completions.createCompletionDetails = createCompletionDetails; - function getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) { + function getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) { if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) { - return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] }; + var _a = getRelevantTokens(position, sourceFile), contextToken = _a.contextToken, previousToken_1 = _a.previousToken; + if (previousToken_1 && getImportCompletionNode(contextToken || previousToken_1)) { + // Import statement completion: 'import c|' + return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] }; + } } - if (!origin || !originIsExport(origin)) { + if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) { return { codeActions: undefined, sourceDisplay: undefined }; } + var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); var moduleSymbol = origin.moduleSymbol; var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; + var _b = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _b.moduleSpecifier, codeAction = _b.codeAction; + ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier); return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host, preferences) { @@ -124275,25 +127133,25 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: switch (parent.kind) { - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 281 /* JsxAttribute */: + case 283 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: return checker.getContextualType(parent); - case 81 /* CaseKeyword */: + case 82 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 274 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 276 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? @@ -124313,9 +127171,9 @@ var ts; } function isModuleSymbol(symbol) { var _a; - return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 298 /* SourceFile */; })); + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 300 /* SourceFile */; })); } - function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host, cancellationToken) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 @@ -124364,11 +127222,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 304 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 337 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 342 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -124386,18 +127244,12 @@ var ts; } } start = ts.timestamp(); - var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined); // TODO: GH#18217 - log("getCompletionData: Get previous token 1: " + (ts.timestamp() - start)); // The decision to provide completion depends on the contextToken, which is determined through the previousToken. // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file - var contextToken = previousToken; - // 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.isMemberName(contextToken) || ts.isKeyword(contextToken.kind))) { - var start_1 = ts.timestamp(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 - log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_1)); - } + var tokens = getRelevantTokens(position, sourceFile); + var previousToken = tokens.previousToken; + var contextToken = tokens.contextToken; + log("getCompletionData: Get previous token: " + (ts.timestamp() - start)); // Find the node where completion is requested on. // Also determine whether we are trying to complete with members of that node // or attributes of a JSX tag. @@ -124413,8 +127265,8 @@ var ts; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { var importCompletionCandidate = getImportCompletionNode(contextToken); - if (importCompletionCandidate === 153 /* FromKeyword */) { - return { kind: 4 /* Keywords */, keywords: [153 /* FromKeyword */] }; + if (importCompletionCandidate === 154 /* FromKeyword */) { + return { kind: 4 /* Keywords */, keywords: [154 /* FromKeyword */] }; } // Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier` // added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature @@ -124433,29 +127285,35 @@ var ts; isRightOfDot = contextToken.kind === 24 /* DotToken */; isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; - if ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && - node.end === contextToken.pos && - node.getChildCount(sourceFile) && - ts.last(node.getChildren(sourceFile)).kind !== 21 /* CloseParenToken */) { + var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert); + if (ts.nodeIsMissing(leftmostAccessExpression) || + ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && + node.end === contextToken.pos && + node.getChildCount(sourceFile) && + ts.last(node.getChildren(sourceFile)).kind !== 21 /* CloseParenToken */)) { // This is likely dot from incorrectly parsed expression and user is starting to write spread // eg: Math.min(./**/) // const x = function (./**/) {} + // ({./**/}) return undefined; } break; - case 158 /* QualifiedName */: + case 159 /* QualifiedName */: node = parent.left; break; - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: node = parent.name; break; - case 196 /* ImportType */: - case 227 /* MetaProperty */: + case 198 /* ImportType */: node = parent; break; + case 229 /* MetaProperty */: + node = parent.getFirstToken(sourceFile); + ts.Debug.assert(node.kind === 100 /* ImportKeyword */ || node.kind === 103 /* NewKeyword */); + break; default: // There is nothing that precedes the dot, so this likely just a stray character // or leading into a '...' token. Just bail out instead. @@ -124466,7 +127324,7 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 202 /* PropertyAccessExpression */) { + if (parent && parent.kind === 204 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -124474,45 +127332,46 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 274 /* JsxElement */ || currentToken.parent.kind === 276 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 276 /* JsxElement */ || currentToken.parent.kind === 278 /* JsxOpeningElement */) { location = currentToken; } break; case 43 /* SlashToken */: - if (currentToken.parent.kind === 275 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 277 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 277 /* JsxClosingElement */: + case 279 /* JsxClosingElement */: if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 275 /* JsxSelfClosingElement */: - case 274 /* JsxElement */: - case 276 /* JsxOpeningElement */: + case 277 /* JsxSelfClosingElement */: + case 276 /* JsxElement */: + case 278 /* JsxOpeningElement */: isJsxIdentifierExpected = true; if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 284 /* JsxExpression */: + case 286 /* JsxExpression */: + case 285 /* JsxSpreadAttribute */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 281 /* JsxAttribute */: + case 283 /* JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -124520,16 +127379,16 @@ var ts; break; } switch (previousToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: isJsxInitializer = true; break; - case 78 /* Identifier */: + case 79 /* Identifier */: isJsxIdentifierExpected = true; // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 62 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -124541,13 +127400,14 @@ var ts; var completionKind = 5 /* None */; var isNewIdentifierLocation = false; var isNonContextualObjectLiteral = false; + var hasUnresolvedAutoImports = false; var keywordFilters = 0 /* None */; // This also gets mutated in nested-functions after the return var symbols = []; var symbolToOriginInfoMap = []; - var symbolToSortTextMap = []; + var symbolToSortTextIdMap = []; var seenPropertySymbols = new ts.Map(); - var isTypeOnly = isTypeOnlyCompletion(); + var isTypeOnlyLocation = isTypeOnlyCompletion(); var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); }); @@ -124555,10 +127415,9 @@ var ts; getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { - var tagSymbols = typeChecker.getJsxIntrinsicTagNamesAt(location); - ts.Debug.assertEachIsDefined(tagSymbols, "getJsxIntrinsicTagNames() should all be defined"); + symbols = typeChecker.getJsxIntrinsicTagNamesAt(location); + ts.Debug.assertEachIsDefined(symbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); - symbols = tagSymbols.concat(symbols); completionKind = 1 /* Global */; keywordFilters = 0 /* None */; } @@ -124598,18 +127457,19 @@ var ts; previousToken: previousToken, isJsxInitializer: isJsxInitializer, insideJsDocTagTypeExpression: insideJsDocTagTypeExpression, - symbolToSortTextMap: symbolToSortTextMap, - isTypeOnlyLocation: isTypeOnly, + symbolToSortTextIdMap: symbolToSortTextIdMap, + isTypeOnlyLocation: isTypeOnlyLocation, isJsxIdentifierExpected: isJsxIdentifierExpected, importCompletionNode: importCompletionNode, + hasUnresolvedAutoImports: hasUnresolvedAutoImports, }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 330 /* JSDocParameterTag */: - case 337 /* JSDocPropertyTag */: - case 331 /* JSDocReturnTag */: - case 333 /* JSDocTypeTag */: - case 335 /* JSDocTypedefTag */: + case 335 /* JSDocParameterTag */: + case 342 /* JSDocPropertyTag */: + case 336 /* JSDocReturnTag */: + case 338 /* JSDocTypeTag */: + case 340 /* JSDocTypedefTag */: return true; default: return false; @@ -124636,7 +127496,7 @@ var ts; // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); - var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : (node.parent), symbol.name); }; + var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : node.parent, symbol.name); }; var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); }; var isValidAccess = isNamespaceName // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. @@ -124654,7 +127514,7 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 298 /* SourceFile */ && d.kind !== 257 /* ModuleDeclaration */ && d.kind !== 256 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 300 /* SourceFile */ && d.kind !== 259 /* ModuleDeclaration */ && d.kind !== 258 /* EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -124674,12 +127534,13 @@ var ts; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 102 /* NewKeyword */ || node.keywordToken === 99 /* ImportKeyword */) && contextToken === node.getChildAt(1)) { - var completion = (node.keywordToken === 102 /* NewKeyword */) ? "target" : "meta"; - symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); - return; - } if (!isTypeLocation) { + // GH#39946. Pulling on the type of a node inside of a function with a contextual `this` parameter can result in a circularity + // if the `node` is part of the exprssion of a `yield` or `return`. This circularity doesn't exist at compile time because + // we will check (and cache) the type of `this` *before* checking the type of the node. + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (!ts.isSourceFile(container) && container.parent) + typeChecker.getTypeAtLocation(container); var type = typeChecker.getTypeAtLocation(node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -124701,7 +127562,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 196 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 198 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -124772,7 +127633,7 @@ var ts; } function addSymbolSortInfo(symbol) { if (isStaticProperty(symbol)) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.LocalDeclarationPriority; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 10 /* LocalDeclarationPriority */; } } function addSymbolOriginInfo(symbol) { @@ -124823,7 +127684,7 @@ var ts; if (!attrsType) return 0 /* Continue */; var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* Completions */); - symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + symbols = ts.concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties)); setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; @@ -124832,7 +127693,8 @@ var ts; function tryGetImportCompletionSymbols() { if (!importCompletionNode) return 0 /* Continue */; - collectAutoImports(/*resolveModuleSpecifiers*/ true); + isNewIdentifierLocation = true; + collectAutoImports(); return 1 /* Success */; } function getGlobalCompletions() { @@ -124873,30 +127735,30 @@ var ts; position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); - var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings)); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; if (!typeChecker.isArgumentsSymbol(symbol) && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.GlobalsOrKeywords; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 298 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 300 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */; } } } - collectAutoImports(/*resolveModuleSpecifier*/ false); - if (isTypeOnly) { + collectAutoImports(); + if (isTypeOnlyLocation) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) ? 6 /* TypeAssertionKeywords */ : 7 /* TypeKeywords */; @@ -124923,10 +127785,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 298 /* SourceFile */: - case 219 /* TemplateExpression */: - case 284 /* JsxExpression */: - case 231 /* Block */: + case 300 /* SourceFile */: + case 221 /* TemplateExpression */: + case 286 /* JsxExpression */: + case 233 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -124941,128 +127803,108 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - ((contextToken.kind === 111 /* TypeOfKeyword */ && - (contextToken.parent.kind === 177 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || - (contextToken.kind === 127 /* AssertsKeyword */ && contextToken.parent.kind === 173 /* TypePredicate */)); + ((contextToken.kind === 112 /* TypeOfKeyword */ && + (contextToken.parent.kind === 179 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 175 /* TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 58 /* ColonToken */: - return parentKind === 164 /* PropertyDeclaration */ || - parentKind === 163 /* PropertySignature */ || - parentKind === 161 /* Parameter */ || - parentKind === 250 /* VariableDeclaration */ || + return parentKind === 165 /* PropertyDeclaration */ || + parentKind === 164 /* PropertySignature */ || + parentKind === 162 /* Parameter */ || + parentKind === 252 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 62 /* EqualsToken */: - return parentKind === 255 /* TypeAliasDeclaration */; - case 126 /* AsKeyword */: - return parentKind === 225 /* AsExpression */; + case 63 /* EqualsToken */: + return parentKind === 257 /* TypeAliasDeclaration */; + case 127 /* AsKeyword */: + return parentKind === 227 /* AsExpression */; case 29 /* LessThanToken */: - return parentKind === 174 /* TypeReference */ || - parentKind === 207 /* TypeAssertionExpression */; - case 93 /* ExtendsKeyword */: - return parentKind === 160 /* TypeParameter */; + return parentKind === 176 /* TypeReference */ || + parentKind === 209 /* TypeAssertionExpression */; + case 94 /* ExtendsKeyword */: + return parentKind === 161 /* TypeParameter */; } } return false; } - /** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextMap` */ - function collectAutoImports(resolveModuleSpecifiers) { - var _a, _b, _c, _d, _e; + /** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextIdMap` */ + function collectAutoImports() { + var _a, _b; if (!shouldOfferImportCompletions()) return; - ts.Debug.assert(!(detailsEntryId === null || detailsEntryId === void 0 ? void 0 : detailsEntryId.data)); - var start = ts.timestamp(); - var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "collectAutoImports: starting, " + (resolveModuleSpecifiers ? "" : "not ") + "resolving module specifiers"); - if (moduleSpecifierCache) { - (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "collectAutoImports: module specifier cache size: " + moduleSpecifierCache.count()); + ts.Debug.assert(!(detailsEntryId === null || detailsEntryId === void 0 ? void 0 : detailsEntryId.data), "Should not run 'collectAutoImports' when faster path is available via `data`"); + if (detailsEntryId && !detailsEntryId.source) { + // Asking for completion details for an item that is not an auto-import + return; } + var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); var lowerCaseTokenText = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; - var exportInfo = ts.codefix.getSymbolToExportInfoMap(sourceFile, host, program); - var packageJsonAutoImportProvider = (_d = host.getPackageJsonAutoImportProvider) === null || _d === void 0 ? void 0 : _d.call(host); - var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, host); - exportInfo.forEach(function (info, key) { - var symbolName = key.substring(0, key.indexOf("|")); - if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) - return; - var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); }); - if (isCompletionDetailsMatch || isNameMatch(symbolName)) { - // If we don't need to resolve module specifiers, we can use any re-export that is importable at all - // (We need to ensure that at least one is importable to show a completion.) - var _a = resolveModuleSpecifiers - ? ts.codefix.getModuleSpecifierForBestExportInfo(info, sourceFile, program, host, preferences) - : { moduleSpecifier: undefined, exportInfo: ts.find(info, isImportableExportInfo) }, moduleSpecifier = _a.moduleSpecifier, exportInfo_1 = _a.exportInfo; - if (!exportInfo_1) + var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken); + var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host); + var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host); + resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) { + exportInfo.forEach(sourceFile.path, function (info, symbolName, isFromAmbientModule) { + if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings()))) return; - var moduleFile = ts.tryCast(exportInfo_1.moduleSymbol.valueDeclaration, ts.isSourceFile); - var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */; - var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol; - pushAutoImportSymbol(symbol, { - kind: resolveModuleSpecifiers ? 32 /* ResolvedExport */ : 4 /* Export */, - moduleSpecifier: moduleSpecifier, - symbolName: symbolName, - exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name, - fileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, - isDefaultExport: isDefaultExport, - moduleSymbol: exportInfo_1.moduleSymbol, - isFromPackageJson: exportInfo_1.isFromPackageJson, - }); - } + if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) + return; + // `targetFlags` should be the same for each `info` + if (!isTypeOnlyLocation && !importCompletionNode && !(info[0].targetFlags & 111551 /* Value */)) + return; + if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */))) + return; + var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); }); + if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) { + var defaultExportInfo = ts.find(info, isImportableExportInfo); + if (!defaultExportInfo) { + return; + } + // If we don't need to resolve module specifiers, we can use any re-export that is importable at all + // (We need to ensure that at least one is importable to show a completion.) + var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo_1 = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier; + var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */; + var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol; + pushAutoImportSymbol(symbol, { + kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + moduleSpecifier: moduleSpecifier, + symbolName: symbolName, + exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name, + fileName: exportInfo_1.moduleFileName, + isDefaultExport: isDefaultExport, + moduleSymbol: exportInfo_1.moduleSymbol, + isFromPackageJson: exportInfo_1.isFromPackageJson, + }); + } + }); + hasUnresolvedAutoImports = context.resolutionLimitExceeded(); }); - (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "collectAutoImports: done in " + (ts.timestamp() - start) + " ms"); - function isNameMatch(symbolName) { - var lowerCaseSymbolName = symbolName.toLowerCase(); - if (resolveModuleSpecifiers && lowerCaseTokenText) { - // Use a more restrictive filter if resolving module specifiers since resolving module specifiers is expensive. - return lowerCaseTokenText[0] === lowerCaseSymbolName[0] && stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); - } - return stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); - } function isImportableExportInfo(info) { var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); if (!moduleFile) { + var moduleName = ts.stripQuotes(info.moduleSymbol.name); + if (ts.JsTyping.nodeCoreModules.has(moduleName) && ts.startsWith(moduleName, "node:") !== ts.shouldUseUriStyleNodeCoreModules(sourceFile, program)) { + return false; + } return packageJsonFilter ? packageJsonFilter.allowsImportingAmbientModule(info.moduleSymbol, getModuleSpecifierResolutionHost(info.isFromPackageJson)) : true; } - return ts.isImportableFile(info.isFromPackageJson ? packageJsonAutoImportProvider : program, sourceFile, moduleFile, packageJsonFilter, getModuleSpecifierResolutionHost(info.isFromPackageJson), moduleSpecifierCache); + return ts.isImportableFile(info.isFromPackageJson ? packageJsonAutoImportProvider : program, sourceFile, moduleFile, preferences, packageJsonFilter, getModuleSpecifierResolutionHost(info.isFromPackageJson), moduleSpecifierCache); } } function pushAutoImportSymbol(symbol, origin) { var symbolId = ts.getSymbolId(symbol); - if (symbolToSortTextMap[symbolId] === SortText.GlobalsOrKeywords) { + if (symbolToSortTextIdMap[symbolId] === 15 /* GlobalsOrKeywords */) { // If an auto-importable symbol is available as a global, don't add the auto import return; } symbolToOriginInfoMap[symbols.length] = origin; - symbolToSortTextMap[symbolId] = importCompletionNode ? SortText.LocationPriority : SortText.AutoImportSuggestions; + symbolToSortTextIdMap[symbolId] = importCompletionNode ? 11 /* LocationPriority */ : 16 /* AutoImportSuggestions */; symbols.push(symbol); } - /** - * True if you could remove some characters in `a` to get `b`. - * E.g., true for "abcdef" and "bdf". - * But not true for "abcdef" and "dbf". - */ - function stringContainsCharactersInOrder(str, characters) { - if (characters.length === 0) { - return true; - } - var characterIndex = 0; - var len = str.length; - for (var strIndex = 0; strIndex < len; strIndex++) { - if (str.charCodeAt(strIndex) === characters.charCodeAt(characterIndex)) { - characterIndex++; - if (characterIndex === characters.length) { - return true; - } - } - } - // Did not find all characters - return false; - } /** * Finds the first node that "embraces" the position, so that one may * accurately aggregate locals from the closest containing scope. @@ -125079,7 +127921,8 @@ var ts; var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || isSolelyIdentifierDefinitionLocation(contextToken) || isDotOfNumericLiteral(contextToken) || - isInJsxText(contextToken); + isInJsxText(contextToken) || + ts.isBigIntLiteral(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (ts.timestamp() - start)); return result; } @@ -125088,7 +127931,7 @@ var ts; return true; } if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 276 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 278 /* JsxOpeningElement */) { // Two possibilities: // 1.
/**/ // - contextToken: GreaterThanToken (before cursor) @@ -125098,10 +127941,10 @@ var ts; // - contextToken: GreaterThanToken (before cursor) // - location: GreaterThanToken (after cursor) // - same parent (JSXOpeningElement) - return location.parent.kind !== 276 /* JsxOpeningElement */; + return location.parent.kind !== 278 /* JsxOpeningElement */; } - if (contextToken.parent.kind === 277 /* JsxClosingElement */ || contextToken.parent.kind === 275 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 274 /* JsxElement */; + if (contextToken.parent.kind === 279 /* JsxClosingElement */ || contextToken.parent.kind === 277 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 276 /* JsxElement */; } } return false; @@ -125112,42 +127955,42 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { case 27 /* CommaToken */: - return containingNodeKind === 204 /* CallExpression */ // func( a, | - || containingNodeKind === 167 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 205 /* NewExpression */ // new C(a, | - || containingNodeKind === 200 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 217 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 175 /* FunctionType */ // var x: (s: string, list| - || containingNodeKind === 201 /* ObjectLiteralExpression */; // const obj = { x, | + return containingNodeKind === 206 /* CallExpression */ // func( a, | + || containingNodeKind === 169 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 207 /* NewExpression */ // new C(a, | + || containingNodeKind === 202 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 219 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 177 /* FunctionType */ // var x: (s: string, list| + || containingNodeKind === 203 /* ObjectLiteralExpression */; // const obj = { x, | case 20 /* OpenParenToken */: - return containingNodeKind === 204 /* CallExpression */ // func( | - || containingNodeKind === 167 /* Constructor */ // constructor( | - || containingNodeKind === 205 /* NewExpression */ // new C(a| - || containingNodeKind === 208 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 187 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 206 /* CallExpression */ // func( | + || containingNodeKind === 169 /* Constructor */ // constructor( | + || containingNodeKind === 207 /* NewExpression */ // new C(a| + || containingNodeKind === 210 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 189 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 200 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 172 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 159 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 139 /* ModuleKeyword */: // module | - case 140 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 202 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 174 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 160 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 140 /* ModuleKeyword */: // module | + case 141 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 257 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 259 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 253 /* ClassDeclaration */ // class A { | - || containingNodeKind === 201 /* ObjectLiteralExpression */; // const obj = { | - case 62 /* EqualsToken */: - return containingNodeKind === 250 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 217 /* BinaryExpression */; // x = a| + return containingNodeKind === 255 /* ClassDeclaration */ // class A { | + || containingNodeKind === 203 /* ObjectLiteralExpression */; // const obj = { | + case 63 /* EqualsToken */: + return containingNodeKind === 252 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 219 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 219 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 221 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 229 /* TemplateSpan */; // `aa ${10} dd ${| - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - return containingNodeKind === 164 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 231 /* TemplateSpan */; // `aa ${10} dd ${| + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + return containingNodeKind === 165 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -125174,7 +128017,7 @@ var ts; var existingMembers = getPropertiesForCompletion(containerActualType, typeChecker); var existingMemberEscapedNames = new ts.Set(); existingMembers.forEach(function (s) { return existingMemberEscapedNames.add(s.escapedName); }); - symbols = ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); }); + symbols = ts.concatenate(symbols, ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); })); completionKind = 0 /* ObjectPropertyDeclaration */; isNewIdentifierLocation = true; return 1 /* Success */; @@ -125193,7 +128036,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 201 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 203 /* ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { @@ -125218,7 +128061,7 @@ var ts; } } else { - ts.Debug.assert(objectLikeContainer.kind === 197 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 199 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -125229,12 +128072,12 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 240 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 161 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 242 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 162 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 166 /* MethodDeclaration */ || rootDeclaration.parent.kind === 169 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 167 /* MethodDeclaration */ || rootDeclaration.parent.kind === 171 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -125256,7 +128099,7 @@ var ts; } if (typeMembers && typeMembers.length > 0) { // Add filtered items to the completion list - symbols = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)); + symbols = ts.concatenate(symbols, filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers))); } setSortTextToOptionalMember(); return 1 /* Success */; @@ -125281,9 +128124,9 @@ var ts; if (!namedImportsOrExports) return 0 /* Continue */; // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 265 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 267 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) - return namedImportsOrExports.kind === 265 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 267 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -125291,7 +128134,7 @@ var ts; isNewIdentifierLocation = false; var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); var existing = new ts.Set(namedImportsOrExports.elements.filter(function (n) { return !isCurrentlyEditingNode(n); }).map(function (n) { return (n.propertyName || n.name).escapedText; })); - symbols = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); }); + symbols = ts.concatenate(symbols, exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); })); return 1 /* Success */; } /** @@ -125318,7 +128161,7 @@ var ts; var _a, _b; symbols.push(symbol); if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.OptionalMember; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 12 /* OptionalMember */; } }); return 1 /* Success */; @@ -125343,7 +128186,7 @@ var ts; var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 78 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -125356,6 +128199,9 @@ var ts; break; } } + if (ts.isClassStaticBlockDeclaration(classElement)) { + classElementModifierFlags |= 32 /* Static */; + } // No member list for private methods if (!(classElementModifierFlags & 8 /* Private */)) { // List of property symbols of base type that are not private and already implemented @@ -125366,7 +128212,7 @@ var ts; (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); }); - symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags); + symbols = ts.concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags)); } return 1 /* Success */; } @@ -125386,7 +128232,7 @@ var ts; break; case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 78 /* Identifier */: + case 79 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -125439,12 +128285,12 @@ var ts; case 31 /* GreaterThanToken */: // End of a type argument list case 30 /* LessThanSlashToken */: case 43 /* SlashToken */: - case 78 /* Identifier */: - case 202 /* PropertyAccessExpression */: - case 282 /* JsxAttributes */: - case 281 /* JsxAttribute */: - case 283 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 275 /* JsxSelfClosingElement */ || parent.kind === 276 /* JsxOpeningElement */)) { + case 79 /* Identifier */: + case 204 /* PropertyAccessExpression */: + case 284 /* JsxAttributes */: + case 283 /* JsxAttribute */: + case 285 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 277 /* JsxSelfClosingElement */ || parent.kind === 278 /* JsxOpeningElement */)) { if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) @@ -125452,7 +128298,7 @@ var ts; } return parent; } - else if (parent.kind === 281 /* JsxAttribute */) { + else if (parent.kind === 283 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -125464,7 +128310,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 281 /* JsxAttribute */) || (parent.kind === 283 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 283 /* JsxAttribute */) || (parent.kind === 285 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -125474,8 +128320,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 284 /* JsxExpression */ && - parent.parent && parent.parent.kind === 281 /* JsxAttribute */) { + parent.kind === 286 /* JsxExpression */ && + parent.parent && parent.parent.kind === 283 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -125483,7 +128329,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 283 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 285 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -125503,62 +128349,62 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 250 /* VariableDeclaration */ || + return containingNodeKind === 252 /* VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 233 /* VariableStatement */ || - containingNodeKind === 256 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 235 /* VariableStatement */ || + containingNodeKind === 258 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 254 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 198 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 200 /* ArrayBindingPattern */; // var [.| case 58 /* ColonToken */: - return containingNodeKind === 199 /* BindingElement */; // var {x :html| + return containingNodeKind === 201 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 198 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 200 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 288 /* CatchClause */ || + return containingNodeKind === 290 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 256 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 258 /* EnumDeclaration */; // enum a { | case 29 /* LessThanToken */: - return containingNodeKind === 253 /* ClassDeclaration */ || // class A< | - containingNodeKind === 222 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 254 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 255 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 255 /* ClassDeclaration */ || // class A< | + containingNodeKind === 224 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 256 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 257 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 123 /* StaticKeyword */: - return containingNodeKind === 164 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 124 /* StaticKeyword */: + return containingNodeKind === 165 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 161 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 198 /* ArrayBindingPattern */); // var [...z| - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - return containingNodeKind === 161 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 126 /* AsKeyword */: - return containingNodeKind === 266 /* ImportSpecifier */ || - containingNodeKind === 271 /* ExportSpecifier */ || - containingNodeKind === 264 /* NamespaceImport */; - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: + return containingNodeKind === 162 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 200 /* ArrayBindingPattern */); // var [...z| + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + return containingNodeKind === 162 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* AsKeyword */: + return containingNodeKind === 268 /* ImportSpecifier */ || + containingNodeKind === 273 /* ExportSpecifier */ || + containingNodeKind === 266 /* NamespaceImport */; + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: - case 117 /* InterfaceKeyword */: - case 97 /* FunctionKeyword */: - case 112 /* VarKeyword */: - case 99 /* ImportKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: - case 135 /* InferKeyword */: - case 149 /* TypeKeyword */: // type htm| + case 84 /* ClassKeyword */: + case 92 /* EnumKeyword */: + case 118 /* InterfaceKeyword */: + case 98 /* FunctionKeyword */: + case 113 /* VarKeyword */: + case 100 /* ImportKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: + case 136 /* InferKeyword */: + case 150 /* TypeKeyword */: // type htm| return true; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); @@ -125581,21 +128427,21 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 125 /* AbstractKeyword */: - case 83 /* ClassKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 91 /* EnumKeyword */: - case 97 /* FunctionKeyword */: - case 117 /* InterfaceKeyword */: - case 118 /* LetKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 123 /* StaticKeyword */: - case 112 /* VarKeyword */: + case 126 /* AbstractKeyword */: + case 84 /* ClassKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 92 /* EnumKeyword */: + case 98 /* FunctionKeyword */: + case 118 /* InterfaceKeyword */: + case 119 /* LetKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 124 /* StaticKeyword */: + case 113 /* VarKeyword */: return true; - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } // If we are inside a class declaration, and `constructor` is totally not present, @@ -125604,7 +128450,7 @@ var ts; if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { return false; // Don't block completions. } - var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 164 /* PropertyDeclaration */); + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 165 /* PropertyDeclaration */); // If we are inside a class declaration and typing `constructor` after property declaration... if (ancestorPropertyDeclaraion && contextToken !== previousToken @@ -125615,7 +128461,7 @@ var ts; if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { return false; // Don't block completions. } - else if (contextToken.kind !== 62 /* EqualsToken */ + else if (contextToken.kind !== 63 /* EqualsToken */ // Should not block: `class C { blah = c/**/ }` // But should block: `class C { blah = somewhat c/**/ }` and `class C { blah: SomeType c/**/ }` && (ts.isInitializedProperty(ancestorPropertyDeclaraion) @@ -125631,12 +128477,12 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isPreviousPropertyDeclarationTerminated(contextToken, position) { - return contextToken.kind !== 62 /* EqualsToken */ && + return contextToken.kind !== 63 /* EqualsToken */ && (contextToken.kind === 26 /* SemicolonToken */ || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 167 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 169 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -125646,7 +128492,7 @@ var ts; return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 251 /* VariableDeclarationList */ + return node.parent.kind === 253 /* VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -125664,13 +128510,13 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 289 /* PropertyAssignment */ && - m.kind !== 290 /* ShorthandPropertyAssignment */ && - m.kind !== 199 /* BindingElement */ && - m.kind !== 166 /* MethodDeclaration */ && - m.kind !== 168 /* GetAccessor */ && - m.kind !== 169 /* SetAccessor */ && - m.kind !== 291 /* SpreadAssignment */) { + if (m.kind !== 291 /* PropertyAssignment */ && + m.kind !== 292 /* ShorthandPropertyAssignment */ && + m.kind !== 201 /* BindingElement */ && + m.kind !== 167 /* MethodDeclaration */ && + m.kind !== 170 /* GetAccessor */ && + m.kind !== 171 /* SetAccessor */ && + m.kind !== 293 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -125683,7 +128529,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 78 /* Identifier */) { + if (m.propertyName.kind === 79 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -125716,8 +128562,10 @@ var ts; // Set SortText to OptionalMember if it is an optional member function setSortTextToOptionalMember() { symbols.forEach(function (m) { + var _a; if (m.flags & 16777216 /* Optional */) { - symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + var symbolId = ts.getSymbolId(m); + symbolToSortTextIdMap[symbolId] = (_a = symbolToSortTextIdMap[symbolId]) !== null && _a !== void 0 ? _a : 12 /* OptionalMember */; } }); } @@ -125729,7 +128577,7 @@ var ts; for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { var contextualMemberSymbol = contextualMemberSymbols_1[_i]; if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { - symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + symbolToSortTextIdMap[ts.getSymbolId(contextualMemberSymbol)] = 13 /* MemberDeclaredBySpreadAssignment */; } } } @@ -125743,10 +128591,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 164 /* PropertyDeclaration */ && - m.kind !== 166 /* MethodDeclaration */ && - m.kind !== 168 /* GetAccessor */ && - m.kind !== 169 /* SetAccessor */) { + if (m.kind !== 165 /* PropertyDeclaration */ && + m.kind !== 167 /* MethodDeclaration */ && + m.kind !== 170 /* GetAccessor */ && + m.kind !== 171 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -125758,7 +128606,7 @@ var ts; continue; } // do not filter it out if the static presence doesnt match - if (ts.hasEffectiveModifier(m, 32 /* Static */) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { + if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { continue; } var existingName = ts.getPropertyNameForPropertyNameNode(m.name); @@ -125788,7 +128636,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 281 /* JsxAttribute */) { + if (attr.kind === 283 /* JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -125803,6 +128651,14 @@ var ts; return node.getStart(sourceFile) <= position && position <= node.getEnd(); } } + function getRelevantTokens(position, sourceFile) { + var previousToken = ts.findPrecedingToken(position, sourceFile); + if (previousToken && position <= previousToken.end && (ts.isMemberName(previousToken) || ts.isKeyword(previousToken.kind))) { + var contextToken = ts.findPrecedingToken(previousToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 + return { contextToken: contextToken, previousToken: previousToken }; + } + return { contextToken: previousToken, previousToken: previousToken }; + } function getAutoImportSymbolFromCompletionEntryData(name, data, program, host) { var containingProgram = data.isPackageJsonImport ? host.getPackageJsonAutoImportProvider() : program; var checker = containingProgram.getTypeChecker(); @@ -125827,6 +128683,7 @@ var ts; isDefaultExport: isDefaultExport, exportName: data.exportName, fileName: data.fileName, + isFromPackageJson: !!data.isPackageJsonImport, } }; } @@ -125865,7 +128722,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 80 /* FirstKeyword */; i <= 157 /* LastKeyword */; i++) { + for (var i = 81 /* FirstKeyword */; i <= 158 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -125891,11 +128748,11 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 133 /* DeclareKeyword */ - || kind === 139 /* ModuleKeyword */ - || kind === 149 /* TypeKeyword */ - || kind === 140 /* NamespaceKeyword */ - || ts.isTypeKeyword(kind) && kind !== 150 /* UndefinedKeyword */; + || kind === 134 /* DeclareKeyword */ + || kind === 140 /* ModuleKeyword */ + || kind === 150 /* TypeKeyword */ + || kind === 141 /* NamespaceKeyword */ + || ts.isTypeKeyword(kind) && kind !== 151 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -125905,7 +128762,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 84 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -125915,59 +128772,59 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 125 /* AbstractKeyword */: - case 128 /* AnyKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 133 /* DeclareKeyword */: - case 91 /* EnumKeyword */: - case 154 /* GlobalKeyword */: - case 116 /* ImplementsKeyword */: - case 135 /* InferKeyword */: - case 117 /* InterfaceKeyword */: - case 137 /* IsKeyword */: - case 138 /* KeyOfKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 141 /* NeverKeyword */: - case 144 /* NumberKeyword */: - case 145 /* ObjectKeyword */: - case 156 /* OverrideKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 142 /* ReadonlyKeyword */: - case 147 /* StringKeyword */: - case 148 /* SymbolKeyword */: - case 149 /* TypeKeyword */: - case 151 /* UniqueKeyword */: - case 152 /* UnknownKeyword */: + case 126 /* AbstractKeyword */: + case 129 /* AnyKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 134 /* DeclareKeyword */: + case 92 /* EnumKeyword */: + case 155 /* GlobalKeyword */: + case 117 /* ImplementsKeyword */: + case 136 /* InferKeyword */: + case 118 /* InterfaceKeyword */: + case 138 /* IsKeyword */: + case 139 /* KeyOfKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 142 /* NeverKeyword */: + case 145 /* NumberKeyword */: + case 146 /* ObjectKeyword */: + case 157 /* OverrideKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 143 /* ReadonlyKeyword */: + case 148 /* StringKeyword */: + case 149 /* SymbolKeyword */: + case 150 /* TypeKeyword */: + case 152 /* UniqueKeyword */: + case 153 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 142 /* ReadonlyKeyword */; + return kind === 143 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 125 /* AbstractKeyword */: - case 132 /* ConstructorKeyword */: - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 156 /* OverrideKeyword */: + case 126 /* AbstractKeyword */: + case 133 /* ConstructorKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 157 /* OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 129 /* AsyncKeyword */ - || kind === 130 /* AwaitKeyword */ - || kind === 126 /* AsKeyword */ + return kind === 130 /* AsyncKeyword */ + || kind === 131 /* AwaitKeyword */ + || kind === 127 /* AsKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -126019,7 +128876,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 338 /* SyntaxList */: + case 343 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -126027,7 +128884,7 @@ var ts; return cls; } break; - case 78 /* Identifier */: { + case 79 /* Identifier */: { // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -126041,13 +128898,13 @@ var ts; if (!contextToken) return undefined; // class C { blah; constructor/**/ } and so on - if (location.kind === 132 /* ConstructorKeyword */ + if (location.kind === 133 /* ConstructorKeyword */ // class C { blah \n constructor/**/ } || (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) { return ts.findAncestor(contextToken, ts.isClassLike); } switch (contextToken.kind) { - case 62 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; case 26 /* SemicolonToken */: // class c {getValue(): number; | } case 19 /* CloseBraceToken */: // class c { method() { } | } @@ -126083,8 +128940,8 @@ var ts; break; case 26 /* SemicolonToken */: case 27 /* CommaToken */: - case 78 /* Identifier */: - if (parent.kind === 163 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + case 79 /* Identifier */: + if (parent.kind === 164 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { return parent.parent; } break; @@ -126101,11 +128958,11 @@ var ts; if (!t) return undefined; switch (node.kind) { - case 163 /* PropertySignature */: + case 164 /* PropertySignature */: return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); - case 184 /* IntersectionType */: - case 178 /* TypeLiteral */: - case 183 /* UnionType */: + case 186 /* IntersectionType */: + case 180 /* TypeLiteral */: + case 185 /* UnionType */: return t; } } @@ -126133,7 +128990,7 @@ var ts; ? !!ts.tryGetImportFromModuleSpecifier(contextToken) : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); case " ": - return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 298 /* SourceFile */; + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 300 /* SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -126168,7 +129025,7 @@ var ts; if (type) { return type; } - if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ && node === node.parent.left) { + if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ && node === node.parent.left) { // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(node.parent); } @@ -126176,7 +129033,7 @@ var ts; } function getImportCompletionNode(contextToken) { var candidate = getCandidate(); - return candidate === 153 /* FromKeyword */ || candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined; + return candidate === 154 /* FromKeyword */ || candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined; function getCandidate() { var parent = contextToken.parent; if (ts.isImportEqualsDeclaration(parent)) { @@ -126185,8 +129042,8 @@ var ts; if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { if (isModuleSpecifierMissingOrEmpty(parent.parent.parent.moduleSpecifier) && (ts.isNamespaceImport(parent) || parent.elements.length < 2) && !parent.parent.name) { // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` - return contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 78 /* Identifier */ - ? 153 /* FromKeyword */ + return contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */ + ? 154 /* FromKeyword */ : parent.parent.parent; } return undefined; @@ -126224,11 +129081,63 @@ var ts; function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) { if (seenModules === void 0) { seenModules = new ts.Map(); } var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker); - return !!(sym.flags & 788968 /* Type */) || - !!(sym.flags & 1536 /* Module */) && - ts.addToSeen(seenModules, ts.getSymbolId(sym)) && + return !!(sym.flags & 788968 /* Type */) || checker.isUnknownSymbol(sym) || + !!(sym.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(sym)) && checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); } + function isDeprecated(symbol, checker) { + var declarations = ts.skipAlias(symbol, checker).declarations; + return !!ts.length(declarations) && ts.every(declarations, ts.isDeprecatedDeclaration); + } + /** + * True if the first character of `lowercaseCharacters` is the first character + * of some "word" in `identiferString` (where the string is split into "words" + * by camelCase and snake_case segments), then if the remaining characters of + * `lowercaseCharacters` appear, in order, in the rest of `identifierString`. + * + * True: + * 'state' in 'useState' + * 'sae' in 'useState' + * 'viable' in 'ENVIRONMENT_VARIABLE' + * + * False: + * 'staet' in 'useState' + * 'tate' in 'useState' + * 'ment' in 'ENVIRONMENT_VARIABLE' + */ + function charactersFuzzyMatchInString(identifierString, lowercaseCharacters) { + if (lowercaseCharacters.length === 0) { + return true; + } + var matchedFirstCharacter = false; + var prevChar; + var characterIndex = 0; + var len = identifierString.length; + for (var strIndex = 0; strIndex < len; strIndex++) { + var strChar = identifierString.charCodeAt(strIndex); + var testChar = lowercaseCharacters.charCodeAt(characterIndex); + if (strChar === testChar || strChar === toUpperCharCode(testChar)) { + matchedFirstCharacter || (matchedFirstCharacter = prevChar === undefined || // Beginning of word + 97 /* a */ <= prevChar && prevChar <= 122 /* z */ && 65 /* A */ <= strChar && strChar <= 90 /* Z */ || // camelCase transition + prevChar === 95 /* _ */ && strChar !== 95 /* _ */); // snake_case transition + if (matchedFirstCharacter) { + characterIndex++; + } + if (characterIndex === lowercaseCharacters.length) { + return true; + } + } + prevChar = strChar; + } + // Did not find all characters + return false; + } + function toUpperCharCode(charCode) { + if (97 /* a */ <= charCode && charCode <= 122 /* z */) { + return charCode - 32; + } + return charCode; + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -126263,10 +129172,11 @@ var ts; if (!referenceEntries) return undefined; var map = ts.arrayToMultiMap(referenceEntries.map(ts.FindAllReferences.toHighlightSpan), function (e) { return e.fileName; }, function (e) { return e.span; }); + var getCanonicalFileName = ts.createGetCanonicalFileName(program.useCaseSensitiveFileNames()); return ts.mapDefined(ts.arrayFrom(map.entries()), function (_a) { var fileName = _a[0], highlightSpans = _a[1]; if (!sourceFilesSet.has(fileName)) { - if (!program.redirectTargetsMap.has(fileName)) { + if (!program.redirectTargetsMap.has(ts.toPath(fileName, program.getCurrentDirectory(), getCanonicalFileName))) { return undefined; } var redirectTarget_1 = program.getSourceFile(fileName); @@ -126283,44 +129193,44 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 98 /* IfKeyword */: - case 90 /* ElseKeyword */: + case 99 /* IfKeyword */: + case 91 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 104 /* ReturnKeyword */: + case 105 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 108 /* ThrowKeyword */: + case 109 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 110 /* TryKeyword */: - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: - var tryStatement = node.kind === 82 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* TryKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: + var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 106 /* SwitchKeyword */: + case 107 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 81 /* CaseKeyword */: - case 87 /* DefaultKeyword */: { + case 82 /* CaseKeyword */: + case 88 /* DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 80 /* BreakKeyword */: - case 85 /* ContinueKeyword */: + case 81 /* BreakKeyword */: + case 86 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 96 /* ForKeyword */: - case 114 /* WhileKeyword */: - case 89 /* DoKeyword */: + case 97 /* ForKeyword */: + case 115 /* WhileKeyword */: + case 90 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 132 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [132 /* ConstructorKeyword */]); - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [134 /* GetKeyword */, 146 /* SetKeyword */]); - case 130 /* AwaitKeyword */: + case 133 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [133 /* ConstructorKeyword */]); + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [135 /* GetKeyword */, 147 /* SetKeyword */]); + case 131 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 124 /* YieldKeyword */: + case 125 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -126363,7 +129273,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 298 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 300 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -126395,16 +129305,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 245 /* SwitchStatement */: - if (statement.kind === 241 /* ContinueStatement */) { + case 247 /* SwitchStatement */: + if (statement.kind === 243 /* ContinueStatement */) { return false; } // falls through - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 237 /* WhileStatement */: - case 236 /* DoStatement */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 239 /* WhileStatement */: + case 238 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -126420,41 +129330,41 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 258 /* ModuleBlock */: - case 298 /* SourceFile */: - case 231 /* Block */: - case 285 /* CaseClause */: - case 286 /* DefaultClause */: + case 260 /* ModuleBlock */: + case 300 /* SourceFile */: + case 233 /* Block */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { - return __spreadArray(__spreadArray([], declaration.members), [declaration]); + return __spreadArray(__spreadArray([], declaration.members, true), [declaration], false); } else { return container.statements; } - case 167 /* Constructor */: - case 166 /* MethodDeclaration */: - case 252 /* FunctionDeclaration */: - return __spreadArray(__spreadArray([], container.parameters), (ts.isClassLike(container.parent) ? container.parent.members : [])); - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: - case 178 /* TypeLiteral */: + case 169 /* Constructor */: + case 167 /* MethodDeclaration */: + case 254 /* FunctionDeclaration */: + return __spreadArray(__spreadArray([], container.parameters, true), (ts.isClassLike(container.parent) ? container.parent.members : []), true); + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: + case 180 /* TypeLiteral */: var 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 & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { - return __spreadArray(__spreadArray([], nodes), constructor.parameters); + return __spreadArray(__spreadArray([], nodes, true), constructor.parameters, true); } } else if (modifierFlag & 128 /* Abstract */) { - return __spreadArray(__spreadArray([], nodes), [container]); + return __spreadArray(__spreadArray([], nodes, true), [container], false); } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -126473,12 +129383,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 96 /* ForKeyword */, 114 /* WhileKeyword */, 89 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 236 /* DoStatement */) { + if (loopNode.kind === 238 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 114 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { break; } } @@ -126486,7 +129396,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 80 /* BreakKeyword */, 85 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); } }); return keywords; @@ -126495,13 +129405,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 236 /* DoStatement */: - case 237 /* WhileStatement */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -126509,13 +129419,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 106 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* 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(), 81 /* CaseKeyword */, 87 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 80 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); } }); }); @@ -126523,13 +129433,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 110 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 82 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 95 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 95 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); } return keywords; } @@ -126540,13 +129450,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 108 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); }); // 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) { - keywords.push(ts.findChildOfKind(returnStatement, 104 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -126558,11 +129468,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 104 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 108 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -126574,13 +129484,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 129 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 130 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 130 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 131 /* AwaitKeyword */); } }); }); @@ -126595,7 +129505,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 124 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); } }); }); @@ -126614,7 +129524,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 === 90 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -126649,10 +129559,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 98 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* 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], 90 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { break; } } @@ -126910,43 +129820,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 204 /* CallExpression */: + case 206 /* CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 250 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 252 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { directImports.push(name); break; } } } break; - case 78 /* Identifier */: // for 'const x = require("y"); + case 79 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 264 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 266 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); } - else if (direct.exportClause.kind === 270 /* NamespaceExport */) { + else if (direct.exportClause.kind === 272 /* NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -126955,7 +129865,7 @@ var ts; directImports.push(direct); } break; - case 196 /* ImportType */: + case 198 /* ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -126977,7 +129887,7 @@ var ts; return ts.findAncestor(node, function (node) { if (stopAtAmbientModule && isAmbientModuleDeclaration(node)) return "quit"; - return ts.some(node.modifiers, function (mod) { return mod.kind === 92 /* ExportKeyword */; }); + return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* ExportKeyword */; }); }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { @@ -126988,7 +129898,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 298 /* SourceFile */ || sourceFileLike.kind === 257 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 300 /* SourceFile */ || sourceFileLike.kind === 259 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -127044,17 +129954,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 261 /* ImportEqualsDeclaration */) { + if (decl.kind === 263 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 78 /* Identifier */) { + if (decl.kind === 79 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 196 /* ImportType */) { + if (decl.kind === 198 /* ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { @@ -127070,7 +129980,7 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 268 /* ExportDeclaration */) { + if (decl.kind === 270 /* ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -127079,10 +129989,10 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 265 /* NamedImports */: + case 267 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -127132,7 +130042,7 @@ var ts; } } else { - var localSymbol = element.kind === 271 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 273 /* ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -127161,7 +130071,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 298 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 300 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -127209,7 +130119,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 298 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 300 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -127224,15 +130134,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 268 /* ExportDeclaration */: - case 262 /* ImportDeclaration */: { + case 270 /* ExportDeclaration */: + case 264 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 261 /* ImportEqualsDeclaration */: { + case 263 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -127257,7 +130167,7 @@ var ts; var parent = node.parent; var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 202 /* PropertyAccessExpression */) { + if (parent.kind === 204 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) @@ -127391,16 +130301,16 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 266 /* ImportSpecifier */: + case 268 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 263 /* ImportClause */: - case 264 /* NamespaceImport */: + case 265 /* ImportClause */: + case 266 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 199 /* BindingElement */: + case 201 /* BindingElement */: return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent); default: return false; @@ -127441,21 +130351,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 204 /* CallExpression */) { + if (node.kind === 206 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 298 /* SourceFile */) { + if (parent.kind === 300 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 258 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 260 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 257 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 259 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 273 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 275 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -127549,7 +130459,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 87 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -127558,7 +130468,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -127566,28 +130476,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 199 /* BindingElement */: + case 201 /* BindingElement */: return getContextNode(node.parent.parent); - case 266 /* ImportSpecifier */: + case 268 /* ImportSpecifier */: return node.parent.parent.parent; - case 271 /* ExportSpecifier */: - case 264 /* NamespaceImport */: + case 273 /* ExportSpecifier */: + case 266 /* NamespaceImport */: return node.parent.parent; - case 263 /* ImportClause */: - case 270 /* NamespaceExport */: + case 265 /* ImportClause */: + case 272 /* NamespaceExport */: return node.parent; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 240 /* ForOfStatement */: - case 239 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 241 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 289 /* PropertyAssignment */: - case 290 /* ShorthandPropertyAssignment */: + case 291 /* PropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -127644,14 +130554,14 @@ var ts; var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 202 /* PropertyAccessExpression */ - || node.parent.kind === 199 /* BindingElement */ - || node.parent.kind === 203 /* ElementAccessExpression */ - || node.kind === 105 /* SuperKeyword */) { - referenceEntries = entries && __spreadArray([], entries); + if (node.parent.kind === 204 /* PropertyAccessExpression */ + || node.parent.kind === 201 /* BindingElement */ + || node.parent.kind === 205 /* ElementAccessExpression */ + || node.kind === 106 /* SuperKeyword */) { + referenceEntries = entries && __spreadArray([], entries, true); } else { - var queue = entries && __spreadArray([], entries); + var queue = entries && __spreadArray([], entries, true); var seenNodes = new ts.Map(); while (queue && queue.length) { var entry = queue.shift(); @@ -127670,18 +130580,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 298 /* SourceFile */) { + if (node.kind === 300 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 290 /* ShorthandPropertyAssignment */) { - var result_1 = []; - Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); - return result_1; + if (node.parent.kind === 292 /* ShorthandPropertyAssignment */) { + var result_2 = []; + Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); }); + return result_2; } - else if (node.kind === 105 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -127714,9 +130624,7 @@ var ts; var name_1 = displayParts_1.map(function (p) { return p.text; }).join(""); var declaration = symbol.declarations && ts.firstOrUndefined(symbol.declarations); var node = declaration ? (ts.getNameOfDeclaration(declaration) || declaration) : originalNode; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_1, - kind: kind_1, - displayParts: displayParts_1, context: getContextNode(declaration) }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_1, kind: kind_1, displayParts: displayParts_1, context: getContextNode(declaration) }); } case 1 /* Label */: { var node = def.node; @@ -127751,10 +130659,7 @@ var ts; } })(); var sourceFile = info.sourceFile, textSpan = info.textSpan, name = info.name, kind = info.kind, displayParts = info.displayParts, context = info.context; - return __assign({ containerKind: "" /* unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, - name: name, - textSpan: textSpan, - displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); + return __assign({ containerKind: "" /* unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); } function getFileAndTextSpanFromNode(node) { var sourceFile = node.getSourceFile(); @@ -127851,13 +130756,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 201 /* ObjectLiteralExpression */) { + else if (node.kind === 203 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 222 /* ClassExpression */) { + else if (node.kind === 224 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -127901,13 +130806,13 @@ var ts; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 87 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); } function isDefinitionForReference(node) { - return node.kind === 87 /* DefaultKeyword */ + return node.kind === 88 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 132 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 133 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -127918,47 +130823,47 @@ var ts; if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 217 /* BinaryExpression */: - case 199 /* BindingElement */: - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 87 /* DefaultKeyword */: - case 256 /* EnumDeclaration */: - case 292 /* EnumMember */: - case 271 /* ExportSpecifier */: - case 263 /* ImportClause */: // default import - case 261 /* ImportEqualsDeclaration */: - case 266 /* ImportSpecifier */: - case 254 /* InterfaceDeclaration */: - case 328 /* JSDocCallbackTag */: - case 335 /* JSDocTypedefTag */: - case 281 /* JsxAttribute */: - case 257 /* ModuleDeclaration */: - case 260 /* NamespaceExportDeclaration */: - case 264 /* NamespaceImport */: - case 270 /* NamespaceExport */: - case 161 /* Parameter */: - case 290 /* ShorthandPropertyAssignment */: - case 255 /* TypeAliasDeclaration */: - case 160 /* TypeParameter */: + case 219 /* BinaryExpression */: + case 201 /* BindingElement */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 88 /* DefaultKeyword */: + case 258 /* EnumDeclaration */: + case 294 /* EnumMember */: + case 273 /* ExportSpecifier */: + case 265 /* ImportClause */: // default import + case 263 /* ImportEqualsDeclaration */: + case 268 /* ImportSpecifier */: + case 256 /* InterfaceDeclaration */: + case 333 /* JSDocCallbackTag */: + case 340 /* JSDocTypedefTag */: + case 283 /* JsxAttribute */: + case 259 /* ModuleDeclaration */: + case 262 /* NamespaceExportDeclaration */: + case 266 /* NamespaceImport */: + case 272 /* NamespaceExport */: + case 162 /* Parameter */: + case 292 /* ShorthandPropertyAssignment */: + case 257 /* TypeAliasDeclaration */: + case 161 /* TypeParameter */: return true; - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 167 /* Constructor */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 169 /* Constructor */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return !!decl.body; - case 250 /* VariableDeclaration */: - case 164 /* PropertyDeclaration */: + case 252 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 165 /* MethodSignature */: - case 163 /* PropertySignature */: - case 337 /* JSDocPropertyTag */: - case 330 /* JSDocParameterTag */: + case 166 /* MethodSignature */: + case 164 /* PropertySignature */: + case 342 /* JSDocPropertyTag */: + case 335 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -128179,10 +131084,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 298 /* SourceFile */: + case 300 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } @@ -128201,7 +131106,7 @@ var ts; if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : - ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 92 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } @@ -128211,25 +131116,28 @@ var ts; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 142 /* ReadonlyKeyword */ + return node.kind === 143 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 142 /* ReadonlyKeyword */; + && node.parent.operator === 143 /* ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A void expression (i.e., `void foo()`) is not special, but the `void` type is. - if (node.kind === 113 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { return undefined; } // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 142 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 143 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 142 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 143 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + } + if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { + return [{ definition: { type: 2 /* Keyword */, node: node }, references: [nodeEntry(node)] }]; } // Labels if (ts.isJumpStatementTarget(node)) { @@ -128245,7 +131153,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 105 /* SuperKeyword */) { + if (node.kind === 106 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -128262,7 +131170,7 @@ var ts; // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 87 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { + else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { addReference(node, symbol, state); searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* Default */ }, state); } @@ -128290,10 +131198,10 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 167 /* Constructor */: - case 132 /* ConstructorKeyword */: + case 169 /* Constructor */: + case 133 /* ConstructorKeyword */: return 1 /* Constructor */; - case 78 /* Identifier */: + case 79 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -128533,7 +131441,7 @@ 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 declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 209 /* FunctionExpression */ || valueDeclaration.kind === 222 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 211 /* FunctionExpression */ || valueDeclaration.kind === 224 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -128543,7 +131451,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 253 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 255 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -128572,7 +131480,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 298 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 300 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -128688,8 +131596,12 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 79 /* PrivateIdentifier */: - case 78 /* Identifier */: + case 80 /* PrivateIdentifier */: + if (ts.isJSDocMemberName(node.parent)) { + return true; + } + // falls through I guess + case 79 /* Identifier */: return node.text.length === searchSymbolName.length; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { @@ -128699,7 +131611,7 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 87 /* DefaultKeyword */: + case 88 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -128765,7 +131677,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 78 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -128789,7 +131701,7 @@ var ts; ts.Debug.assertNever(state.specialSearchKind); } // Use the parent symbol if the location is commonjs require syntax on javascript files only. - referenceSymbol = ts.isInJSFile(referenceLocation) && referenceLocation.parent.kind === 199 /* BindingElement */ && ts.isRequireVariableDeclaration(referenceLocation.parent) + referenceSymbol = ts.isInJSFile(referenceLocation) && referenceLocation.parent.kind === 201 /* BindingElement */ && ts.isRequireVariableDeclaration(referenceLocation.parent) ? referenceLocation.parent.symbol : referenceSymbol; getImportOrExportReferences(referenceLocation, referenceSymbol, search, state); @@ -128825,8 +131737,8 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 87 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 87 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); @@ -128907,7 +131819,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 87 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -128929,12 +131841,12 @@ var ts; var addRef = state.referenceAdder(search.symbol); for (var _i = 0, _a = classLike.members; _i < _a.length; _i++) { var member = _a[_i]; - if (!(ts.isMethodOrAccessor(member) && ts.hasSyntacticModifier(member, 32 /* Static */))) { + if (!(ts.isMethodOrAccessor(member) && ts.isStatic(member))) { continue; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 107 /* ThisKeyword */) { + if (node.kind === 108 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -128953,18 +131865,18 @@ var ts; if (constructorSymbol && constructorSymbol.declarations) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 132 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 167 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 133 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 169 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 166 /* MethodDeclaration */) { + if (decl && decl.kind === 167 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 107 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -128985,10 +131897,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 167 /* Constructor */); + ts.Debug.assert(decl.kind === 169 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 105 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -129012,10 +131924,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 78 /* Identifier */) { + if (refNode.kind !== 79 /* Identifier */) { return; } - if (refNode.parent.kind === 290 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 292 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -129035,7 +131947,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 231 /* Block */) { + if (body.kind === 233 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -129063,13 +131975,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 208 /* ParenthesizedExpression */: + case 210 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 210 /* ArrowFunction */: - case 209 /* FunctionExpression */: - case 201 /* ObjectLiteralExpression */: - case 222 /* ClassExpression */: - case 200 /* ArrayLiteralExpression */: + case 212 /* ArrowFunction */: + case 211 /* FunctionExpression */: + case 203 /* ObjectLiteralExpression */: + case 224 /* ClassExpression */: + case 202 /* ArrayLiteralExpression */: return true; default: return false; @@ -129122,13 +132034,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -129137,55 +132049,55 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 105 /* SuperKeyword */) { + if (node.kind !== 106 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); // If we have a 'super' container, we must have an enclosing class. // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. - return container && (32 /* Static */ & ts.getSyntacticModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined; + return container && ts.isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined; }); return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 78 /* Identifier */ && node.parent.kind === 161 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* Identifier */ && node.parent.kind === 162 /* Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 298 /* SourceFile */: + case 300 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: + case 211 /* 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. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 298 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 300 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -129193,20 +132105,20 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 209 /* FunctionExpression */: - case 252 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 222 /* ClassExpression */: - case 253 /* ClassDeclaration */: - case 201 /* ObjectLiteralExpression */: + case 224 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 203 /* ObjectLiteralExpression */: // Make sure the container belongs to the same class/object literals // and has the appropriate static modifier from the original container. - return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getSyntacticModifierFlags(container) & 32 /* Static */) === staticFlag; - case 298 /* SourceFile */: - return container.kind === 298 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag; + case 300 /* SourceFile */: + return container.kind === 300 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); @@ -129246,7 +132158,7 @@ var ts; forEachRelatedSymbol(symbol, location, checker, isForRename, !(isForRename && providePrefixAndSuffixText), function (sym, root, base) { // static method/property and instance method/property might have the same name. Only include static or only include instance. if (base) { - if (isStatic(symbol) !== isStatic(base)) { + if (isStaticSymbol(symbol) !== isStaticSymbol(base)) { base = undefined; } } @@ -129316,7 +132228,7 @@ var ts; ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 271 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 273 /* ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { @@ -129361,7 +132273,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 199 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 201 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -129393,7 +132305,7 @@ var ts; }); }); } } - function isStatic(symbol) { + function isStaticSymbol(symbol) { if (!symbol.valueDeclaration) { return false; } @@ -129407,7 +132319,7 @@ var ts; // check whether the symbol used to search itself is just the searched one. if (baseSymbol) { // static method/property and instance method/property might have the same name. Only check static or only check instance. - if (isStatic(referenceSymbol) !== isStatic(baseSymbol)) { + if (isStaticSymbol(referenceSymbol) !== isStaticSymbol(baseSymbol)) { baseSymbol = undefined; } } @@ -129532,6 +132444,7 @@ var ts; || ts.isFunctionExpression(node) || ts.isClassDeclaration(node) || ts.isClassExpression(node) + || ts.isClassStaticBlockDeclaration(node) || ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isGetAccessorDeclaration(node) @@ -129547,6 +132460,7 @@ var ts; || ts.isModuleDeclaration(node) && ts.isIdentifier(node.name) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) + || ts.isClassStaticBlockDeclaration(node) || ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isGetAccessorDeclaration(node) @@ -129565,7 +132479,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 87 /* DefaultKeyword */; + return node.kind === 88 /* DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -129583,6 +132497,15 @@ var ts; return { text: "default", pos: defaultModifier.getStart(), end: defaultModifier.getEnd() }; } } + if (ts.isClassStaticBlockDeclaration(node)) { + var sourceFile = node.getSourceFile(); + var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(node).pos); + var end = pos + 6; /* "static".length */ + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node.parent); + var prefix = symbol ? typeChecker.symbolToString(symbol, node.parent) + " " : ""; + return { text: prefix + "static {}", pos: pos, end: end }; + } var declName = isConstNamedExpression(node) ? node.parent.name : ts.Debug.checkDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name"); var text = ts.isIdentifier(declName) ? ts.idText(declName) : @@ -129614,16 +132537,16 @@ var ts; return; } switch (node.kind) { - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 166 /* MethodDeclaration */: - if (node.parent.kind === 201 /* ObjectLiteralExpression */) { + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 167 /* MethodDeclaration */: + if (node.parent.kind === 203 /* ObjectLiteralExpression */) { return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText(); } return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText(); - case 252 /* FunctionDeclaration */: - case 253 /* ClassDeclaration */: - case 257 /* ModuleDeclaration */: + case 254 /* FunctionDeclaration */: + case 255 /* ClassDeclaration */: + case 259 /* ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -129669,6 +132592,9 @@ var ts; /** Find the implementation or the first declaration for a call hierarchy declaration. */ function findImplementationOrAllInitialDeclarations(typeChecker, node) { var _a, _b, _c; + if (ts.isClassStaticBlockDeclaration(node)) { + return node; + } if (ts.isFunctionLikeDeclaration(node)) { return (_b = (_a = findImplementation(typeChecker, node)) !== null && _a !== void 0 ? _a : findAllInitialDeclarations(typeChecker, node)) !== null && _b !== void 0 ? _b : node; } @@ -129676,13 +132602,14 @@ var ts; } /** Resolves the call hierarchy declaration for a node. */ function resolveCallHierarchyDeclaration(program, location) { - // A call hierarchy item must refer to either a SourceFile, Module Declaration, or something intrinsically callable that has a name: + // A call hierarchy item must refer to either a SourceFile, Module Declaration, Class Static Block, or something intrinsically callable that has a name: // - Class Declarations // - Class Expressions (with a name) // - Function Declarations // - Function Expressions (with a name or assigned to a const variable) // - Arrow Functions (assigned to a const variable) // - Constructors + // - Class `static {}` initializer blocks // - Methods // - Accessors // @@ -129717,6 +132644,10 @@ var ts; } return undefined; } + if (location.kind === 124 /* StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { + location = location.parent; + continue; + } // #39453 if (ts.isVariableDeclaration(location) && location.initializer && isConstNamedExpression(location.initializer)) { return location.initializer; @@ -129780,7 +132711,7 @@ var ts; /** Gets the call sites that call into the provided call hierarchy declaration. */ function getIncomingCalls(program, declaration, cancellationToken) { // Source files and modules have no incoming calls. - if (ts.isSourceFile(declaration) || ts.isModuleDeclaration(declaration)) { + if (ts.isSourceFile(declaration) || ts.isModuleDeclaration(declaration) || ts.isClassStaticBlockDeclaration(declaration)) { return []; } var location = getCallHierarchyDeclarationReferenceNode(declaration); @@ -129793,7 +132724,8 @@ var ts; var target = ts.isTaggedTemplateExpression(node) ? node.tag : ts.isJsxOpeningLikeElement(node) ? node.tagName : ts.isAccessExpression(node) ? node : - node.expression; + ts.isClassStaticBlockDeclaration(node) ? node : + node.expression; var declaration = resolveCallHierarchyDeclaration(program, target); if (declaration) { var range = ts.createTextRangeFromNode(target, node.getSourceFile()); @@ -129828,56 +132760,59 @@ var ts; return; } switch (node.kind) { - case 78 /* Identifier */: - case 261 /* ImportEqualsDeclaration */: - case 262 /* ImportDeclaration */: - case 268 /* ExportDeclaration */: - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: + case 79 /* Identifier */: + case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportDeclaration */: + case 270 /* ExportDeclaration */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 207 /* TypeAssertionExpression */: - case 225 /* AsExpression */: + case 168 /* ClassStaticBlockDeclaration */: + recordCallSite(node); + return; + case 209 /* TypeAssertionExpression */: + case 227 /* AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 250 /* VariableDeclaration */: - case 161 /* Parameter */: + case 252 /* VariableDeclaration */: + case 162 /* Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 204 /* CallExpression */: + case 206 /* CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 205 /* NewExpression */: + case 207 /* NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 206 /* TaggedTemplateExpression */: + case 208 /* TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 276 /* JsxOpeningElement */: - case 275 /* JsxSelfClosingElement */: + case 278 /* JsxOpeningElement */: + case 277 /* JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 162 /* Decorator */: + case 163 /* Decorator */: recordCallSite(node); collect(node.expression); return; - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -129905,6 +132840,9 @@ var ts; collect(implementation.body); } } + function collectCallSitesOfClassStaticBlockDeclaration(node, collect) { + collect(node.body); + } function collectCallSitesOfClassLikeDeclaration(node, collect) { ts.forEach(node.decorators, collect); var heritage = ts.getClassExtendsHeritageElement(node); @@ -129921,30 +132859,36 @@ var ts; ts.forEach(member.parameters, collect); collect(member.body); } + else if (ts.isClassStaticBlockDeclaration(member)) { + collect(member); + } } } function collectCallSites(program, node) { var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 298 /* SourceFile */: + case 300 /* SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; + case 168 /* ClassStaticBlockDeclaration */: + collectCallSitesOfClassStaticBlockDeclaration(node, collect); + break; default: ts.Debug.assertNever(node); } @@ -130017,16 +132961,18 @@ var ts; case "include": case "exclude": { var foundExactMatch = updatePaths(property); - if (!foundExactMatch && propertyName === "include" && ts.isArrayLiteralExpression(property.initializer)) { - var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); - var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory); - // If there isn't some include for this, add a new one. - if (ts.getRegexFromPattern(ts.Debug.checkDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(oldFileOrDirPath) && - !ts.getRegexFromPattern(ts.Debug.checkDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { - changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.factory.createStringLiteral(relativePath(newFileOrDirPath))); - } + if (foundExactMatch || propertyName !== "include" || !ts.isArrayLiteralExpression(property.initializer)) + return; + var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); + if (includes.length === 0) + return; + var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory); + // If there isn't some include for this, add a new one. + if (ts.getRegexFromPattern(ts.Debug.checkDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(oldFileOrDirPath) && + !ts.getRegexFromPattern(ts.Debug.checkDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { + changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.factory.createStringLiteral(relativePath(newFileOrDirPath))); } - break; + return; } case "compilerOptions": forEachProperty(property.initializer, function (property, propertyName) { @@ -130045,11 +132991,10 @@ var ts; }); } }); - break; + return; } }); function updatePaths(property) { - // Type annotation needed due to #7294 var elements = ts.isArrayLiteralExpression(property.initializer) ? property.initializer.elements : [property.initializer]; var foundExactMatch = false; for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { @@ -130137,9 +133082,9 @@ var ts; return undefined; // First try resolved module if (resolved.resolvedModule) { - var result_2 = tryChange(resolved.resolvedModule.resolvedFileName); - if (result_2) - return result_2; + var result_3 = tryChange(resolved.resolvedModule.resolvedFileName); + if (result_3) + return result_3; } // Then failed lookups that are in the list of sources var result = ts.forEach(resolved.failedLookupLocations, tryChangeWithIgnoringPackageJsonExisting) @@ -130209,11 +133154,26 @@ var ts; } var parent = node.parent; var typeChecker = program.getTypeChecker(); + if (node.kind === 157 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { + return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray; + } // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } + if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { + var classDecl = node.parent.parent; + var symbol_1 = getSymbol(classDecl, typeChecker); + var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration); + var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : ""; + var sourceFile_1 = node.getSourceFile(); + return ts.map(staticBlocks, function (staticBlock) { + var pos = ts.moveRangePastModifiers(staticBlock).pos; + pos = ts.skipTrivia(sourceFile_1.text, pos); + return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length }); + }); + } var symbol = getSymbol(node, typeChecker); // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol @@ -130232,7 +133192,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 105 /* SuperKeyword */ ? __spreadArray([sigInfo], defs) : __spreadArray(__spreadArray([], defs), [sigInfo]); + return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -130240,7 +133200,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 === 290 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 292 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : ts.emptyArray; return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); @@ -130299,6 +133259,25 @@ var ts; } } } + function getDefinitionFromOverriddenMember(typeChecker, node) { + var classElement = ts.findAncestor(node, ts.isClassElement); + if (!(classElement && classElement.name)) + return; + var baseDeclaration = ts.findAncestor(classElement, ts.isClassLike); + if (!baseDeclaration) + return; + var baseTypeNode = ts.getEffectiveBaseTypeNode(baseDeclaration); + var baseType = baseTypeNode ? typeChecker.getTypeAtLocation(baseTypeNode) : undefined; + if (!baseType) + return; + var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(classElement.name)); + var symbol = ts.hasStaticModifier(classElement) + ? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbolAtLocation(baseType.symbol, baseDeclaration), name) + : typeChecker.getPropertyOfType(baseType, name); + if (!symbol) + return; + return getDefinitionFromSymbol(typeChecker, symbol, node); + } function getReferenceAtPosition(sourceFile, position, program) { var _a, _b; var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); @@ -130389,13 +133368,7 @@ var ts; GoToDefinition.getDefinitionAndBoundSpan = getDefinitionAndBoundSpan; // At 'x.foo', see if the type of 'x' has an index signature, and if so find its declarations. function getDefinitionInfoForIndexSignatures(node, checker) { - if (!ts.isPropertyAccessExpression(node.parent) || node.parent.name !== node) - return; - var type = checker.getTypeAtLocation(node.parent.expression); - return ts.mapDefined(type.isUnionOrIntersection() ? type.types : [type], function (nonUnionType) { - var info = checker.getIndexInfoOfType(nonUnionType, 0 /* String */); - return info && info.declaration && createDefinitionFromSignatureDeclaration(checker, info.declaration); - }); + return ts.mapDefined(checker.getIndexInfosAtLocation(node), function (info) { return info.declaration && createDefinitionFromSignatureDeclaration(checker, info.declaration); }); } function getSymbol(node, checker) { var symbol = checker.getSymbolAtLocation(node); @@ -130417,20 +133390,20 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 78 /* Identifier */) { + if (node.kind !== 79 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 263 /* ImportClause */: - case 261 /* ImportEqualsDeclaration */: + case 265 /* ImportClause */: + case 263 /* ImportEqualsDeclaration */: return true; - case 266 /* ImportSpecifier */: - return declaration.parent.kind === 265 /* NamedImports */; - case 199 /* BindingElement */: - case 250 /* VariableDeclaration */: + case 268 /* ImportSpecifier */: + return declaration.parent.kind === 267 /* NamedImports */; + case 201 /* BindingElement */: + case 252 /* VariableDeclaration */: return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration); default: return false; @@ -130446,7 +133419,7 @@ var ts; function getConstructSignatureDefinition() { // 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 (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 132 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 133 /* ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -130478,10 +133451,12 @@ var ts; return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName); } /** Creates a DefinitionInfo directly from the name of a declaration. */ - function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName) { - var name = ts.getNameOfDeclaration(declaration) || declaration; - var sourceFile = name.getSourceFile(); - var textSpan = ts.createTextSpanFromNode(name, sourceFile); + function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) { + var sourceFile = declaration.getSourceFile(); + if (!textSpan) { + var name = ts.getNameOfDeclaration(declaration) || declaration; + textSpan = ts.createTextSpanFromNode(name, sourceFile); + } return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217 containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) }); } @@ -130495,22 +133470,22 @@ var ts; return isDefinitionVisible(checker, declaration.parent); // Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent switch (declaration.kind) { - case 164 /* PropertyDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 166 /* MethodDeclaration */: + case 165 /* PropertyDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 167 /* MethodDeclaration */: // Private/protected properties/methods are not visible if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) return false; // Public properties/methods are visible if its parents are visible, so: // falls through - case 167 /* Constructor */: - case 289 /* PropertyAssignment */: - case 290 /* ShorthandPropertyAssignment */: - case 201 /* ObjectLiteralExpression */: - case 222 /* ClassExpression */: - case 210 /* ArrowFunction */: - case 209 /* FunctionExpression */: + case 169 /* Constructor */: + case 291 /* PropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: + case 203 /* ObjectLiteralExpression */: + case 224 /* ClassExpression */: + case 212 /* ArrowFunction */: + case 211 /* FunctionExpression */: return isDefinitionVisible(checker, declaration.parent); default: return false; @@ -130548,9 +133523,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 167 /* Constructor */: - case 176 /* ConstructorType */: - case 171 /* ConstructSignature */: + case 169 /* Constructor */: + case 178 /* ConstructorType */: + case 173 /* ConstructSignature */: return true; default: return false; @@ -130655,10 +133630,20 @@ var ts; var parts = []; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { - var comment = _a[_i].comment; - if (comment === undefined) + var jsdoc = _a[_i]; + // skip comments containing @typedefs since they're not associated with particular declarations + // Exceptions: + // - @typedefs are themselves declarations with associated comments + // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation + if (jsdoc.comment === undefined + || ts.isJSDoc(jsdoc) + && declaration.kind !== 340 /* JSDocTypedefTag */ && declaration.kind !== 333 /* JSDocCallbackTag */ + && jsdoc.tags + && jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocTypedefTag */ || t.kind === 333 /* JSDocCallbackTag */; }) + && !jsdoc.tags.some(function (t) { return t.kind === 335 /* JSDocParameterTag */ || t.kind === 336 /* JSDocReturnTag */; })) { continue; - var newparts = getDisplayPartsFromComment(comment, checker); + } + var newparts = getDisplayPartsFromComment(jsdoc.comment, checker); if (!ts.contains(parts, newparts, isIdenticalListOfDisplayParts)) { parts.push(newparts); } @@ -130672,11 +133657,11 @@ var ts; } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 330 /* JSDocParameterTag */: - case 337 /* JSDocPropertyTag */: + case 335 /* JSDocParameterTag */: + case 342 /* JSDocPropertyTag */: return [declaration]; - case 328 /* JSDocCallbackTag */: - case 335 /* JSDocTypedefTag */: + case 333 /* JSDocCallbackTag */: + case 340 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -130684,39 +133669,47 @@ var ts; } function getJsDocTagsFromDeclarations(declarations, checker) { // Only collect doc comments from duplicate declarations once. - var tags = []; + var infos = []; ts.forEachUnique(declarations, function (declaration) { - for (var _i = 0, _a = ts.getJSDocTags(declaration); _i < _a.length; _i++) { - var tag = _a[_i]; - tags.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) }); + var tags = ts.getJSDocTags(declaration); + // skip comments containing @typedefs since they're not associated with particular declarations + // Exceptions: + // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation + if (tags.some(function (t) { return t.kind === 340 /* JSDocTypedefTag */ || t.kind === 333 /* JSDocCallbackTag */; }) + && !tags.some(function (t) { return t.kind === 335 /* JSDocParameterTag */ || t.kind === 336 /* JSDocReturnTag */; })) { + return; + } + for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) { + var tag = tags_1[_i]; + infos.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) }); } }); - return tags; + return infos; } JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; function getDisplayPartsFromComment(comment, checker) { if (typeof comment === "string") { return [ts.textPart(comment)]; } - return ts.flatMap(comment, function (node) { return node.kind === 313 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); + return ts.flatMap(comment, function (node) { return node.kind === 316 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); } function getCommentDisplayParts(tag, checker) { var comment = tag.comment, kind = tag.kind; var namePart = getTagNameDisplayPart(kind); switch (kind) { - case 319 /* JSDocImplementsTag */: + case 324 /* JSDocImplementsTag */: return withNode(tag.class); - case 318 /* JSDocAugmentsTag */: + case 323 /* JSDocAugmentsTag */: return withNode(tag.class); - case 334 /* JSDocTemplateTag */: + case 339 /* JSDocTemplateTag */: return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", ")); - case 333 /* JSDocTypeTag */: + case 338 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 335 /* JSDocTypedefTag */: - case 328 /* JSDocCallbackTag */: - case 337 /* JSDocPropertyTag */: - case 330 /* JSDocParameterTag */: - case 336 /* JSDocSeeTag */: + case 340 /* JSDocTypedefTag */: + case 333 /* JSDocCallbackTag */: + case 342 /* JSDocPropertyTag */: + case 335 /* JSDocParameterTag */: + case 341 /* JSDocSeeTag */: var name = tag.name; return name ? withNode(name) : comment === undefined ? undefined @@ -130730,10 +133723,10 @@ var ts; function addComment(s) { if (comment) { if (s.match(/^https?$/)) { - return __spreadArray([ts.textPart(s)], getDisplayPartsFromComment(comment, checker)); + return __spreadArray([ts.textPart(s)], getDisplayPartsFromComment(comment, checker), true); } else { - return __spreadArray([namePart(s), ts.spacePart()], getDisplayPartsFromComment(comment, checker)); + return __spreadArray([namePart(s), ts.spacePart()], getDisplayPartsFromComment(comment, checker), true); } } else { @@ -130743,14 +133736,14 @@ var ts; } function getTagNameDisplayPart(kind) { switch (kind) { - case 330 /* JSDocParameterTag */: + case 335 /* JSDocParameterTag */: return ts.parameterNamePart; - case 337 /* JSDocPropertyTag */: + case 342 /* JSDocPropertyTag */: return ts.propertyNamePart; - case 334 /* JSDocTemplateTag */: + case 339 /* JSDocTemplateTag */: return ts.typeParameterNamePart; - case 335 /* JSDocTypedefTag */: - case 328 /* JSDocCallbackTag */: + case 340 /* JSDocTypedefTag */: + case 333 /* JSDocCallbackTag */: return ts.typeAliasNamePart; default: return ts.textPart; @@ -130901,7 +133894,7 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 78 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -130914,24 +133907,24 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 166 /* MethodDeclaration */: - case 167 /* Constructor */: - case 165 /* MethodSignature */: - case 210 /* ArrowFunction */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 169 /* Constructor */: + case 166 /* MethodSignature */: + case 212 /* ArrowFunction */: var host = commentOwner; return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer, options); - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 163 /* PropertySignature */: - case 256 /* EnumDeclaration */: - case 292 /* EnumMember */: - case 255 /* TypeAliasDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 164 /* PropertySignature */: + case 258 /* EnumDeclaration */: + case 294 /* EnumMember */: + case 257 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 233 /* VariableStatement */: { + case 235 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -130941,16 +133934,16 @@ var ts; ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 298 /* SourceFile */: + case 300 /* SourceFile */: return "quit"; - case 257 /* ModuleDeclaration */: + case 259 /* 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 { }'. - return commentOwner.parent.kind === 257 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 234 /* ExpressionStatement */: + return commentOwner.parent.kind === 259 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 236 /* ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression, options); - case 217 /* BinaryExpression */: { + case 219 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -130959,7 +133952,7 @@ var ts; ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; @@ -130972,14 +133965,14 @@ var ts; || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 208 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 210 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: return rightHandSide; - case 222 /* ClassExpression */: + case 224 /* ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -131038,9 +134031,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 263 /* ImportClause */: - case 266 /* ImportSpecifier */: - case 261 /* ImportEqualsDeclaration */: + case 265 /* ImportClause */: + case 268 /* ImportSpecifier */: + case 263 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -131050,7 +134043,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 159 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 160 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -131067,7 +134060,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 159 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 160 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -131284,7 +134277,7 @@ var ts; */ function hasNavigationBarName(node) { return !ts.hasDynamicName(node) || - (node.kind !== 217 /* BinaryExpression */ && + (node.kind !== 219 /* BinaryExpression */ && ts.isPropertyAccessExpression(node.name.expression) && ts.isIdentifier(node.name.expression.expression) && ts.idText(node.name.expression.expression) === "Symbol"); @@ -131297,7 +134290,7 @@ var ts; return; } switch (node.kind) { - case 167 /* Constructor */: + case 169 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -131309,25 +134302,25 @@ var ts; } } break; - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 165 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 166 /* MethodSignature */: if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (hasNavigationBarName(node)) { addNodeWithRecursiveInitializer(node); } break; - case 163 /* PropertySignature */: + case 164 /* PropertySignature */: if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 263 /* ImportClause */: + case 265 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -131339,7 +134332,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 264 /* NamespaceImport */) { + if (namedBindings.kind === 266 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -131350,17 +134343,17 @@ var ts; } } break; - case 290 /* ShorthandPropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 291 /* SpreadAssignment */: + case 293 /* SpreadAssignment */: var expression = node.expression; // Use the expression as the name of the SpreadAssignment, otherwise show as . ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); break; - case 199 /* BindingElement */: - case 289 /* PropertyAssignment */: - case 250 /* VariableDeclaration */: { + case 201 /* BindingElement */: + case 291 /* PropertyAssignment */: + case 252 /* VariableDeclaration */: { var child = node; if (ts.isBindingPattern(child.name)) { addChildrenRecursively(child.name); @@ -131370,7 +134363,7 @@ var ts; } break; } - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -131378,11 +134371,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 210 /* ArrowFunction */: - case 209 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 211 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -131392,9 +134385,9 @@ var ts; } endNode(); break; - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -131402,10 +134395,10 @@ var ts; } endNode(); break; - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 267 /* ExportAssignment */: { + case 269 /* ExportAssignment */: { var expression_1 = node.expression; var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 : ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined; @@ -131419,16 +134412,16 @@ var ts; } break; } - case 271 /* ExportSpecifier */: - case 261 /* ImportEqualsDeclaration */: - case 172 /* IndexSignature */: - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 255 /* TypeAliasDeclaration */: + case 273 /* ExportSpecifier */: + case 263 /* ImportEqualsDeclaration */: + case 174 /* IndexSignature */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 257 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 204 /* CallExpression */: - case 217 /* BinaryExpression */: { + case 206 /* CallExpression */: + case 219 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -131670,12 +134663,12 @@ var ts; return false; } switch (a.kind) { - case 164 /* PropertyDeclaration */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - return ts.hasSyntacticModifier(a, 32 /* Static */) === ts.hasSyntacticModifier(b, 32 /* Static */); - case 257 /* ModuleDeclaration */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + return ts.isStatic(a) === ts.isStatic(b); + case 259 /* ModuleDeclaration */: return areSameModule(a, b) && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: @@ -131694,7 +134687,7 @@ var ts; // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { - return a.body.kind === b.body.kind && (a.body.kind !== 257 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 259 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -131724,7 +134717,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 257 /* ModuleDeclaration */) { + if (node.kind === 259 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -131733,16 +134726,16 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 222 /* ClassExpression */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 224 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 257 /* ModuleDeclaration */) { + if (node.kind === 259 /* ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { @@ -131754,18 +134747,18 @@ var ts; } } switch (node.kind) { - case 298 /* SourceFile */: + case 300 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 210 /* ArrowFunction */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: + case 212 /* ArrowFunction */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -131773,13 +134766,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 167 /* Constructor */: + case 169 /* Constructor */: return "constructor"; - case 171 /* ConstructSignature */: + case 173 /* ConstructSignature */: return "new()"; - case 170 /* CallSignature */: + case 172 /* CallSignature */: return "()"; - case 172 /* IndexSignature */: + case 174 /* IndexSignature */: return "[]"; default: return ""; @@ -131812,19 +134805,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 256 /* EnumDeclaration */: - case 254 /* InterfaceDeclaration */: - case 257 /* ModuleDeclaration */: - case 298 /* SourceFile */: - case 255 /* TypeAliasDeclaration */: - case 335 /* JSDocTypedefTag */: - case 328 /* JSDocCallbackTag */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 258 /* EnumDeclaration */: + case 256 /* InterfaceDeclaration */: + case 259 /* ModuleDeclaration */: + case 300 /* SourceFile */: + case 257 /* TypeAliasDeclaration */: + case 340 /* JSDocTypedefTag */: + case 333 /* JSDocCallbackTag */: return true; - case 210 /* ArrowFunction */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -131834,10 +134827,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 258 /* ModuleBlock */: - case 298 /* SourceFile */: - case 166 /* MethodDeclaration */: - case 167 /* Constructor */: + case 260 /* ModuleBlock */: + case 300 /* SourceFile */: + case 167 /* MethodDeclaration */: + case 169 /* Constructor */: return true; default: return false; @@ -131899,7 +134892,7 @@ var ts; function getFullyQualifiedModuleName(moduleDeclaration) { // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)]; - while (moduleDeclaration.body && moduleDeclaration.body.kind === 257 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 259 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -131913,13 +134906,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 159 /* ComputedPropertyName */; + return !member.name || member.name.kind === 160 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 298 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 300 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 250 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 252 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -131934,7 +134927,7 @@ var ts; return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -131977,9 +134970,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 210 /* ArrowFunction */: - case 209 /* FunctionExpression */: - case 222 /* ClassExpression */: + case 212 /* ArrowFunction */: + case 211 /* FunctionExpression */: + case 224 /* ClassExpression */: return true; default: return false; @@ -132344,11 +135337,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return declaration.moduleSpecifier; - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -132387,19 +135380,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: if (!s1.importClause) return 0; if (s1.importClause.isTypeOnly) return 1; - if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 264 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 266 /* NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return 5; - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return 6; } } @@ -132421,7 +135414,7 @@ var ts; var depthRemaining = 40; var current = 0; // Includes the EOF Token so that comments which aren't attached to statements are included - var statements = __spreadArray(__spreadArray([], sourceFile.statements), [sourceFile.endOfFileToken]); + var statements = __spreadArray(__spreadArray([], sourceFile.statements, true), [sourceFile.endOfFileToken], false); var n = statements.length; while (current < n) { while (current < n && !ts.isAnyImportSyntax(statements[current])) { @@ -132437,7 +135430,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 99 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -132445,12 +135438,18 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n) || ts.isVariableStatement(n) || n.kind === 1 /* EndOfFileToken */) { + if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || n.kind === 1 /* EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (ts.isFunctionLike(n) && ts.isBinaryExpression(n.parent) && ts.isPropertyAccessExpression(n.parent.left)) { addOutliningForLeadingCommentsForNode(n.parent.left, sourceFile, cancellationToken, out); } + if (ts.isBlock(n) || ts.isModuleBlock(n)) { + addOutliningForLeadingCommentsForPos(n.statements.end, sourceFile, cancellationToken, out); + } + if (ts.isClassLike(n) || ts.isInterfaceDeclaration(n)) { + addOutliningForLeadingCommentsForPos(n.members.end, sourceFile, cancellationToken, out); + } var span = getOutliningSpanForNode(n, sourceFile); if (span) out.push(span); @@ -132501,12 +135500,19 @@ var ts; } } } - var regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + var regionDelimiterRegExp = /^#(end)?region(?:\s+(.*))?(?:\r)?$/; function isRegionDelimiter(lineText) { + // We trim the leading whitespace and // without the regex since the + // multiple potential whitespace matches can make for some gnarly backtracking behavior + lineText = ts.trimStringStart(lineText); + if (!ts.startsWith(lineText, "\/\/")) { + return null; // eslint-disable-line no-null/no-null + } + lineText = ts.trimString(lineText.slice(2)); return regionDelimiterRegExp.exec(lineText); } - function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { - var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); + function addOutliningForLeadingCommentsForPos(pos, sourceFile, cancellationToken, out) { + var comments = ts.getLeadingCommentRanges(sourceFile.text, pos); if (!comments) return; var firstSingleLineCommentStart = -1; @@ -132514,12 +135520,12 @@ var ts; var singleLineCommentCount = 0; var sourceText = sourceFile.getFullText(); for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var _a = comments_1[_i], kind = _a.kind, pos = _a.pos, end = _a.end; + var _a = comments_1[_i], kind = _a.kind, pos_1 = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { case 2 /* SingleLineCommentTrivia */: // never fold region delimiters into single-line comment regions - var commentText = sourceText.slice(pos, end); + var commentText = sourceText.slice(pos_1, end); if (isRegionDelimiter(commentText)) { combineAndAddMultipleSingleLineComments(); singleLineCommentCount = 0; @@ -132528,14 +135534,14 @@ var ts; // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (singleLineCommentCount === 0) { - firstSingleLineCommentStart = pos; + firstSingleLineCommentStart = pos_1; } lastSingleLineCommentEnd = end; singleLineCommentCount++; break; case 3 /* MultiLineCommentTrivia */: combineAndAddMultipleSingleLineComments(); - out.push(createOutliningSpanFromBounds(pos, end, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* Comment */)); singleLineCommentCount = 0; break; default: @@ -132550,12 +135556,17 @@ var ts; } } } + function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { + if (ts.isJsxText(n)) + return; + addOutliningForLeadingCommentsForPos(n.pos, sourceFile, cancellationToken, out); + } function createOutliningSpanFromBounds(pos, end, kind) { return createOutliningSpan(ts.createTextSpanFromBounds(pos, end), kind); } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 231 /* Block */: + case 233 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -132563,23 +135574,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 236 /* DoStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 238 /* ForStatement */: - case 235 /* IfStatement */: - case 237 /* WhileStatement */: - case 244 /* WithStatement */: - case 288 /* CatchClause */: + case 238 /* DoStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 240 /* ForStatement */: + case 237 /* IfStatement */: + case 239 /* WhileStatement */: + case 246 /* WithStatement */: + case 290 /* CatchClause */: return spanForNode(n.parent); - case 248 /* TryStatement */: + case 250 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - var node = ts.findChildOfKind(tryStatement, 95 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -132589,40 +135600,40 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 258 /* ModuleBlock */: + case 260 /* ModuleBlock */: return spanForNode(n.parent); - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: - case 256 /* EnumDeclaration */: - case 259 /* CaseBlock */: - case 178 /* TypeLiteral */: - case 197 /* ObjectBindingPattern */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: + case 258 /* EnumDeclaration */: + case 261 /* CaseBlock */: + case 180 /* TypeLiteral */: + case 199 /* ObjectBindingPattern */: return spanForNode(n); - case 180 /* TupleType */: + case 182 /* TupleType */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 285 /* CaseClause */: - case 286 /* DefaultClause */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: return spanForNodeArray(n.statements); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 274 /* JsxElement */: + case 276 /* JsxElement */: return spanForJSXElement(n); - case 278 /* JsxFragment */: + case 280 /* JsxFragment */: return spanForJSXFragment(n); - case 275 /* JsxSelfClosingElement */: - case 276 /* JsxOpeningElement */: + case 277 /* JsxSelfClosingElement */: + case 278 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 219 /* TemplateExpression */: + case 221 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 198 /* ArrayBindingPattern */: + case 200 /* ArrayBindingPattern */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return spanForArrowFunction(n); - case 204 /* CallExpression */: + case 206 /* CallExpression */: return spanForCallExpression(n); } function spanForCallExpression(node) { @@ -132689,7 +135700,7 @@ var ts; function functionSpan(node, body, sourceFile) { var openToken = tryGetFunctionOpenToken(node, body, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 210 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 212 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -133233,10 +136244,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 133 /* DeclareKeyword */) { + if (token === 134 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 139 /* ModuleKeyword */) { + if (token === 140 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -133254,7 +136265,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 99 /* ImportKeyword */) { + if (token === 100 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -133270,21 +136281,21 @@ var ts; return true; } else { - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 153 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || + return token !== 154 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || token === 18 /* OpenBraceToken */ || - token === 78 /* Identifier */ || + token === 79 /* Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -133292,7 +136303,7 @@ var ts; return true; } } - else if (token === 62 /* EqualsToken */) { + else if (token === 63 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -133315,7 +136326,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -133327,11 +136338,11 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 126 /* AsKeyword */) { + if (token === 127 /* AsKeyword */) { token = nextToken(); - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -133349,10 +136360,10 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 92 /* ExportKeyword */) { + if (token === 93 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); return token === 41 /* AsteriskToken */ || @@ -133371,7 +136382,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -133383,7 +136394,7 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -133391,21 +136402,21 @@ var ts; } } } - else if (token === 99 /* ImportKeyword */) { + else if (token === 100 /* ImportKeyword */) { token = nextToken(); - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 78 /* Identifier */ || + return token === 79 /* Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 62 /* EqualsToken */) { + if (token === 63 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -133419,7 +136430,7 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 143 /* RequireKeyword */) { + if (token === 144 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -133435,7 +136446,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 78 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -133584,14 +136595,14 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 87 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 159 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 160 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -133651,11 +136662,11 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -133710,9 +136721,9 @@ var ts; } // Synthesize a stop for '${ ... }' since '${' and '}' actually belong to siblings. if (ts.isTemplateSpan(parentNode) && nextNode && ts.isTemplateMiddleOrTemplateTail(nextNode)) { - var start_2 = node.getFullStart() - "${".length; + var start_1 = node.getFullStart() - "${".length; var end_2 = nextNode.getStart() + "}".length; - pushSelectionRange(start_2, end_2); + pushSelectionRange(start_1, end_2); } // Blocks with braces, brackets, parens, or JSX tags on separate lines should be // selected from open to close, including whitespace but not including the braces/etc. themselves. @@ -133817,14 +136828,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 142 /* ReadonlyKeyword */ || + return child === node.readonlyToken || child.kind === 143 /* ReadonlyKeyword */ || child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 160 /* TypeParameter */ || + kind === 161 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -133857,14 +136868,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 62 /* EqualsToken */; + return kind === 63 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 62 /* EqualsToken */; + return kind === 63 /* EqualsToken */; }); } return node.getChildren(); @@ -133938,22 +136949,22 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 276 /* JsxOpeningElement */; + || kind === 278 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 277 /* JsxClosingElement */; + || kind === 279 /* JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 330 /* JSDocParameterTag */: - case 328 /* JSDocCallbackTag */: - case 337 /* JSDocPropertyTag */: - case 335 /* JSDocTypedefTag */: - case 332 /* JSDocThisTag */: + case 335 /* JSDocParameterTag */: + case 333 /* JSDocCallbackTag */: + case 342 /* JSDocPropertyTag */: + case 340 /* JSDocTypedefTag */: + case 337 /* JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -134163,10 +137174,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 206 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 208 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 219 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 221 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -134235,17 +137246,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 208 /* ParenthesizedExpression */: - case 166 /* MethodDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 210 /* ParenthesizedExpression */: + case 167 /* MethodDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 217 /* BinaryExpression */: { + case 219 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -134369,7 +137380,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 === 219 /* TemplateExpression */) { + if (template.kind === 221 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -134468,7 +137479,7 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(checker); - var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay), [ts.punctuationPart(29 /* LessThanToken */)]); + var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* LessThanToken */)], false); return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; @@ -134476,8 +137487,8 @@ var ts; var infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile); return ts.map(infos, function (_a) { var isVariadic = _a.isVariadic, parameters = _a.parameters, prefix = _a.prefix, suffix = _a.suffix; - var prefixDisplayParts = __spreadArray(__spreadArray([], callTargetDisplayParts), prefix); - var suffixDisplayParts = __spreadArray(__spreadArray([], suffix), returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); + var prefixDisplayParts = __spreadArray(__spreadArray([], callTargetDisplayParts, true), prefix, true); + var suffixDisplayParts = __spreadArray(__spreadArray([], suffix, true), returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker), true); var documentation = candidateSignature.getDocumentationComment(checker); var tags = candidateSignature.getJsDocTags(); return { isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; @@ -134502,15 +137513,14 @@ var ts; var parameters = (typeParameters || ts.emptyArray).map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; return checker.getExpandedParameters(candidateSignature).map(function (paramList) { - var params = ts.factory.createNodeArray(__spreadArray(__spreadArray([], thisParameter), ts.map(paramList, function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + var params = ts.factory.createNodeArray(__spreadArray(__spreadArray([], thisParameter, true), ts.map(paramList, function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }), true)); var parameterParts = ts.mapToDisplayParts(function (writer) { printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts, true) }; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { - var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); var printer = ts.createPrinter({ removeComments: true }); var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { @@ -134519,14 +137529,15 @@ var ts; } }); var lists = checker.getExpandedParameters(candidateSignature); - return lists.map(function (parameterList) { - return { - isVariadic: isVariadic && (lists.length === 1 || !!(parameterList[parameterList.length - 1].checkFlags & 32768 /* RestParameter */)), - parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts), [ts.punctuationPart(20 /* OpenParenToken */)]), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] - }; - }); + var isVariadic = !checker.hasEffectiveRestParameter(candidateSignature) ? function (_) { return false; } + : lists.length === 1 ? function (_) { return true; } + : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* RestParameter */); }; + return lists.map(function (parameterList) { return ({ + isVariadic: isVariadic(parameterList), + parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), + prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* OpenParenToken */)], false), + suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -134548,6 +137559,279 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var InlayHints; + (function (InlayHints) { + var maxHintsLength = 30; + var leadingParameterNameCommentRegexFactory = function (name) { + return new RegExp("^\\s?/\\*\\*?\\s?" + name + "\\s?\\*\\/\\s?$"); + }; + function shouldShowParameterNameHints(preferences) { + return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all"; + } + function shouldShowLiteralParameterNameHintsOnly(preferences) { + return preferences.includeInlayParameterNameHints === "literals"; + } + function provideInlayHints(context) { + var file = context.file, program = context.program, span = context.span, cancellationToken = context.cancellationToken, preferences = context.preferences; + var sourceFileText = file.text; + var compilerOptions = program.getCompilerOptions(); + var checker = program.getTypeChecker(); + var result = []; + visitor(file); + return result; + function visitor(node) { + if (!node || node.getFullWidth() === 0) { + return; + } + switch (node.kind) { + case 259 /* ModuleDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 254 /* FunctionDeclaration */: + case 224 /* ClassExpression */: + case 211 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 212 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) { + return; + } + if (ts.isTypeNode(node)) { + return; + } + if (preferences.includeInlayVariableTypeHints && ts.isVariableDeclaration(node)) { + visitVariableLikeDeclaration(node); + } + else if (preferences.includeInlayPropertyDeclarationTypeHints && ts.isPropertyDeclaration(node)) { + visitVariableLikeDeclaration(node); + } + else if (preferences.includeInlayEnumMemberValueHints && ts.isEnumMember(node)) { + visitEnumMember(node); + } + else if (shouldShowParameterNameHints(preferences) && (ts.isCallExpression(node) || ts.isNewExpression(node))) { + visitCallOrNewExpression(node); + } + else { + if (preferences.includeInlayFunctionParameterTypeHints && ts.isFunctionLikeDeclaration(node) && ts.hasContextSensitiveParameters(node)) { + visitFunctionLikeForParameterType(node); + } + if (preferences.includeInlayFunctionLikeReturnTypeHints && isSignatureSupportingReturnAnnotation(node)) { + visitFunctionDeclarationLikeForReturnType(node); + } + } + return ts.forEachChild(node, visitor); + } + function isSignatureSupportingReturnAnnotation(node) { + return ts.isArrowFunction(node) || ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node) || ts.isGetAccessorDeclaration(node); + } + function addParameterHints(text, position, isFirstVariadicArgument) { + result.push({ + text: "" + (isFirstVariadicArgument ? "..." : "") + truncation(text, maxHintsLength) + ":", + position: position, + kind: "Parameter" /* Parameter */, + whitespaceAfter: true, + }); + } + function addTypeHints(text, position) { + result.push({ + text: ": " + truncation(text, maxHintsLength), + position: position, + kind: "Type" /* Type */, + whitespaceBefore: true, + }); + } + function addEnumMemberValueHints(text, position) { + result.push({ + text: "= " + truncation(text, maxHintsLength), + position: position, + kind: "Enum" /* Enum */, + whitespaceBefore: true, + }); + } + function visitEnumMember(member) { + if (member.initializer) { + return; + } + var enumValue = checker.getConstantValue(member); + if (enumValue !== undefined) { + addEnumMemberValueHints(enumValue.toString(), member.end); + } + } + function isModuleReferenceType(type) { + return type.symbol && (type.symbol.flags & 1536 /* Module */); + } + function visitVariableLikeDeclaration(decl) { + if (!decl.initializer || ts.isBindingPattern(decl.name)) { + return; + } + var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(decl); + if (effectiveTypeAnnotation) { + return; + } + var declarationType = checker.getTypeAtLocation(decl); + if (isModuleReferenceType(declarationType)) { + return; + } + var typeDisplayString = printTypeInSingleLine(declarationType); + if (typeDisplayString) { + addTypeHints(typeDisplayString, decl.name.end); + } + } + function visitCallOrNewExpression(expr) { + var args = expr.arguments; + if (!args || !args.length) { + return; + } + var candidates = []; + var signature = checker.getResolvedSignatureForSignatureHelp(expr, candidates); + if (!signature || !candidates.length) { + return; + } + for (var i = 0; i < args.length; ++i) { + var originalArg = args[i]; + var arg = ts.skipParentheses(originalArg); + if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) { + continue; + } + var identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, i); + if (identifierNameInfo) { + var parameterName = identifierNameInfo[0], isFirstVariadicArgument = identifierNameInfo[1]; + var isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName); + if (!isParameterNameNotSameAsArgument && !isFirstVariadicArgument) { + continue; + } + var name = ts.unescapeLeadingUnderscores(parameterName); + if (leadingCommentsContainsParameterName(arg, name)) { + continue; + } + addParameterHints(name, originalArg.getStart(), isFirstVariadicArgument); + } + } + } + function identifierOrAccessExpressionPostfixMatchesParameterName(expr, parameterName) { + if (ts.isIdentifier(expr)) { + return expr.text === parameterName; + } + if (ts.isPropertyAccessExpression(expr)) { + return expr.name.text === parameterName; + } + return false; + } + function leadingCommentsContainsParameterName(node, name) { + if (!ts.isIdentifierText(name, compilerOptions.target, ts.getLanguageVariant(file.scriptKind))) { + return false; + } + var ranges = ts.getLeadingCommentRanges(sourceFileText, node.pos); + if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) { + return false; + } + var regex = leadingParameterNameCommentRegexFactory(name); + return ts.some(ranges, function (range) { return regex.test(sourceFileText.substring(range.pos, range.end)); }); + } + function isHintableLiteral(node) { + switch (node.kind) { + case 217 /* PrefixUnaryExpression */: { + var operand = node.operand; + return ts.isLiteralExpression(operand) || ts.isIdentifier(operand) && ts.isInfinityOrNaNString(operand.escapedText); + } + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + return true; + case 79 /* Identifier */: { + var name = node.escapedText; + return isUndefined(name) || ts.isInfinityOrNaNString(name); + } + } + return ts.isLiteralExpression(node); + } + function visitFunctionDeclarationLikeForReturnType(decl) { + if (ts.isArrowFunction(decl)) { + if (!ts.findChildOfKind(decl, 20 /* OpenParenToken */, file)) { + return; + } + } + var effectiveTypeAnnotation = ts.getEffectiveReturnTypeNode(decl); + if (effectiveTypeAnnotation || !decl.body) { + return; + } + var signature = checker.getSignatureFromDeclaration(decl); + if (!signature) { + return; + } + var returnType = checker.getReturnTypeOfSignature(signature); + if (isModuleReferenceType(returnType)) { + return; + } + var typeDisplayString = printTypeInSingleLine(returnType); + if (!typeDisplayString) { + return; + } + addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl)); + } + function getTypeAnnotationPosition(decl) { + var closeParenToken = ts.findChildOfKind(decl, 21 /* CloseParenToken */, file); + if (closeParenToken) { + return closeParenToken.end; + } + return decl.parameters.end; + } + function visitFunctionLikeForParameterType(node) { + var signature = checker.getSignatureFromDeclaration(node); + if (!signature) { + return; + } + for (var i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) { + var param = node.parameters[i]; + var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(param); + if (effectiveTypeAnnotation) { + continue; + } + var typeDisplayString = getParameterDeclarationTypeDisplayString(signature.parameters[i]); + if (!typeDisplayString) { + continue; + } + addTypeHints(typeDisplayString, param.end); + } + } + function getParameterDeclarationTypeDisplayString(symbol) { + var valueDeclaration = symbol.valueDeclaration; + if (!valueDeclaration || !ts.isParameter(valueDeclaration)) { + return undefined; + } + var signatureParamType = checker.getTypeOfSymbolAtLocation(symbol, valueDeclaration); + if (isModuleReferenceType(signatureParamType)) { + return undefined; + } + return printTypeInSingleLine(signatureParamType); + } + function truncation(text, maxLength) { + if (text.length > maxLength) { + return text.substr(0, maxLength - "...".length) + "..."; + } + return text; + } + function printTypeInSingleLine(type) { + var flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var options = { removeComments: true }; + var printer = ts.createPrinter(options); + return ts.usingSingleLineStringWriter(function (writer) { + var typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer); + ts.Debug.assertIsDefined(typeNode, "should always get typenode"); + printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ file, writer); + }); + } + function isUndefined(name) { + return name === "undefined"; + } + } + InlayHints.provideInlayHints = provideInlayHints; + })(InlayHints = ts.InlayHints || (ts.InlayHints = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; function getSourceMapper(host) { @@ -134763,11 +138047,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 234 /* ExpressionStatement */: { + case 236 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -134784,12 +138068,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 264 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 266 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -134851,22 +138135,27 @@ var ts; if (node.arguments.length < 2) return true; return ts.some(node.arguments, function (arg) { - return arg.kind === 103 /* NullKeyword */ || + return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + var functionFlags = ts.getFunctionFlags(arg); + if (functionFlags & 1 /* Generator */) { + return false; + } + // falls through + case 212 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return true; - case 78 /* Identifier */: - case 202 /* PropertyAccessExpression */: { + case 79 /* Identifier */: + case 204 /* PropertyAccessExpression */: { var symbol = checker.getSymbolAtLocation(arg); if (!symbol) { return false; @@ -134883,24 +138172,24 @@ var ts; } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 209 /* FunctionExpression */) { + if (node.kind === 211 /* FunctionExpression */) { if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) { return true; } var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false); return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size))); } - if (node.kind === 252 /* FunctionDeclaration */) { + if (node.kind === 254 /* FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } function canBeConvertedToAsync(node) { switch (node.kind) { - case 252 /* FunctionDeclaration */: - case 166 /* MethodDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 254 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: return true; default: return false; @@ -134922,7 +138211,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 222 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 224 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -134957,7 +138246,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 107 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -135006,11 +138295,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 276 /* JsxOpeningElement */: - case 274 /* JsxElement */: - case 275 /* JsxSelfClosingElement */: - return location.kind === 78 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 281 /* JsxAttribute */: + case 278 /* JsxOpeningElement */: + case 276 /* JsxElement */: + case 277 /* JsxSelfClosingElement */: + return location.kind === 79 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 283 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -135018,14 +138307,11 @@ var ts; } return "" /* unknown */; } - function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); - } function getNormalizedSymbolModifiers(symbol) { if (symbol.declarations && symbol.declarations.length) { var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated - var excludeFlags = ts.length(declarations) && isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !isDeprecatedDeclaration(d); }) + var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) ? 8192 /* Deprecated */ : 0 /* None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); @@ -135064,14 +138350,14 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 107 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 107 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(107 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { @@ -135081,7 +138367,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (location.parent && location.parent.kind === 202 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 204 /* 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)) { @@ -135101,7 +138387,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 205 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 105 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 207 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -135120,10 +138406,10 @@ var ts; displayParts.push(ts.spacePart()); if (useConstructSignatures) { if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(125 /* AbstractKeyword */)); + displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -135148,10 +138434,10 @@ var ts; } if (useConstructSignatures) { if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(125 /* AbstractKeyword */)); + displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -135165,29 +138451,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 132 /* ConstructorKeyword */ && location.parent.kind === 167 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 133 /* ConstructorKeyword */ && location.parent.kind === 169 /* Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 132 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 133 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 167 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 169 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 167 /* Constructor */) { + if (functionDeclaration_1.kind === 169 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 170 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 172 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } if (signature) { @@ -135200,7 +138486,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 222 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 224 /* 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 @@ -135208,7 +138494,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(83 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -135216,37 +138502,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(117 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(84 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(91 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 257 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 78 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 140 /* NamespaceKeyword */ : 139 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 259 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 141 /* NamespaceKeyword */ : 140 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -135265,7 +138551,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 160 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 161 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -135273,21 +138559,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 171 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + if (declaration.kind === 173 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 170 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 172 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 255 /* TypeAliasDeclaration */) { + else if (declaration.kind === 257 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -135299,11 +138585,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; - if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 292 /* EnumMember */) { + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 294 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -135335,33 +138621,33 @@ var ts; } if (symbol.declarations) { switch (symbol.declarations[0].kind) { - case 260 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); + case 262 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(140 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(141 /* NamespaceKeyword */)); break; - case 267 /* ExportAssignment */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); + case 269 /* ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 87 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); break; - case 271 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); + case 273 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(99 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 261 /* ImportEqualsDeclaration */) { + if (declaration.kind === 263 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(143 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(144 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -135370,7 +138656,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -135384,7 +138670,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(107 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -135442,10 +138728,10 @@ var ts; // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 298 /* SourceFile */; })) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 300 /* SourceFile */; })) { for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (!declaration.parent || declaration.parent.kind !== 217 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 219 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -135490,7 +138776,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(100 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -135563,16 +138849,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 209 /* FunctionExpression */) { + if (declaration.kind === 211 /* FunctionExpression */) { return true; } - if (declaration.kind !== 250 /* VariableDeclaration */ && declaration.kind !== 252 /* FunctionDeclaration */) { + if (declaration.kind !== 252 /* VariableDeclaration */ && declaration.kind !== 254 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 298 /* SourceFile */ || parent.kind === 258 /* ModuleBlock */) { + if (parent.kind === 300 /* SourceFile */ || parent.kind === 260 /* ModuleBlock */) { return false; } } @@ -135674,9 +138960,8 @@ var ts; /*@internal*/ function fixupCompilerOptions(options, diagnostics) { // Lazily create this value to fix module loading errors. - commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); - }); + commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || + ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); var _loop_9 = function (opt) { if (!ts.hasProperty(options, opt.name)) { @@ -135862,8 +139147,8 @@ var ts; function shouldRescanGreaterThanToken(node) { switch (node.kind) { case 33 /* GreaterThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 49 /* GreaterThanGreaterThanGreaterThanToken */: case 48 /* GreaterThanGreaterThanToken */: return true; @@ -135873,12 +139158,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 281 /* JsxAttribute */: - case 276 /* JsxOpeningElement */: - case 277 /* JsxClosingElement */: - case 275 /* JsxSelfClosingElement */: + case 283 /* JsxAttribute */: + case 278 /* JsxOpeningElement */: + case 279 /* JsxClosingElement */: + case 277 /* JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 78 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; } } return false; @@ -135897,7 +139182,7 @@ var ts; return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); @@ -136070,7 +139355,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 157 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 158 /* LastToken */; token++) { if (token !== 1 /* EndOfFileToken */) { allTokens.push(token); } @@ -136083,29 +139368,29 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [3 /* MultiLineCommentTrivia */])); - var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [1 /* EndOfFileToken */])); - var keywords = tokenRangeFromRange(80 /* FirstKeyword */, 157 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 77 /* LastBinaryOperator */); - var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 157 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* MultiLineCommentTrivia */], false)); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* EndOfFileToken */], false)); + var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 158 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); + var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 158 /* OfKeyword */, 127 /* AsKeyword */, 138 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 78 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; - var unaryPostincrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* NewKeyword */]; - var unaryPredecrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; - var unaryPostdecrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* NewKeyword */]; + var unaryPreincrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; + var unaryPostincrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; + var unaryPredecrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; + var unaryPostdecrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArray([78 /* Identifier */], ts.typeKeywords); + var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords, true); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([78 /* Identifier */, 3 /* MultiLineCommentTrivia */, 83 /* ClassKeyword */, 92 /* ExportKeyword */, 99 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 89 /* DoKeyword */, 110 /* TryKeyword */, 95 /* FinallyKeyword */, 90 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone @@ -136120,7 +139405,7 @@ var ts; rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenImportParenInImportType", 99 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. @@ -136147,79 +139432,79 @@ var ts; rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 90 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 114 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 91 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 115 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 97 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 78 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 97 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 79 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 98 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), // Insert new line after { and before } in multi-line contexts. rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [134 /* GetKeyword */, 146 /* SetKeyword */], 78 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 124 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [124 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 104 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [112 /* VarKeyword */, 108 /* ThrowKeyword */, 102 /* NewKeyword */, 88 /* DeleteKeyword */, 104 /* ReturnKeyword */, 111 /* TypeOfKeyword */, 130 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [118 /* LetKeyword */, 84 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("SpaceAfterGetSetInMember", [135 /* GetKeyword */, 147 /* SetKeyword */], 79 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 105 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterCertainKeywords", [113 /* VarKeyword */, 109 /* ThrowKeyword */, 103 /* NewKeyword */, 89 /* DeleteKeyword */, 105 /* ReturnKeyword */, 112 /* TypeOfKeyword */, 131 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [119 /* LetKeyword */, 85 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterVoidOperator", 113 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 129 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 129 /* AsyncKeyword */, [97 /* FunctionKeyword */, 78 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 130 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 130 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [78 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 78 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeJsxAttribute", anyToken, 79 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [139 /* ModuleKeyword */, 143 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [140 /* ModuleKeyword */, 144 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 125 /* AbstractKeyword */, - 83 /* ClassKeyword */, - 133 /* DeclareKeyword */, - 87 /* DefaultKeyword */, - 91 /* EnumKeyword */, - 92 /* ExportKeyword */, - 93 /* ExtendsKeyword */, - 134 /* GetKeyword */, - 116 /* ImplementsKeyword */, - 99 /* ImportKeyword */, - 117 /* InterfaceKeyword */, - 139 /* ModuleKeyword */, - 140 /* NamespaceKeyword */, - 120 /* PrivateKeyword */, - 122 /* PublicKeyword */, - 121 /* ProtectedKeyword */, - 142 /* ReadonlyKeyword */, - 146 /* SetKeyword */, - 123 /* StaticKeyword */, - 149 /* TypeKeyword */, - 153 /* FromKeyword */, - 138 /* KeyOfKeyword */, - 135 /* InferKeyword */, + 126 /* AbstractKeyword */, + 84 /* ClassKeyword */, + 134 /* DeclareKeyword */, + 88 /* DefaultKeyword */, + 92 /* EnumKeyword */, + 93 /* ExportKeyword */, + 94 /* ExtendsKeyword */, + 135 /* GetKeyword */, + 117 /* ImplementsKeyword */, + 100 /* ImportKeyword */, + 118 /* InterfaceKeyword */, + 140 /* ModuleKeyword */, + 141 /* NamespaceKeyword */, + 121 /* PrivateKeyword */, + 123 /* PublicKeyword */, + 122 /* ProtectedKeyword */, + 143 /* ReadonlyKeyword */, + 147 /* SetKeyword */, + 124 /* StaticKeyword */, + 150 /* TypeKeyword */, + 154 /* FromKeyword */, + 139 /* KeyOfKeyword */, + 136 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [93 /* ExtendsKeyword */, 116 /* ImplementsKeyword */, 153 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 154 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), // Lambda expressions rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 78 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), @@ -136230,38 +139515,38 @@ var ts; rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 78 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 125 /* AbstractKeyword */, - 78 /* Identifier */, - 92 /* ExportKeyword */, - 87 /* DefaultKeyword */, - 83 /* ClassKeyword */, - 123 /* StaticKeyword */, - 122 /* PublicKeyword */, - 120 /* PrivateKeyword */, - 121 /* ProtectedKeyword */, - 134 /* GetKeyword */, - 146 /* SetKeyword */, + 126 /* AbstractKeyword */, + 79 /* Identifier */, + 93 /* ExportKeyword */, + 88 /* DefaultKeyword */, + 84 /* ClassKeyword */, + 124 /* StaticKeyword */, + 123 /* PublicKeyword */, + 121 /* PrivateKeyword */, + 122 /* ProtectedKeyword */, + 135 /* GetKeyword */, + 147 /* SetKeyword */, 22 /* OpenBracketToken */, 41 /* AsteriskToken */, ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 102 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 132 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 132 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 133 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 133 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */), rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [97 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [97 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), // Insert space after keywords in control flow statements rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), @@ -136330,18 +139615,18 @@ var ts; rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(129 /* AsyncKeyword */, 81 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(130 /* AsyncKeyword */, 82 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 96 /* ForKeyword */, 130 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 131 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // 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] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 89 /* DoKeyword */, 90 /* ElseKeyword */, 81 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [110 /* TryKeyword */, 82 /* CatchKeyword */, 95 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; - return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules), userConfigurableRules), lowPriorityCommonRules); + return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules, true), userConfigurableRules, true), lowPriorityCommonRules, true); } formatting.getAllRules = getAllRules; /** @@ -136398,51 +139683,54 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 238 /* ForStatement */; + return context.contextNode.kind === 240 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 218 /* ConditionalExpression */: - case 185 /* ConditionalType */: - case 225 /* AsExpression */: - case 271 /* ExportSpecifier */: - case 266 /* ImportSpecifier */: - case 173 /* TypePredicate */: - case 183 /* UnionType */: - case 184 /* IntersectionType */: + case 220 /* ConditionalExpression */: + case 187 /* ConditionalType */: + case 227 /* AsExpression */: + case 273 /* ExportSpecifier */: + case 268 /* ImportSpecifier */: + case 175 /* TypePredicate */: + case 185 /* UnionType */: + case 186 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 199 /* BindingElement */: + case 201 /* BindingElement */: // equals in type X = ... // falls through - case 255 /* TypeAliasDeclaration */: + case 257 /* TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: + // equal in export = 1 + // falls through + case 269 /* ExportAssignment */: // equal in let a = 0 // falls through - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: // equal in p = 0 // falls through - case 161 /* Parameter */: - case 292 /* EnumMember */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; + case 162 /* Parameter */: + case 294 /* EnumMember */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 160 /* TypeParameter */: - return context.currentTokenSpan.kind === 100 /* InKeyword */ || context.nextTokenSpan.kind === 100 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; + case 161 /* TypeParameter */: + return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 240 /* ForOfStatement */: - return context.currentTokenSpan.kind === 157 /* OfKeyword */ || context.nextTokenSpan.kind === 157 /* OfKeyword */; + case 242 /* ForOfStatement */: + return context.currentTokenSpan.kind === 158 /* OfKeyword */ || context.nextTokenSpan.kind === 158 /* OfKeyword */; } return false; } @@ -136454,22 +139742,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 164 /* PropertyDeclaration */ || - contextKind === 163 /* PropertySignature */ || - contextKind === 161 /* Parameter */ || - contextKind === 250 /* VariableDeclaration */ || + return contextKind === 165 /* PropertyDeclaration */ || + contextKind === 164 /* PropertySignature */ || + contextKind === 162 /* Parameter */ || + contextKind === 252 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 218 /* ConditionalExpression */ || - context.contextNode.kind === 185 /* ConditionalType */; + return context.contextNode.kind === 220 /* ConditionalExpression */ || + context.contextNode.kind === 187 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 197 /* ObjectBindingPattern */ || - context.contextNode.kind === 191 /* MappedType */ || + return context.contextNode.kind === 199 /* ObjectBindingPattern */ || + context.contextNode.kind === 193 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -136495,34 +139783,34 @@ var ts; return true; } switch (node.kind) { - case 231 /* Block */: - case 259 /* CaseBlock */: - case 201 /* ObjectLiteralExpression */: - case 258 /* ModuleBlock */: + case 233 /* Block */: + case 261 /* CaseBlock */: + case 203 /* ObjectLiteralExpression */: + case 260 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 252 /* FunctionDeclaration */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: + case 254 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 170 /* CallSignature */: - case 209 /* FunctionExpression */: - case 167 /* Constructor */: - case 210 /* ArrowFunction */: + case 172 /* CallSignature */: + case 211 /* FunctionExpression */: + case 169 /* Constructor */: + case 212 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 254 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 256 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -136531,40 +139819,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 252 /* FunctionDeclaration */ || context.contextNode.kind === 209 /* FunctionExpression */; + return context.contextNode.kind === 254 /* FunctionDeclaration */ || context.contextNode.kind === 211 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: - case 256 /* EnumDeclaration */: - case 178 /* TypeLiteral */: - case 257 /* ModuleDeclaration */: - case 268 /* ExportDeclaration */: - case 269 /* NamedExports */: - case 262 /* ImportDeclaration */: - case 265 /* NamedImports */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: + case 258 /* EnumDeclaration */: + case 180 /* TypeLiteral */: + case 259 /* ModuleDeclaration */: + case 270 /* ExportDeclaration */: + case 271 /* NamedExports */: + case 264 /* ImportDeclaration */: + case 267 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 253 /* ClassDeclaration */: - case 257 /* ModuleDeclaration */: - case 256 /* EnumDeclaration */: - case 288 /* CatchClause */: - case 258 /* ModuleBlock */: - case 245 /* SwitchStatement */: + case 255 /* ClassDeclaration */: + case 259 /* ModuleDeclaration */: + case 258 /* EnumDeclaration */: + case 290 /* CatchClause */: + case 260 /* ModuleBlock */: + case 247 /* SwitchStatement */: return true; - case 231 /* Block */: { + case 233 /* Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 210 /* ArrowFunction */ && blockParent.kind !== 209 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 212 /* ArrowFunction */ && blockParent.kind !== 211 /* FunctionExpression */) { return true; } } @@ -136573,32 +139861,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 235 /* IfStatement */: - case 245 /* SwitchStatement */: - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 237 /* WhileStatement */: - case 248 /* TryStatement */: - case 236 /* DoStatement */: - case 244 /* WithStatement */: + case 237 /* IfStatement */: + case 247 /* SwitchStatement */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 239 /* WhileStatement */: + case 250 /* TryStatement */: + case 238 /* DoStatement */: + case 246 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 288 /* CatchClause */: + case 290 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 201 /* ObjectLiteralExpression */; + return context.contextNode.kind === 203 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 204 /* CallExpression */; + return context.contextNode.kind === 206 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 205 /* NewExpression */; + return context.contextNode.kind === 207 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -136613,10 +139901,10 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 210 /* ArrowFunction */; + return context.contextNode.kind === 212 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 196 /* ImportType */; + return context.contextNode.kind === 198 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; @@ -136625,19 +139913,19 @@ var ts; return context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 274 /* JsxElement */ && context.contextNode.kind !== 278 /* JsxFragment */; + return context.contextNode.kind !== 276 /* JsxElement */ && context.contextNode.kind !== 280 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 284 /* JsxExpression */ || context.contextNode.kind === 283 /* JsxSpreadAttribute */; + return context.contextNode.kind === 286 /* JsxExpression */ || context.contextNode.kind === 285 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 281 /* JsxAttribute */; + return context.nextTokenParent.kind === 283 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 281 /* JsxAttribute */; + return context.contextNode.kind === 283 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 275 /* JsxSelfClosingElement */; + return context.contextNode.kind === 277 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -136652,45 +139940,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 162 /* Decorator */; + return node.kind === 163 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 251 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 253 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 257 /* ModuleDeclaration */; + return context.contextNode.kind === 259 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 178 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 180 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 171 /* ConstructSignature */; + return context.contextNode.kind === 173 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 174 /* TypeReference */: - case 207 /* TypeAssertionExpression */: - case 255 /* TypeAliasDeclaration */: - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 204 /* CallExpression */: - case 205 /* NewExpression */: - case 224 /* ExpressionWithTypeArguments */: + case 176 /* TypeReference */: + case 209 /* TypeAssertionExpression */: + case 257 /* TypeAliasDeclaration */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: + case 226 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -136701,28 +139989,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 207 /* TypeAssertionExpression */; + return context.contextNode.kind === 209 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 113 /* VoidKeyword */ && context.currentTokenParent.kind === 213 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 215 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 220 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 222 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 226 /* NonNullExpression */; + return context.contextNode.kind === 228 /* NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 235 /* IfStatement */: - case 238 /* ForStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 236 /* DoStatement */: - case 237 /* WhileStatement */: + case 237 /* IfStatement */: + case 240 /* ForStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 238 /* DoStatement */: + case 239 /* WhileStatement */: return true; default: return false; @@ -136747,12 +140035,12 @@ var ts; return nextTokenKind === 19 /* CloseBraceToken */ || nextTokenKind === 1 /* EndOfFileToken */; } - if (nextTokenKind === 230 /* SemicolonClassElement */ || + if (nextTokenKind === 232 /* SemicolonClassElement */ || nextTokenKind === 26 /* SemicolonToken */) { return false; } - if (context.contextNode.kind === 254 /* InterfaceDeclaration */ || - context.contextNode.kind === 255 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 256 /* InterfaceDeclaration */ || + context.contextNode.kind === 257 /* TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -136766,9 +140054,9 @@ var ts; if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 238 /* ForStatement */ - && context.currentTokenParent.kind !== 232 /* EmptyStatement */ - && context.currentTokenParent.kind !== 230 /* SemicolonClassElement */ + return context.currentTokenParent.kind !== 240 /* ForStatement */ + && context.currentTokenParent.kind !== 234 /* EmptyStatement */ + && context.currentTokenParent.kind !== 232 /* SemicolonClassElement */ && nextTokenKind !== 22 /* OpenBracketToken */ && nextTokenKind !== 20 /* OpenParenToken */ && nextTokenKind !== 39 /* PlusToken */ @@ -136776,7 +140064,7 @@ var ts; && nextTokenKind !== 43 /* SlashToken */ && nextTokenKind !== 13 /* RegularExpressionLiteral */ && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 219 /* TemplateExpression */ + && nextTokenKind !== 221 /* TemplateExpression */ && nextTokenKind !== 15 /* TemplateHead */ && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ && nextTokenKind !== 24 /* DotToken */; @@ -136867,12 +140155,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 157 /* LastKeyword */ && column <= 157 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 158 /* LastKeyword */ && column <= 158 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 157 /* LastToken */ + 1; + var mapRowLength = 158 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -137060,17 +140348,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 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 258 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 298 /* SourceFile */: - case 231 /* Block */: - case 258 /* ModuleBlock */: + return !!body && body.kind === 260 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 300 /* SourceFile */: + case 233 /* Block */: + case 260 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 288 /* CatchClause */: + case 290 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -137299,19 +140587,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 253 /* ClassDeclaration */: return 83 /* ClassKeyword */; - case 254 /* InterfaceDeclaration */: return 117 /* InterfaceKeyword */; - case 252 /* FunctionDeclaration */: return 97 /* FunctionKeyword */; - case 256 /* EnumDeclaration */: return 256 /* EnumDeclaration */; - case 168 /* GetAccessor */: return 134 /* GetKeyword */; - case 169 /* SetAccessor */: return 146 /* SetKeyword */; - case 166 /* MethodDeclaration */: + case 255 /* ClassDeclaration */: return 84 /* ClassKeyword */; + case 256 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; + case 254 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; + case 258 /* EnumDeclaration */: return 258 /* EnumDeclaration */; + case 170 /* GetAccessor */: return 135 /* GetKeyword */; + case 171 /* SetAccessor */: return 147 /* SetKeyword */; + case 167 /* MethodDeclaration */: if (node.asteriskToken) { return 41 /* AsteriskToken */; } // falls through - case 164 /* PropertyDeclaration */: - case 161 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 162 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -137361,23 +140649,23 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 90 /* ElseKeyword */: - case 114 /* WhileKeyword */: + case 91 /* ElseKeyword */: + case 115 /* WhileKeyword */: case 59 /* AtToken */: return false; case 43 /* SlashToken */: case 31 /* GreaterThanToken */: switch (container.kind) { - case 276 /* JsxOpeningElement */: - case 277 /* JsxClosingElement */: - case 275 /* JsxSelfClosingElement */: - case 224 /* ExpressionWithTypeArguments */: + case 278 /* JsxOpeningElement */: + case 279 /* JsxClosingElement */: + case 277 /* JsxSelfClosingElement */: + case 226 /* ExpressionWithTypeArguments */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 191 /* MappedType */) { + if (container.kind !== 193 /* MappedType */) { return false; } break; @@ -137480,11 +140768,11 @@ var ts; return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 162 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 163 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 200 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 202 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -137917,12 +141205,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 167 /* Constructor */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 210 /* ArrowFunction */: + case 169 /* Constructor */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 212 /* ArrowFunction */: if (node.typeParameters === list) { return 29 /* LessThanToken */; } @@ -137930,8 +141218,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 204 /* CallExpression */: - case 205 /* NewExpression */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } @@ -137939,12 +141227,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 174 /* TypeReference */: + case 176 /* TypeReference */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } break; - case 178 /* TypeLiteral */: + case 180 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -138062,7 +141350,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 217 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 219 /* 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 */) { @@ -138235,7 +141523,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.isStatementButNotDeclaration(current)) && - (parent.kind === 298 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 300 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -138283,8 +141571,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 235 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 90 /* ElseKeyword */, sourceFile); + if (parent.kind === 237 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -138364,40 +141652,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 174 /* TypeReference */: + case 176 /* TypeReference */: return getList(node.typeArguments); - case 201 /* ObjectLiteralExpression */: + case 203 /* ObjectLiteralExpression */: return getList(node.properties); - case 200 /* ArrayLiteralExpression */: + case 202 /* ArrayLiteralExpression */: return getList(node.elements); - case 178 /* TypeLiteral */: + case 180 /* TypeLiteral */: return getList(node.members); - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 170 /* CallSignature */: - case 167 /* Constructor */: - case 176 /* ConstructorType */: - case 171 /* ConstructSignature */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 172 /* CallSignature */: + case 169 /* Constructor */: + case 178 /* ConstructorType */: + case 173 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 334 /* JSDocTemplateTag */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 339 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 205 /* NewExpression */: - case 204 /* CallExpression */: + case 207 /* NewExpression */: + case 206 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 251 /* VariableDeclarationList */: + case 253 /* VariableDeclarationList */: return getList(node.declarations); - case 265 /* NamedImports */: - case 269 /* NamedExports */: + case 267 /* NamedImports */: + case 271 /* NamedExports */: return getList(node.elements); - case 197 /* ObjectBindingPattern */: - case 198 /* ArrayBindingPattern */: + case 199 /* ObjectBindingPattern */: + case 200 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -138420,7 +141708,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 251 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 253 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -138493,91 +141781,91 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 234 /* ExpressionStatement */: - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: - case 256 /* EnumDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 200 /* ArrayLiteralExpression */: - case 231 /* Block */: - case 258 /* ModuleBlock */: - case 201 /* ObjectLiteralExpression */: - case 178 /* TypeLiteral */: - case 191 /* MappedType */: - case 180 /* TupleType */: - case 259 /* CaseBlock */: - case 286 /* DefaultClause */: - case 285 /* CaseClause */: - case 208 /* ParenthesizedExpression */: - case 202 /* PropertyAccessExpression */: - case 204 /* CallExpression */: - case 205 /* NewExpression */: - case 233 /* VariableStatement */: - case 267 /* ExportAssignment */: - case 243 /* ReturnStatement */: - case 218 /* ConditionalExpression */: - case 198 /* ArrayBindingPattern */: - case 197 /* ObjectBindingPattern */: - case 276 /* JsxOpeningElement */: - case 279 /* JsxOpeningFragment */: - case 275 /* JsxSelfClosingElement */: - case 284 /* JsxExpression */: - case 165 /* MethodSignature */: - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 161 /* Parameter */: - case 175 /* FunctionType */: - case 176 /* ConstructorType */: - case 187 /* ParenthesizedType */: - case 206 /* TaggedTemplateExpression */: - case 214 /* AwaitExpression */: - case 269 /* NamedExports */: - case 265 /* NamedImports */: - case 271 /* ExportSpecifier */: - case 266 /* ImportSpecifier */: - case 164 /* PropertyDeclaration */: + case 236 /* ExpressionStatement */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: + case 258 /* EnumDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 202 /* ArrayLiteralExpression */: + case 233 /* Block */: + case 260 /* ModuleBlock */: + case 203 /* ObjectLiteralExpression */: + case 180 /* TypeLiteral */: + case 193 /* MappedType */: + case 182 /* TupleType */: + case 261 /* CaseBlock */: + case 288 /* DefaultClause */: + case 287 /* CaseClause */: + case 210 /* ParenthesizedExpression */: + case 204 /* PropertyAccessExpression */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: + case 235 /* VariableStatement */: + case 269 /* ExportAssignment */: + case 245 /* ReturnStatement */: + case 220 /* ConditionalExpression */: + case 200 /* ArrayBindingPattern */: + case 199 /* ObjectBindingPattern */: + case 278 /* JsxOpeningElement */: + case 281 /* JsxOpeningFragment */: + case 277 /* JsxSelfClosingElement */: + case 286 /* JsxExpression */: + case 166 /* MethodSignature */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 162 /* Parameter */: + case 177 /* FunctionType */: + case 178 /* ConstructorType */: + case 189 /* ParenthesizedType */: + case 208 /* TaggedTemplateExpression */: + case 216 /* AwaitExpression */: + case 271 /* NamedExports */: + case 267 /* NamedImports */: + case 273 /* ExportSpecifier */: + case 268 /* ImportSpecifier */: + case 165 /* PropertyDeclaration */: return true; - case 250 /* VariableDeclaration */: - case 289 /* PropertyAssignment */: - case 217 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 201 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 252 /* VariableDeclaration */: + case 291 /* PropertyAssignment */: + case 219 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 203 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind !== 217 /* BinaryExpression */) { + if (parent.kind !== 219 /* BinaryExpression */) { return true; } break; - case 236 /* DoStatement */: - case 237 /* WhileStatement */: - case 239 /* ForInStatement */: - case 240 /* ForOfStatement */: - case 238 /* ForStatement */: - case 235 /* IfStatement */: - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 166 /* MethodDeclaration */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - return childKind !== 231 /* Block */; - case 210 /* ArrowFunction */: - if (sourceFile && childKind === 208 /* ParenthesizedExpression */) { + case 238 /* DoStatement */: + case 239 /* WhileStatement */: + case 241 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 240 /* ForStatement */: + case 237 /* IfStatement */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + return childKind !== 233 /* Block */; + case 212 /* ArrowFunction */: + if (sourceFile && childKind === 210 /* ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 231 /* Block */; - case 268 /* ExportDeclaration */: - return childKind !== 269 /* NamedExports */; - case 262 /* ImportDeclaration */: - return childKind !== 263 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 265 /* NamedImports */); - case 274 /* JsxElement */: - return childKind !== 277 /* JsxClosingElement */; - case 278 /* JsxFragment */: - return childKind !== 280 /* JsxClosingFragment */; - case 184 /* IntersectionType */: - case 183 /* UnionType */: - if (childKind === 178 /* TypeLiteral */ || childKind === 180 /* TupleType */) { + return childKind !== 233 /* Block */; + case 270 /* ExportDeclaration */: + return childKind !== 271 /* NamedExports */; + case 264 /* ImportDeclaration */: + return childKind !== 265 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 267 /* NamedImports */); + case 276 /* JsxElement */: + return childKind !== 279 /* JsxClosingElement */; + case 280 /* JsxFragment */: + return childKind !== 282 /* JsxClosingFragment */; + case 186 /* IntersectionType */: + case 185 /* UnionType */: + if (childKind === 180 /* TypeLiteral */ || childKind === 182 /* TupleType */) { return false; } break; @@ -138588,11 +141876,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 243 /* ReturnStatement */: - case 247 /* ThrowStatement */: - case 241 /* ContinueStatement */: - case 242 /* BreakStatement */: - return parent.kind !== 231 /* Block */; + case 245 /* ReturnStatement */: + case 249 /* ThrowStatement */: + case 243 /* ContinueStatement */: + case 244 /* BreakStatement */: + return parent.kind !== 233 /* Block */; default: return false; } @@ -138708,7 +141996,9 @@ var ts; return node.getStart(sourceFile); } if (leadingTriviaOption === LeadingTriviaOption.StartLine) { - return ts.getLineStartPositionForPosition(node.getStart(sourceFile), sourceFile); + var startPos = node.getStart(sourceFile); + var pos = ts.getLineStartPositionForPosition(startPos, sourceFile); + return ts.rangeContainsPosition(node, pos) ? pos : startPos; } if (leadingTriviaOption === LeadingTriviaOption.JSDoc) { var JSDocComments = ts.getJSDocCommentRanges(node, sourceFile.text); @@ -138807,7 +142097,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 201 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 203 /* ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -139014,7 +142304,7 @@ var ts; } } else { - endNode = (_a = (node.kind === 250 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 252 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; @@ -139050,7 +142340,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { var firstStatement = ts.firstOrUndefined(ctr.body.statements); if (!firstStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, __spreadArray([newStatement], ctr.body.statements)); + this.replaceConstructorBody(sourceFile, ctr, __spreadArray([newStatement], ctr.body.statements, true)); } else { this.insertNodeBefore(sourceFile, firstStatement, newStatement); @@ -139059,7 +142349,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorStartAfterSuperCall = function (sourceFile, ctr, newStatement) { var superCallStatement = ts.find(ctr.body.statements, function (stmt) { return ts.isExpressionStatement(stmt) && ts.isSuperCall(stmt.expression); }); if (!superCallStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, __spreadArray(__spreadArray([], ctr.body.statements), [newStatement])); + this.replaceConstructorBody(sourceFile, ctr, __spreadArray(__spreadArray([], ctr.body.statements, true), [newStatement], false)); } else { this.insertNodeAfter(sourceFile, superCallStatement, newStatement); @@ -139068,7 +142358,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, __spreadArray(__spreadArray([], ctr.body.statements), [newStatement])); + this.replaceConstructorBody(sourceFile, ctr, __spreadArray(__spreadArray([], ctr.body.statements, true), [newStatement], false)); } else { this.insertNodeAfter(sourceFile, lastStatement, newStatement); @@ -139180,18 +142470,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 253 /* ClassDeclaration */: - case 257 /* ModuleDeclaration */: + case 255 /* ClassDeclaration */: + case 259 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 78 /* Identifier */: + case 79 /* Identifier */: return { prefix: ", " }; - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: return { prefix: " " }; - case 161 /* Parameter */: + case 162 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -139200,12 +142490,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 210 /* ArrowFunction */) { + if (node.kind === 212 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(97 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -139214,14 +142504,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 231 /* Block */) { + if (node.body.kind !== 233 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(104 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(105 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 209 /* FunctionExpression */ ? 97 /* FunctionKeyword */ : 83 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 211 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -139448,16 +142738,17 @@ var ts; } changesToText.newFileChangesWorker = newFileChangesWorker; function computeNewText(change, sourceFile, newLineCharacter, formatContext, validate) { + var _a; if (change.kind === ChangeKind.Remove) { return ""; } if (change.kind === ChangeKind.Text) { return change.text; } - var _a = change.options, options = _a === void 0 ? {} : _a, pos = change.range.pos; + var _b = change.options, options = _b === void 0 ? {} : _b, pos = change.range.pos; var format = function (n) { return getFormattedTextOfNode(n, sourceFile, pos, options, newLineCharacter, formatContext, validate); }; var text = change.kind === ChangeKind.ReplaceWithMultipleNodes - ? change.nodes.map(function (n) { return ts.removeSuffix(format(n), newLineCharacter); }).join(change.options.joiner || newLineCharacter) // TODO: GH#18217 + ? change.nodes.map(function (n) { return ts.removeSuffix(format(n), newLineCharacter); }).join(((_a = change.options) === null || _a === void 0 ? void 0 : _a.joiner) || newLineCharacter) : format(change.node); // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); @@ -139514,7 +142805,7 @@ var ts; return ts.skipTrivia(s, 0) === s.length; } function assignPositionsToNode(node) { - var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // TODO: GH#18217 + var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited); ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node)); @@ -139773,14 +143064,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 159 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 160 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 161 /* Parameter */: { + case 162 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -139795,17 +143086,17 @@ var ts; } break; } - case 262 /* ImportDeclaration */: - case 261 /* ImportEqualsDeclaration */: + case 264 /* ImportDeclaration */: + case 263 /* ImportEqualsDeclaration */: var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax); // For first import, leave header comment in place, otherwise only delete JSDoc comments deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, }); break; - case 199 /* BindingElement */: + case 201 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 198 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 200 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -139813,13 +143104,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 160 /* TypeParameter */: + case 161 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 266 /* ImportSpecifier */: + case 268 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -139828,17 +143119,17 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 264 /* NamespaceImport */: + case 266 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; case 26 /* SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 253 /* ClassDeclaration */: - case 252 /* FunctionDeclaration */: + case 255 /* ClassDeclaration */: + case 254 /* FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -139889,13 +143180,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 262 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 264 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 288 /* CatchClause */) { + if (parent.kind === 290 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; @@ -139906,14 +143197,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 240 /* ForOfStatement */: - case 239 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 241 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 238 /* ForStatement */: + case 240 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -140046,7 +143337,7 @@ var ts; codefix.eachDiagnostic = eachDiagnostic; function getDiagnostics(_a) { var program = _a.program, sourceFile = _a.sourceFile, cancellationToken = _a.cancellationToken; - return __spreadArray(__spreadArray(__spreadArray([], program.getSemanticDiagnostics(sourceFile, cancellationToken)), program.getSyntacticDiagnostics(sourceFile, cancellationToken)), ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken)); + return __spreadArray(__spreadArray(__spreadArray([], program.getSemanticDiagnostics(sourceFile, cancellationToken), true), program.getSyntacticDiagnostics(sourceFile, cancellationToken), true), ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken), true); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -140099,8 +143390,8 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -140237,7 +143528,7 @@ var ts; ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator.code, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code, propertyAccessCode - ], callableConstructableErrorCodes); + ], callableConstructableErrorCodes, true); codefix.registerCodeFix({ fixIds: [fixId], errorCodes: errorCodes, @@ -140333,7 +143624,7 @@ var ts; } var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 233 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 235 /* VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || @@ -140411,10 +143702,10 @@ var ts; function isInsideAwaitableBody(node) { return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 252 /* FunctionDeclaration */ || - ancestor.parent.kind === 209 /* FunctionExpression */ || - ancestor.parent.kind === 210 /* ArrowFunction */ || - ancestor.parent.kind === 166 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 254 /* FunctionDeclaration */ || + ancestor.parent.kind === 211 /* FunctionExpression */ || + ancestor.parent.kind === 212 /* ArrowFunction */ || + ancestor.parent.kind === 167 /* MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -140503,7 +143794,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -140527,16 +143818,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 84 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 78 /* Identifier */: - case 200 /* ArrayLiteralExpression */: - case 201 /* ObjectLiteralExpression */: - case 289 /* PropertyAssignment */: - case 290 /* ShorthandPropertyAssignment */: + case 79 /* Identifier */: + case 202 /* ArrayLiteralExpression */: + case 203 /* ObjectLiteralExpression */: + case 291 /* PropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -140550,8 +143841,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 78 /* Identifier */: - case 217 /* BinaryExpression */: + case 79 /* Identifier */: + case 219 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -140565,7 +143856,7 @@ var ts; if (expression.operatorToken.kind === 27 /* CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 62 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -140600,9 +143891,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 164 /* PropertyDeclaration */ && + if (declaration.kind === 165 /* PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 133 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 134 /* DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -140737,26 +144028,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 250 /* VariableDeclaration */ || - node.kind === 163 /* PropertySignature */ || - node.kind === 164 /* PropertyDeclaration */; + node.kind === 252 /* VariableDeclaration */ || + node.kind === 164 /* PropertySignature */ || + node.kind === 165 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 304 /* JSDocAllType */: - case 305 /* JSDocUnknownType */: + case 307 /* JSDocAllType */: + case 308 /* JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 308 /* JSDocOptionalType */: + case 311 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 307 /* JSDocNonNullableType */: + case 310 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 306 /* JSDocNullableType */: + case 309 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 310 /* JSDocVariadicType */: + case 313 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 309 /* JSDocFunctionType */: + case 312 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 174 /* TypeReference */: + case 176 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); @@ -140777,11 +144068,11 @@ var ts; var _a; // TODO: This does not properly handle `function(new:C, string)` per https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#the-javascript-type-language // however we do handle it correctly in `serializeTypeForDeclaration` in checker.ts - return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 310 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 313 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -140821,8 +144112,8 @@ var ts; var index = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -140899,7 +144190,7 @@ var ts; if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 62 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; var memberElement = createClassElement(prototypes.symbol, /** modifiers */ undefined); @@ -140909,7 +144200,7 @@ var ts; } } else { - var memberElement = createClassElement(member, [ts.factory.createToken(123 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)]); if (memberElement) { memberElements.push.apply(memberElements, memberElement); } @@ -140955,7 +144246,7 @@ var ts; return members; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 234 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 236 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -141006,7 +144297,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 129 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 130 /* AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -141016,14 +144307,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 231 /* Block */) { + if (arrowFunctionBody.kind === 233 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 129 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 130 /* AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -141040,7 +144331,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 92 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -141051,7 +144342,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 92 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -141139,7 +144430,7 @@ var ts; functionToConvert.decorators ? ts.skipTrivia(sourceFile.text, functionToConvert.decorators.end) : functionToConvert.getStart(sourceFile); var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; - changes.insertModifierAt(sourceFile, pos, 129 /* AsyncKeyword */, options); + changes.insertModifierAt(sourceFile, pos, 130 /* AsyncKeyword */, options); var _loop_13 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { @@ -141398,9 +144689,9 @@ var ts; function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) { if (typeAnnotation && expressionToReturn) { var name = ts.factory.createUniqueName("result", 16 /* Optimistic */); - return __spreadArray(__spreadArray([], createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation)), [ + return __spreadArray(__spreadArray([], createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), true), [ ts.factory.createReturnStatement(name) - ]); + ], false); } return [ts.factory.createReturnStatement(expressionToReturn)]; } @@ -141408,11 +144699,11 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var _a, _b, _c, _d, _e; switch (func.kind) { - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 202 /* PropertyAccessExpression */: - case 78 /* Identifier */: // identifier includes undefined + case 204 /* PropertyAccessExpression */: + case 79 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -141433,8 +144724,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: { + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_c = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _c === void 0 ? void 0 : _c.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -141653,10 +144944,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 204 /* CallExpression */: + case 206 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -141716,29 +145007,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression) && ts.isIdentifier(node.name)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 62 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 234 /* ExpressionStatement */: { + case 236 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 204 /* CallExpression */: { + case 206 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 217 /* BinaryExpression */: { + case 219 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -141785,8 +145076,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 197 /* ObjectBindingPattern */: - case 198 /* ArrayBindingPattern */: { + case 199 /* ObjectBindingPattern */: + case 200 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -141794,7 +145085,7 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 78 /* Identifier */: + case 79 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: @@ -141837,17 +145128,17 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 290 /* ShorthandPropertyAssignment */: - case 291 /* SpreadAssignment */: + case 292 /* ShorthandPropertyAssignment */: + case 293 /* SpreadAssignment */: return undefined; - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 166 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(92 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 167 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); default: ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } @@ -141894,7 +145185,7 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(92 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -141903,14 +145194,14 @@ var ts; } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(92 /* ExportKeyword */), ts.factory.createToken(84 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { - var modifiers = [ts.factory.createToken(92 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; switch (exported.kind) { - case 209 /* FunctionExpression */: { + case 211 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -141918,10 +145209,10 @@ var ts; } } // falls through - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 222 /* ClassExpression */: + case 224 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -141941,7 +145232,7 @@ var ts; : ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode); function replaceNode(original) { // We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions - if (original.kind === 202 /* PropertyAccessExpression */) { + if (original.kind === 204 /* PropertyAccessExpression */) { var replacement = useSitesToUnqualify.get(original); // Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing useSitesToUnqualify.delete(original); @@ -141956,7 +145247,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 197 /* ObjectBindingPattern */: { + case 199 /* ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -141969,7 +145260,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 198 /* ArrayBindingPattern */: { + case 200 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -141980,7 +145271,7 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 78 /* Identifier */: + case 79 /* Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); @@ -142062,11 +145353,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: return parent.name !== node; - case 199 /* BindingElement */: + case 201 /* BindingElement */: return parent.propertyName !== node; - case 266 /* ImportSpecifier */: + case 268 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -142180,7 +145471,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 149 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 150 /* TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, @@ -142366,7 +145657,7 @@ var ts; function createMissingIndexSignatureDeclaration(type, kind) { var indexInfoOfKind = checker.getIndexInfoOfType(type, kind); if (indexInfoOfKind) { - insertInterfaceMemberNode(sourceFile, classDeclaration, checker.indexInfoToIndexSignatureDeclaration(indexInfoOfKind, kind, classDeclaration, /*flags*/ undefined, codefix.getNoopSymbolTrackerWithResolver(context))); + insertInterfaceMemberNode(sourceFile, classDeclaration, checker.indexInfoToIndexSignatureDeclaration(indexInfoOfKind, classDeclaration, /*flags*/ undefined, codefix.getNoopSymbolTrackerWithResolver(context))); } } // Either adds the node at the top of the class, or if there's a constructor right after that @@ -142404,6 +145695,7 @@ var ts; ts.Diagnostics.Cannot_find_namespace_0.code, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, + ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -142448,11 +145740,13 @@ var ts; var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions)); var checker = program.getTypeChecker(); var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker)); - var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, host, program, useAutoImportProvider); + var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, host, program, preferences, useAutoImportProvider); var preferTypeOnlyImport = !!usageIsTypeOnly && compilerOptions.importsNotUsedAsValues === 2 /* Error */; var useRequire = shouldUseRequire(sourceFile, program); var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, preferTypeOnlyImport, useRequire, host, preferences); - addImport({ fixes: [fix], symbolName: symbolName }); + if (fix) { + addImport({ fixes: [fix], symbolName: symbolName }); + } } function addImport(info) { var fixes = info.fixes, symbolName = info.symbolName; @@ -142547,16 +145841,16 @@ var ts; var compilerOptions = program.getCompilerOptions(); var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name)) ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, program, host)] - : getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, host, program, /*useAutoImportProvider*/ true); + : getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true); var useRequire = shouldUseRequire(sourceFile, program); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !ts.isSourceFileJS(sourceFile) && ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); - var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences); + var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences)); return { moduleSpecifier: fix.moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences) { - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); - return getBestFix(getImportFixes(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences), sourceFile, host); + ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); + return getBestFix(getImportFixes(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences), sourceFile, program, host, preferences); } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; @@ -142572,101 +145866,54 @@ var ts; var autoImportProvider = (_b = (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getTypeChecker(); return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider, /*isFromPackageJson*/ true), "Could not find symbol in specified module for code actions"); function getInfoWithChecker(checker, isFromPackageJson) { - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && ts.skipAlias(defaultInfo.symbol, checker) === symbol) { - return { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; + return { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { symbol: named, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; + return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; } } } - function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, host, program, useAutoImportProvider) { + function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, host, program, preferences, useAutoImportProvider) { var result = []; var compilerOptions = program.getCompilerOptions(); var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); }); - forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) { + ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { - result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); + result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(defaultInfo.symbol, checker).flags, isFromPackageJson: isFromPackageJson }); } for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { - result.push({ symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); + result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); } } }); return result; function isImportable(program, moduleFile, isFromPackageJson) { var _a; - return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host)); + return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host)); } } - function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences) { - return getBestFix(getNewImportFixes(program, importingFile, /*position*/ undefined, /*preferTypeOnlyImport*/ false, /*useRequire*/ false, exportInfo, host, preferences), importingFile, host); + function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, fromCacheOnly) { + var _a = getNewImportFixes(program, importingFile, + /*position*/ undefined, + /*preferTypeOnlyImport*/ false, + /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount; + var result = getBestFix(fixes, importingFile, program, host, preferences); + return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount }); } codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo; - function getSymbolToExportInfoMap(importingFile, host, program) { - var _a, _b, _c, _d, _e, _f, _g, _h; - var start = ts.timestamp(); - // Pulling the AutoImportProvider project will trigger its updateGraph if pending, - // which will invalidate the export map cache if things change, so pull it before - // checking the cache. - (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host); - var cache = (_b = host.getExportMapCache) === null || _b === void 0 ? void 0 : _b.call(host); - if (cache) { - var cached = cache.get(importingFile.path, program.getTypeChecker(), (_c = host.getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(host)); - if (cached) { - (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getSymbolToExportInfoMap: cache hit"); - return cached; - } - else { - (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getSymbolToExportInfoMap: cache miss or empty; calculating new results"); - } - } - var result = ts.createMultiMap(); - var compilerOptions = program.getCompilerOptions(); - var target = ts.getEmitScriptTarget(compilerOptions); - forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, _moduleFile, program, isFromPackageJson) { - var checker = program.getTypeChecker(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); - if (defaultInfo) { - var name = ts.getNameForExportedSymbol(ts.getLocalSymbolForExportDefault(defaultInfo.symbol) || defaultInfo.symbol, target); - result.add(key(name, defaultInfo.symbol, moduleSymbol, checker), { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); - } - var seenExports = new ts.Map(); - for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { - var exported = _a[_i]; - if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && ts.addToSeen(seenExports, exported)) { - result.add(key(ts.getNameForExportedSymbol(exported, target), exported, moduleSymbol, checker), { symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); - } - } - }); - if (cache) { - (_f = host.log) === null || _f === void 0 ? void 0 : _f.call(host, "getSymbolToExportInfoMap: caching results"); - cache.set(result, (_g = host.getProjectVersion) === null || _g === void 0 ? void 0 : _g.call(host)); - } - (_h = host.log) === null || _h === void 0 ? void 0 : _h.call(host, "getSymbolToExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); - return result; - function key(name, alias, moduleSymbol, checker) { - var moduleName = ts.stripQuotes(moduleSymbol.name); - var moduleKey = ts.isExternalModuleNameRelative(moduleName) ? "/" : moduleName; - return name + "|" + ts.getSymbolId(ts.skipAlias(alias, checker)) + "|" + moduleKey; - } - } - codefix.getSymbolToExportInfoMap = getSymbolToExportInfoMap; - function isTypeOnlySymbol(s, checker) { - return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); - } function isTypeOnlyPosition(sourceFile, position) { return ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); } @@ -142679,7 +145926,7 @@ var ts; var addToExisting = tryAddToExistingImport(existingImports, position !== undefined && isTypeOnlyPosition(sourceFile, position)); // Don't bother providing an action to add a new import if we can add to an existing one. var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, preferTypeOnlyImport, useRequire, host, preferences); - return __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray)), addImport); + return __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), addImport, true); } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -142709,11 +145956,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport); return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol); default: @@ -142723,11 +145970,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return declaration.name.text; - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text; default: return ts.Debug.assertNever(declaration); @@ -142736,10 +145983,10 @@ var ts; function tryAddToExistingImport(existingImports, canUseTypeOnlyImport) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 261 /* ImportEqualsDeclaration */) + if (declaration.kind === 263 /* ImportEqualsDeclaration */) return undefined; - if (declaration.kind === 250 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 197 /* ObjectBindingPattern */ + if (declaration.kind === 252 /* VariableDeclaration */) { + return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 199 /* ObjectBindingPattern */ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, canUseTypeOnlyImport: false } : undefined; } @@ -142751,15 +145998,15 @@ var ts; // be added to an existing type-only import is adding a named import to existing named bindings. if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings)) return undefined; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 265 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 267 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, canUseTypeOnlyImport: canUseTypeOnlyImport } : undefined; }); } function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) { - var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; + var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags; // Can't use an es6 import for a type in JS. - if (exportedSymbolIsTypeOnly && ts.isSourceFileJS(importingFile)) + if (!(targetFlags & 111551 /* Value */) && ts.isSourceFileJS(importingFile)) return ts.emptyArray; var importKind = getImportKind(importingFile, exportKind, compilerOptions); return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { @@ -142767,7 +146014,7 @@ var ts; if (ts.isRequireVariableDeclaration(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind } : undefined; } - if (i.kind === 262 /* ImportDeclaration */ || i.kind === 261 /* ImportEqualsDeclaration */) { + if (i.kind === 264 /* ImportDeclaration */ || i.kind === 263 /* ImportEqualsDeclaration */) { return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; } }); @@ -142800,23 +146047,37 @@ var ts; // 5. Literally nothing to go on return true; } - function getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { + function getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences, fromCacheOnly) { var isJs = ts.isSourceFileJS(sourceFile); var compilerOptions = program.getCompilerOptions(); var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); - return ts.flatMap(moduleSymbols, function (exportInfo) { - return ts.moduleSpecifiers.getModuleSpecifiers(exportInfo.moduleSymbol, program.getTypeChecker(), compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences) - .map(function (moduleSpecifier) { + var checker = program.getTypeChecker(); + var getModuleSpecifiers = fromCacheOnly + ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); } + : function (moduleSymbol) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); }; + var computedWithoutCacheCount = 0; + var fixes = ts.flatMap(moduleSymbols, function (exportInfo) { + var _a = getModuleSpecifiers(exportInfo.moduleSymbol), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers; + computedWithoutCacheCount += computedWithoutCache ? 1 : 0; + return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportInfo.exportedSymbolIsTypeOnly && isJs && position !== undefined + return !(exportInfo.targetFlags & 111551 /* Value */) && isJs && position !== undefined ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo } - : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), useRequire: useRequire, typeOnly: preferTypeOnlyImport, exportInfo: exportInfo }; + : { + kind: 3 /* AddNew */, + moduleSpecifier: moduleSpecifier, + importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), + useRequire: useRequire, + typeOnly: preferTypeOnlyImport, + exportInfo: exportInfo, + }; }); }); + return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes }; } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, preferTypeOnlyImport, useRequire, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, preferTypeOnlyImport, useRequire); }); - return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); + return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences).fixes; } function newImportInfoFromExistingSpecifier(_a, preferTypeOnlyImport, useRequire) { var declaration = _a.declaration, importKind = _a.importKind; @@ -142830,29 +146091,39 @@ var ts; var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ? getFixesInfoForUMDImport(context, symbolToken) : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined; - return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.host) }); + return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, context.host, context.preferences) }); } - function sortFixes(fixes, sourceFile, host) { - var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; - return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, allowsImportingSpecifier); }); + function sortFixes(fixes, sourceFile, program, host, preferences) { + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier; + return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, allowsImportingSpecifier); }); } - function getBestFix(fixes, sourceFile, host) { + function getBestFix(fixes, sourceFile, program, host, preferences) { + if (!ts.some(fixes)) + return; // These will always be placed first if available, and are better than other kinds if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) { return fixes[0]; } - var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier; return fixes.reduce(function (best, fix) { - return compareModuleSpecifiers(fix, best, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best; + return compareModuleSpecifiers(fix, best, sourceFile, program, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best; }); } - function compareModuleSpecifiers(a, b, allowsImportingSpecifier) { + function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) { if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { return ts.compareBooleans(allowsImportingSpecifier(a.moduleSpecifier), allowsImportingSpecifier(b.moduleSpecifier)) + || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); } return 0 /* EqualTo */; } + function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) { + if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:")) + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */; + if (ts.startsWith(b, "node:") && !ts.startsWith(a, "node:")) + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* GreaterThan */ : -1 /* LessThan */; + return 0 /* EqualTo */; + } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; var checker = program.getTypeChecker(); @@ -142861,7 +146132,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, exportKind: 3 /* UMD */, exportedSymbolIsTypeOnly: false, isFromPackageJson: false }]; + var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; @@ -142877,17 +146148,21 @@ var ts; ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } - function getImportKind(importingFile, exportKind, compilerOptions) { + /** + * @param forceImportKeyword Indicates that the user has already typed `import`, so the result must start with `import`. + * (In other words, do not allow `const x = require("...")` for JS files.) + */ + function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) { switch (exportKind) { case 0 /* Named */: return 0 /* Named */; case 1 /* Default */: return 1 /* Default */; - case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions); - case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions); + case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); default: return ts.Debug.assertNever(exportKind); } } codefix.getImportKind = getImportKind; - function getUmdImportKind(importingFile, compilerOptions) { + function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { return 1 /* Default */; @@ -142899,7 +146174,7 @@ var ts; case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 3 /* CommonJS */; + return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */; } return 3 /* CommonJS */; case ts.ModuleKind.System: @@ -142922,7 +146197,7 @@ var ts; ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && ts.isValidTypeOnlyAliasUseSite(symbolToken); var useRequire = shouldUseRequire(sourceFile, program); - var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host); + var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); @@ -142940,29 +146215,29 @@ var ts; return symbolToken.text; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) { var _a; // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); - var packageJsonFilter = ts.createPackageJsonImportFilter(fromFile, host); + var packageJsonFilter = ts.createPackageJsonImportFilter(fromFile, preferences, host); var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); }); function addSymbol(moduleSymbol, toFile, exportedSymbol, exportKind, program, isFromPackageJson) { var moduleSpecifierResolutionHost = getModuleSpecifierResolutionHost(isFromPackageJson); - if (toFile && ts.isImportableFile(program, fromFile, toFile, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) || + if (toFile && ts.isImportableFile(program, fromFile, toFile, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) || !toFile && packageJsonFilter.allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost)) { var checker = program.getTypeChecker(); - originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, exportKind: exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker), isFromPackageJson: isFromPackageJson }); + originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, moduleFileName: toFile === null || toFile === void 0 ? void 0 : toFile.fileName, exportKind: exportKind, targetFlags: ts.skipAlias(exportedSymbol, checker).flags, isFromPackageJson: isFromPackageJson }); } } - forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) { + ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); cancellationToken.throwIfCancellationRequested(); var compilerOptions = program.getCompilerOptions(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson); } @@ -142974,33 +146249,20 @@ var ts; }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(moduleSymbol, checker); - if (!exported) - return undefined; - var symbol = exported.symbol, exportKind = exported.exportKind; - var info = getDefaultExportInfoWorker(symbol, checker, compilerOptions); - return info && __assign({ symbol: symbol, exportKind: exportKind }, info); - } - function getDefaultLikeExportWorker(moduleSymbol, checker) { - var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); - if (exportEquals !== moduleSymbol) - return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ }; - var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); - if (defaultExport) - return { symbol: defaultExport, exportKind: 1 /* Default */ }; - } - function getExportEqualsImportKind(importingFile, compilerOptions) { + function getExportEqualsImportKind(importingFile, compilerOptions, forceImportKeyword) { var allowSyntheticDefaults = ts.getAllowSyntheticDefaultImports(compilerOptions); - // 1. 'import =' will not work in es2015+, so the decision is between a default + var isJS = ts.isInJSFile(importingFile); + // 1. 'import =' will not work in es2015+ TS files, so the decision is between a default // and a namespace import, based on allowSyntheticDefaultImports/esModuleInterop. - if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + if (!isJS && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */; } - // 2. 'import =' will not work in JavaScript, so the decision is between a default - // and const/require. - if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) ? 1 /* Default */ : 3 /* CommonJS */; + // 2. 'import =' will not work in JavaScript, so the decision is between a default import, + // a namespace import, and const/require. + if (isJS) { + return ts.isExternalModule(importingFile) || forceImportKeyword + ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ + : 3 /* CommonJS */; } // 3. At this point the most correct choice is probably 'import =', but people // really hate that, so look to see if the importing file has any precedent @@ -143016,41 +146278,6 @@ var ts; // allowSyntheticDefaultImports/esModuleInterop is enabled. return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; } - function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { - var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); - if (localSymbol) - return { symbolForMeaning: localSymbol, name: localSymbol.name }; - var name = getNameForExportDefault(defaultExport); - if (name !== undefined) - return { symbolForMeaning: defaultExport, name: name }; - if (defaultExport.flags & 2097152 /* Alias */) { - var aliased = checker.getImmediateAliasedSymbol(defaultExport); - if (aliased && aliased.parent) { - // - `aliased` will be undefined if the module is exporting an unresolvable name, - // but we can still offer completions for it. - // - `aliased.parent` will be undefined if the module is exporting `globalThis.something`, - // or another expression that resolves to a global. - return getDefaultExportInfoWorker(aliased, checker, compilerOptions); - } - } - if (defaultExport.escapedName !== "default" /* Default */ && - defaultExport.escapedName !== "export=" /* ExportEquals */) { - return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; - } - return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; - } - function getNameForExportDefault(symbol) { - return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { - var _a; - if (ts.isExportAssignment(declaration)) { - return (_a = ts.tryCast(ts.skipOuterExpressions(declaration.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - } - else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); - return declaration.propertyName && declaration.propertyName.text; - } - }); - } function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference) { var diag; var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { @@ -143086,7 +146313,7 @@ var ts; } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, canUseTypeOnlyImport) { - if (clause.kind === 197 /* ObjectBindingPattern */) { + if (clause.kind === 199 /* ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport, "default"); } @@ -143213,31 +146440,6 @@ var ts; var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) { - var _a, _b; - forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); - var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)); - if (autoImportProvider) { - var start = ts.timestamp(); - forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start)); - } - } - codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; - function forEachExternalModule(checker, allSourceFiles, cb) { - for (var _i = 0, _a = checker.getAmbientModules(); _i < _a.length; _i++) { - var ambient = _a[_i]; - if (!ts.stringContains(ambient.name, "*")) { - cb(ambient, /*sourceFile*/ undefined); - } - } - for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) { - var sourceFile = allSourceFiles_1[_b]; - if (ts.isExternalOrCommonJsModule(sourceFile)) { - cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile); - } - } - } function moduleSymbolToValidIdentifier(moduleSymbol, target) { return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target); } @@ -143348,28 +146550,30 @@ var ts; var classElement = findContainerClassElementLike(sourceFile, pos); var modifiers = classElement.modifiers || ts.emptyArray; var staticModifier = ts.find(modifiers, ts.isStaticModifier); + var abstractModifier = ts.find(modifiers, ts.isAbstractModifier); var accessibilityModifier = ts.find(modifiers, function (m) { return ts.isAccessibilityModifier(m.kind); }); - var modifierPos = staticModifier ? staticModifier.end : - accessibilityModifier ? accessibilityModifier.end : - classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); - var options = accessibilityModifier || staticModifier ? { prefix: " " } : { suffix: " " }; - changeTracker.insertModifierAt(sourceFile, modifierPos, 156 /* OverrideKeyword */, options); + var modifierPos = abstractModifier ? abstractModifier.end : + staticModifier ? staticModifier.end : + accessibilityModifier ? accessibilityModifier.end : + classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); + var options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " }; + changeTracker.insertModifierAt(sourceFile, modifierPos, 157 /* OverrideKeyword */, options); } function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { var classElement = findContainerClassElementLike(sourceFile, pos); - var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 156 /* OverrideKeyword */; }); + var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 157 /* OverrideKeyword */; }); ts.Debug.assertIsDefined(overrideModifier); changeTracker.deleteModifier(sourceFile, overrideModifier); } function isClassElementLikeHasJSDoc(node) { switch (node.kind) { - case 167 /* Constructor */: - case 164 /* PropertyDeclaration */: - case 166 /* MethodDeclaration */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 169 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: return true; - case 161 /* Parameter */: + case 162 /* Parameter */: return ts.isParameterPropertyDeclaration(node, node.parent); default: return false; @@ -143445,12 +146649,12 @@ var ts; }); function doChange(changes, sourceFile, pos, checker) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 107 /* ThisKeyword */); + ts.Debug.assert(token.kind === 108 /* ThisKeyword */); var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false); if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn)) return undefined; if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function - var fnKeyword = ts.Debug.assertDefined(ts.findChildOfKind(fn, 97 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.assertDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -143469,7 +146673,7 @@ var ts; else { // `function f() {}` => `const f = () => {}` // `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`. - changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(84 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -143500,7 +146704,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 193 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 195 /* NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -143509,11 +146713,11 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 181 /* OptionalType */ || unwrappedType.kind === 182 /* RestType */ || unwrappedType.kind === 187 /* ParenthesizedType */) { - if (unwrappedType.kind === 181 /* OptionalType */) { + while (unwrappedType.kind === 183 /* OptionalType */ || unwrappedType.kind === 184 /* RestType */ || unwrappedType.kind === 189 /* ParenthesizedType */) { + if (unwrappedType.kind === 183 /* OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 182 /* RestType */) { + else if (unwrappedType.kind === 184 /* RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; @@ -143534,10 +146738,13 @@ var ts; var fixId = "fixSpelling"; var errorCodes = [ ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code, + ts.Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.code, + ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1.code, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2.code, + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1.code, // for JSX class components ts.Diagnostics.No_overload_matches_this_call.code, // for JSX FC @@ -143604,6 +146811,14 @@ var ts; var props = checker.getContextualTypeForArgumentAtIndex(tag, 0); suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props); } + else if (ts.hasSyntacticModifier(parent, 16384 /* Override */) && ts.isClassElement(parent) && parent.name === node) { + var baseDeclaration = ts.findAncestor(node, ts.isClassLike); + var baseTypeNode = baseDeclaration ? ts.getEffectiveBaseTypeNode(baseDeclaration) : undefined; + var baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : undefined; + if (baseType) { + suggestedSymbol = checker.getSuggestedSymbolForNonexistentClassMember(ts.getTextOfNode(node), baseType); + } + } else { var meaning = ts.getMeaningFromLocation(node); var name = ts.getTextOfNode(node); @@ -143711,7 +146926,7 @@ var ts; var member = checker.createSymbol(4 /* Property */, label.escapedText); member.type = checker.getTypeAtLocation(expression); var members = ts.createSymbolTable([member]); - return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], []); } function getFixInfo(checker, declaration, expectType, isFunctionType) { if (!declaration.body || !ts.isBlock(declaration.body) || ts.length(declaration.body.statements) !== 1) @@ -143773,9 +146988,7 @@ var ts; var newSig = checker.createSignature(declaration, sig.typeParameters, sig.thisParameter, sig.parameters, exprType, /*typePredicate*/ undefined, sig.minArgumentCount, sig.flags); exprType = checker.createAnonymousType( - /*symbol*/ undefined, ts.createSymbolTable(), [newSig], [], - /*stringIndexInfo*/ undefined, - /*numberIndexInfo*/ undefined); + /*symbol*/ undefined, ts.createSymbolTable(), [newSig], [], []); } else { exprType = checker.getAnyType(); @@ -143813,19 +147026,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 250 /* VariableDeclaration */: - case 161 /* Parameter */: - case 199 /* BindingElement */: - case 164 /* PropertyDeclaration */: - case 289 /* PropertyAssignment */: + case 252 /* VariableDeclaration */: + case 162 /* Parameter */: + case 201 /* BindingElement */: + case 165 /* PropertyDeclaration */: + case 291 /* PropertyAssignment */: return declaration.initializer; - case 281 /* JsxAttribute */: + case 283 /* JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 290 /* ShorthandPropertyAssignment */: - case 163 /* PropertySignature */: - case 292 /* EnumMember */: - case 337 /* JSDocPropertyTag */: - case 330 /* JSDocParameterTag */: + case 292 /* ShorthandPropertyAssignment */: + case 164 /* PropertySignature */: + case 294 /* EnumMember */: + case 342 /* JSDocPropertyTag */: + case 335 /* JSDocParameterTag */: return undefined; } } @@ -143867,6 +147080,8 @@ var ts; var codefix; (function (codefix) { var fixMissingMember = "fixMissingMember"; + var fixMissingProperties = "fixMissingProperties"; + var fixMissingAttributes = "fixMissingAttributes"; var fixMissingFunctionDeclaration = "fixMissingFunctionDeclaration"; var errorCodes = [ ts.Diagnostics.Property_0_does_not_exist_on_type_1.code, @@ -143884,6 +147099,14 @@ var ts; if (!info) { return undefined; } + if (info.kind === 3 /* ObjectLiteral */) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); }); + return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)]; + } + if (info.kind === 4 /* JsxAttributes */) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); }); + return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)]; + } if (info.kind === 2 /* Function */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); }); return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)]; @@ -143894,7 +147117,7 @@ var ts; } return ts.concatenate(getActionsForMissingMethodDeclaration(context, info), getActionsForMissingMemberDeclaration(context, info)); }, - fixIds: [fixMissingMember, fixMissingFunctionDeclaration], + fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes], getAllCodeActions: function (context) { var program = context.program, fixId = context.fixId; var checker = program.getTypeChecker(); @@ -143906,10 +147129,14 @@ var ts; if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { return; } - if (fixId === fixMissingFunctionDeclaration) { - if (info.kind === 2 /* Function */) { - addFunctionDeclaration(changes, context, info); - } + if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) { + addFunctionDeclaration(changes, context, info); + } + else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) { + addObjectLiteralProperties(changes, context, info); + } + else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) { + addJsxAttributes(changes, context, info); } else { if (info.kind === 0 /* Enum */) { @@ -143951,8 +147178,8 @@ var ts; } } }; - for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { - var info = infos_2[_i]; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; _loop_14(info); } }); @@ -143964,6 +147191,8 @@ var ts; InfoKind[InfoKind["Enum"] = 0] = "Enum"; InfoKind[InfoKind["ClassOrInterface"] = 1] = "ClassOrInterface"; InfoKind[InfoKind["Function"] = 2] = "Function"; + InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral"; + InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes"; })(InfoKind || (InfoKind = {})); function getInfo(sourceFile, tokenPos, checker, program) { // The identifier of the missing property. eg: @@ -143974,6 +147203,18 @@ var ts; return undefined; } var parent = token.parent; + if (ts.isIdentifier(token) && ts.hasInitializer(parent) && parent.initializer && ts.isObjectLiteralExpression(parent.initializer)) { + var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); + if (ts.length(properties)) { + return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; + } + } + if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) { + var attributes = getUnmatchedAttributes(checker, token.parent); + if (ts.length(attributes)) { + return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; + } + } if (ts.isIdentifier(token) && ts.isCallExpression(parent)) { return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile }; } @@ -143988,14 +147229,14 @@ var ts; if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) { var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration); var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile(); - if (moduleDeclaration && moduleDeclarationSourceFile && !program.isSourceFileFromExternalLibrary(moduleDeclarationSourceFile)) { + if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) { return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration }; } var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile); if (sourceFile.commonJsModuleIndicator) { return; } - if (moduleSourceFile && !program.isSourceFileFromExternalLibrary(moduleSourceFile)) { + if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; } } @@ -144006,7 +147247,7 @@ var ts; } // Prefer to change the class instead of the interface if they are merged var classOrInterface = classDeclaration || ts.find(symbol.declarations, ts.isInterfaceDeclaration); - if (classOrInterface && !program.isSourceFileFromExternalLibrary(classOrInterface.getSourceFile())) { + if (classOrInterface && !isSourceFileFromLibrary(program, classOrInterface.getSourceFile())) { var makeStatic = (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol); if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(classOrInterface))) { return undefined; @@ -144018,11 +147259,14 @@ var ts; return { kind: 1 /* ClassOrInterface */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: classOrInterface, declSourceFile: declSourceFile, isJSFile: isJSFile }; } var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); - if (enumDeclaration && !ts.isPrivateIdentifier(token) && !program.isSourceFileFromExternalLibrary(enumDeclaration.getSourceFile())) { + if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) { return { kind: 0 /* Enum */, token: token, parentDeclaration: enumDeclaration }; } return undefined; } + function isSourceFileFromLibrary(program, node) { + return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node); + } function getActionsForMissingMemberDeclaration(context, info) { return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) : createActionsForAddMissingMemberInTypeScriptFile(context, info); @@ -144043,7 +147287,7 @@ var ts; function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 222 /* ClassExpression */) { + if (classDeclaration.kind === 224 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -144075,7 +147319,7 @@ var ts; } } function initializePropertyToUndefined(obj, propertyName) { - return ts.factory.createExpressionStatement(ts.factory.createAssignment(ts.factory.createPropertyAccessExpression(obj, propertyName), ts.factory.createIdentifier("undefined"))); + return ts.factory.createExpressionStatement(ts.factory.createAssignment(ts.factory.createPropertyAccessExpression(obj, propertyName), createUndefined())); } function createActionsForAddMissingMemberInTypeScriptFile(context, _a) { var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token; @@ -144095,7 +147339,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 217 /* BinaryExpression */) { + if (token.parent.parent.kind === 219 /* BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); @@ -144105,7 +147349,7 @@ var ts; var contextualType = checker.getContextualType(token.parent); typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags) { var property = ts.factory.createPropertyDeclaration( @@ -144134,7 +147378,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(147 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(148 /* StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -144167,7 +147411,7 @@ var ts; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(166 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); + var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(167 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); }); if (containingMethodDeclaration && containingMethodDeclaration.parent === parentDeclaration) { changes.insertNodeAfter(sourceFile, containingMethodDeclaration, methodDeclaration); @@ -144196,9 +147440,136 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(252 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(254 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); } + function addJsxAttributes(changes, context, info) { + var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); + var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences); + var checker = context.program.getTypeChecker(); + var jsxAttributesNode = info.parentDeclaration.attributes; + var hasSpreadAttribute = ts.some(jsxAttributesNode.properties, ts.isJsxSpreadAttribute); + var attrs = ts.map(info.attributes, function (attr) { + var value = attr.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(attr.valueDeclaration)) : createUndefined(); + return ts.factory.createJsxAttribute(ts.factory.createIdentifier(attr.name), ts.factory.createJsxExpression(/*dotDotDotToken*/ undefined, value)); + }); + var jsxAttributes = ts.factory.createJsxAttributes(hasSpreadAttribute ? __spreadArray(__spreadArray([], attrs, true), jsxAttributesNode.properties, true) : __spreadArray(__spreadArray([], jsxAttributesNode.properties, true), attrs, true)); + var options = { prefix: jsxAttributesNode.pos === jsxAttributesNode.end ? " " : undefined }; + changes.replaceNode(context.sourceFile, jsxAttributesNode, jsxAttributes, options); + } + function addObjectLiteralProperties(changes, context, info) { + var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); + var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences); + var checker = context.program.getTypeChecker(); + var props = ts.map(info.properties, function (prop) { + var initializer = prop.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(prop.valueDeclaration)) : createUndefined(); + return ts.factory.createPropertyAssignment(prop.name, initializer); + }); + changes.replaceNode(context.sourceFile, info.parentDeclaration, ts.factory.createObjectLiteralExpression(__spreadArray(__spreadArray([], info.parentDeclaration.properties, true), props, true), /*multiLine*/ true)); + } + function tryGetValueFromType(context, checker, importAdder, quotePreference, type) { + if (type.flags & 3 /* AnyOrUnknown */) { + return createUndefined(); + } + if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* Single */); + } + if (type.flags & 8 /* Number */) { + return ts.factory.createNumericLiteral(0); + } + if (type.flags & 64 /* BigInt */) { + return ts.factory.createBigIntLiteral("0n"); + } + if (type.flags & 16 /* Boolean */) { + return ts.factory.createFalse(); + } + if (type.flags & 1056 /* EnumLike */) { + var enumMember = type.symbol.exports ? ts.firstOrUndefined(ts.arrayFrom(type.symbol.exports.values())) : type.symbol; + var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); + return enumMember === undefined || name === undefined ? ts.factory.createNumericLiteral(0) : ts.factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember)); + } + if (type.flags & 256 /* NumberLiteral */) { + return ts.factory.createNumericLiteral(type.value); + } + if (type.flags & 2048 /* BigIntLiteral */) { + return ts.factory.createBigIntLiteral(type.value); + } + if (type.flags & 128 /* StringLiteral */) { + return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* Single */); + } + if (type.flags & 512 /* BooleanLiteral */) { + return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); + } + if (type.flags & 65536 /* Null */) { + return ts.factory.createNull(); + } + if (type.flags & 1048576 /* Union */) { + var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t); }); + return expression !== null && expression !== void 0 ? expression : createUndefined(); + } + if (checker.isArrayLikeType(type)) { + return ts.factory.createArrayLiteralExpression(); + } + if (isObjectLiteralType(type)) { + var props = ts.map(checker.getPropertiesOfType(type), function (prop) { + var initializer = prop.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(prop.valueDeclaration)) : createUndefined(); + return ts.factory.createPropertyAssignment(prop.name, initializer); + }); + return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true); + } + if (ts.getObjectFlags(type) & 16 /* Anonymous */) { + var decl = ts.find(type.symbol.declarations || ts.emptyArray, ts.or(ts.isFunctionTypeNode, ts.isMethodSignature, ts.isMethodDeclaration)); + if (decl === undefined) + return createUndefined(); + var signature = checker.getSignaturesOfType(type, 0 /* Call */); + if (signature === undefined) + return createUndefined(); + var func = codefix.createSignatureDeclarationFromSignature(211 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder); + return func !== null && func !== void 0 ? func : createUndefined(); + } + if (ts.getObjectFlags(type) & 1 /* Class */) { + var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); + if (classDeclaration === undefined || ts.hasAbstractModifier(classDeclaration)) + return createUndefined(); + var constructorDeclaration = ts.getFirstConstructorWithBody(classDeclaration); + if (constructorDeclaration && ts.length(constructorDeclaration.parameters)) + return createUndefined(); + return ts.factory.createNewExpression(ts.factory.createIdentifier(type.symbol.name), /*typeArguments*/ undefined, /*argumentsArray*/ undefined); + } + return createUndefined(); + } + function createUndefined() { + return ts.factory.createIdentifier("undefined"); + } + function isObjectLiteralType(type) { + return (type.flags & 524288 /* Object */) && + ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); + } + function getUnmatchedAttributes(checker, source) { + var attrsType = checker.getContextualType(source.attributes); + if (attrsType === undefined) + return ts.emptyArray; + var targetProps = attrsType.getProperties(); + if (!ts.length(targetProps)) + return ts.emptyArray; + var seenNames = new ts.Set(); + for (var _i = 0, _a = source.attributes.properties; _i < _a.length; _i++) { + var sourceProp = _a[_i]; + if (ts.isJsxAttribute(sourceProp)) { + seenNames.add(sourceProp.name.escapedText); + } + if (ts.isJsxSpreadAttribute(sourceProp)) { + var type = checker.getTypeAtLocation(sourceProp.expression); + for (var _b = 0, _c = type.getProperties(); _b < _c.length; _b++) { + var prop = _c[_b]; + seenNames.add(prop.escapedName); + } + } + } + return ts.filter(targetProps, function (targetProp) { + return !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName)); + }); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -144392,7 +147763,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 107 /* ThisKeyword */) + if (token.kind !== 108 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -144615,14 +147986,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 93 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(116 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 93 /* ExtendsKeyword */ && - heritageClauses[1].token === 116 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* ExtendsKeyword */ && + heritageClauses[1].token === 117 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); @@ -144798,7 +148169,7 @@ var ts; ]; } var result = []; - if (token.kind === 135 /* InferKeyword */) { + if (token.kind === 136 /* InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -144840,7 +148211,7 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 135 /* InferKeyword */ || isImport(token)) { + if (token.kind === 136 /* InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { @@ -144869,7 +148240,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 135 /* InferKeyword */) { + if (token.kind === 136 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -144880,7 +148251,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -144889,18 +148260,18 @@ var ts; changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } function isImport(token) { - return token.kind === 99 /* ImportKeyword */ - || token.kind === 78 /* Identifier */ && (token.parent.kind === 266 /* ImportSpecifier */ || token.parent.kind === 263 /* ImportClause */); + return token.kind === 100 /* ImportKeyword */ + || token.kind === 79 /* Identifier */ && (token.parent.kind === 268 /* ImportSpecifier */ || token.parent.kind === 265 /* ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 99 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function canDeleteEntireVariableStatement(sourceFile, token) { return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token; } function deleteEntireVariableStatement(changes, sourceFile, node) { - changes.delete(sourceFile, node.parent.kind === 233 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 235 /* VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -144909,7 +148280,7 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 135 /* InferKeyword */) { + if (token.kind === 136 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -144925,14 +148296,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 161 /* Parameter */: - case 160 /* TypeParameter */: + case 162 /* Parameter */: + case 161 /* TypeParameter */: return true; - case 250 /* VariableDeclaration */: { + case 252 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 240 /* ForOfStatement */: - case 239 /* ForInStatement */: + case 242 /* ForOfStatement */: + case 241 /* ForInStatement */: return true; } } @@ -144982,8 +148353,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 166 /* MethodDeclaration */: - case 167 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* Constructor */: var index = parent.parameters.indexOf(parameter); var referent = ts.isMethodDeclaration(parent) ? parent.name : parent; var entries = ts.FindAllReferences.Core.getReferencedSymbolsForNode(parent.pos, referent, program, sourceFiles, cancellationToken); @@ -145013,17 +148384,17 @@ var ts; } } return true; - case 252 /* FunctionDeclaration */: { + case 254 /* FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. return isLastParameter(parent, parameter, isFixAll); - case 169 /* SetAccessor */: + case 171 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -145081,7 +148452,7 @@ var ts; var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 235 /* IfStatement */: + case 237 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -145092,8 +148463,8 @@ var ts; return; } // falls through - case 237 /* WhileStatement */: - case 238 /* ForStatement */: + case 239 /* WhileStatement */: + case 240 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -145166,7 +148537,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 306 /* JSDocNullableType */) { + if (typeNode.kind === 309 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -145186,7 +148557,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 306 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 309 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -145203,22 +148574,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 225 /* AsExpression */: - case 170 /* CallSignature */: - case 171 /* ConstructSignature */: - case 252 /* FunctionDeclaration */: - case 168 /* GetAccessor */: - case 172 /* IndexSignature */: - case 191 /* MappedType */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 161 /* Parameter */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: - case 169 /* SetAccessor */: - case 255 /* TypeAliasDeclaration */: - case 207 /* TypeAssertionExpression */: - case 250 /* VariableDeclaration */: + case 227 /* AsExpression */: + case 172 /* CallSignature */: + case 173 /* ConstructSignature */: + case 254 /* FunctionDeclaration */: + case 170 /* GetAccessor */: + case 174 /* IndexSignature */: + case 193 /* MappedType */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 171 /* SetAccessor */: + case 257 /* TypeAliasDeclaration */: + case 209 /* TypeAssertionExpression */: + case 252 /* VariableDeclaration */: return true; default: return false; @@ -145320,14 +148691,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 97 /* FunctionKeyword */, sourceFile); + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); break; - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -145342,11 +148713,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 78 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 129 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 130 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -145506,7 +148877,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 78 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 107 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -145660,7 +149031,7 @@ var ts; function annotate(changes, importAdder, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 163 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 164 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -145735,15 +149106,15 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray)), unmergedNewTags))); - var jsDocNode = parent.kind === 210 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray), true), unmergedNewTags, true))); + var jsDocNode = parent.kind === 212 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } codefix.addJSDocTags = addJSDocTags; function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 164 /* PropertyDeclaration */) { + if (signature.parent.kind === 165 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -145753,14 +149124,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 330 /* JSDocParameterTag */: { + case 335 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment) : undefined; } - case 331 /* JSDocReturnTag */: + case 336 /* JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -145785,19 +149156,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 167 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 132 /* ConstructorKeyword */, sourceFile); + case 169 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 133 /* ConstructorKeyword */, sourceFile); break; - case 210 /* ArrowFunction */: - case 209 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 211 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 252 /* FunctionDeclaration */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: + case 254 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: searchToken = containingFunction.name; break; } @@ -145884,7 +149255,7 @@ var ts; cancellationToken.throwIfCancellationRequested(); calculateUsageOfNode(reference, usage); } - var calls = __spreadArray(__spreadArray([], usage.constructs || []), usage.calls || []); + var calls = __spreadArray(__spreadArray([], usage.constructs || [], true), usage.calls || [], true); return declaration.parameters.map(function (parameter, parameterIndex) { var types = []; var isRest = ts.isRestParameter(parameter); @@ -145939,24 +149310,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 216 /* PostfixUnaryExpression */: + case 218 /* PostfixUnaryExpression */: usage.isNumber = true; break; - case 215 /* PrefixUnaryExpression */: + case 217 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 285 /* CaseClause */: - case 286 /* DefaultClause */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 204 /* CallExpression */: - case 205 /* NewExpression */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -145964,20 +149335,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 289 /* PropertyAssignment */: - case 290 /* ShorthandPropertyAssignment */: + case 291 /* PropertyAssignment */: + case 292 /* ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 164 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 250 /* VariableDeclaration */: { + case 252 /* VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -146035,17 +149406,17 @@ var ts; case 52 /* CaretToken */: // CompoundAssignmentOperator // falls through - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 73 /* BarEqualsToken */: - case 77 /* CaretEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* MinusEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: + case 68 /* SlashEqualsToken */: + case 69 /* PercentEqualsToken */: + case 73 /* AmpersandEqualsToken */: + case 74 /* BarEqualsToken */: + case 78 /* CaretEqualsToken */: + case 70 /* LessThanLessThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator // falls through case 40 /* MinusToken */: @@ -146063,7 +149434,7 @@ var ts; usage.isNumber = true; } break; - case 63 /* PlusEqualsToken */: + case 64 /* PlusEqualsToken */: case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { @@ -146083,14 +149454,14 @@ var ts; } break; // AssignmentOperators - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 34 /* EqualsEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: case 37 /* ExclamationEqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 100 /* InKeyword */: + case 101 /* InKeyword */: if (node === parent.left) { usage.isString = true; } @@ -146099,7 +149470,7 @@ var ts; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 250 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 252 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); @@ -146107,7 +149478,7 @@ var ts; break; case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: // nothing to infer here break; } @@ -146127,7 +149498,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 204 /* CallExpression */) { + if (parent.kind === 206 /* CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -146234,13 +149605,15 @@ var ts; } calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); - if (anon.stringIndexInfo) { - stringIndices.push(anon.stringIndexInfo.type); - stringIndexReadonly = stringIndexReadonly || anon.stringIndexInfo.isReadonly; + var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* String */); + if (stringIndexInfo) { + stringIndices.push(stringIndexInfo.type); + stringIndexReadonly = stringIndexReadonly || stringIndexInfo.isReadonly; } - if (anon.numberIndexInfo) { - numberIndices.push(anon.numberIndexInfo.type); - numberIndexReadonly = numberIndexReadonly || anon.numberIndexInfo.isReadonly; + var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* Number */); + if (numberIndexInfo) { + numberIndices.push(numberIndexInfo.type); + numberIndexReadonly = numberIndexReadonly || numberIndexInfo.isReadonly; } } var members = ts.mapEntries(props, function (name, types) { @@ -146249,7 +149622,12 @@ var ts; s.type = checker.getUnionType(types); return [name, s]; }); - return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); + var indexInfos = []; + if (stringIndices.length) + indexInfos.push(checker.createIndexInfo(checker.getStringType(), checker.getUnionType(stringIndices), stringIndexReadonly)); + if (numberIndices.length) + indexInfos.push(checker.createIndexInfo(checker.getNumberType(), checker.getUnionType(numberIndices), numberIndexReadonly)); + return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, indexInfos); } function inferTypes(usage) { var _a, _b, _c; @@ -146284,8 +149662,8 @@ var ts; } var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; - var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); - return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); + var indexInfos = usage.stringIndex ? [checker.createIndexInfo(checker.getStringType(), combineFromUsage(usage.stringIndex), /*isReadonly*/ false)] : []; + return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, indexInfos); } function inferNamedTypesFromProperties(usage) { if (!usage.properties || !usage.properties.size) @@ -146386,7 +149764,7 @@ var ts; return types; } function getFunctionFromCalls(calls) { - return checker.createAnonymousType(/*symbol*/ undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + return checker.createAnonymousType(/*symbol*/ undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, ts.emptyArray); } function getSignatureFromCalls(calls) { var parameters = []; @@ -146403,7 +149781,6 @@ var ts; _loop_15(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - // TODO: GH#18217 return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); } function addCandidateType(usage, type) { @@ -146547,7 +149924,7 @@ var ts; codefix.createMissingMemberNodes = createMissingMemberNodes; function getNoopSymbolTrackerWithResolver(context) { return { - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, moduleResolverHost: ts.getModuleSpecifierResolverHost(context.program, context.host), }; } @@ -146571,8 +149948,8 @@ var ts; var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 163 /* PropertySignature */: - case 164 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 165 /* PropertyDeclaration */: var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { @@ -146586,8 +149963,8 @@ var ts; /*decorators*/ undefined, modifiers, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: { + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -146616,8 +149993,8 @@ var ts; } break; } - case 165 /* MethodSignature */: - case 166 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 167 /* MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -146637,7 +150014,7 @@ var ts; } for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) { var signature = signatures_1[_a]; - // Need to ensure nodes are fresh each time so they can have different positions. + // Ensure nodes are fresh so they can have different positions when going through formatting. outputMethod(quotePreference, signature, ts.getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), ts.getSynthesizedDeepClone(name, /*includeTrivia*/ false)); } if (!ambient) { @@ -146653,17 +150030,17 @@ var ts; break; } function outputMethod(quotePreference, signature, modifiers, name, body) { - var method = signatureToMethodDeclaration(context, quotePreference, signature, enclosingDeclaration, modifiers, name, optional, body, importAdder); + var method = createSignatureDeclarationFromSignature(167 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder); if (method) addClassElement(method); } } - function signatureToMethodDeclaration(context, quotePreference, signature, enclosingDeclaration, modifiers, name, optional, body, importAdder) { + function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) { var program = context.program; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); var flags = 1 /* NoTruncation */ | 1073741824 /* NoUndefinedOptionalParameterType */ | 256 /* SuppressAnyReturnType */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0); - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 166 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -146715,9 +150092,20 @@ var ts; } } } - return ts.factory.updateMethodDeclaration(signatureDeclaration, - /*decorators*/ undefined, modifiers, signatureDeclaration.asteriskToken, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, type, body); + var questionToken = optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var asteriskToken = signatureDeclaration.asteriskToken; + if (ts.isFunctionExpression(signatureDeclaration)) { + return ts.factory.updateFunctionExpression(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body); + } + if (ts.isArrowFunction(signatureDeclaration)) { + return ts.factory.updateArrowFunction(signatureDeclaration, modifiers, typeParameters, parameters, type, signatureDeclaration.equalsGreaterThanToken, body !== null && body !== void 0 ? body : signatureDeclaration.body); + } + if (ts.isMethodDeclaration(signatureDeclaration)) { + return ts.factory.updateMethodDeclaration(signatureDeclaration, /* decorators */ undefined, modifiers, asteriskToken, name !== null && name !== void 0 ? name : ts.factory.createIdentifier(""), questionToken, typeParameters, parameters, type, body); + } + return undefined; } + codefix.createSignatureDeclarationFromSignature = createSignatureDeclarationFromSignature; function createSignatureDeclarationFromCallExpression(kind, context, importAdder, call, name, modifierFlags, contextNode) { var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences); var scriptTarget = ts.getEmitScriptTarget(context.program.getCompilerOptions()); @@ -146747,7 +150135,7 @@ var ts; var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); - if (kind === 166 /* MethodDeclaration */) { + if (kind === 167 /* MethodDeclaration */) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, ts.isInterfaceDeclaration(contextNode) ? undefined : createStubbedMethodBody(quotePreference)); @@ -146762,10 +150150,11 @@ var ts; var importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); if (importableReference) { importSymbols(importAdder, importableReference.symbols); - return importableReference.typeNode; + typeNode = importableReference.typeNode; } } - return typeNode; + // Ensure nodes are fresh so they can have different positions when going through formatting. + return ts.getSynthesizedDeepClone(typeNode); } codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode; function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { @@ -146777,7 +150166,7 @@ var ts; /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -146805,7 +150194,7 @@ var ts; var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { - var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); var restParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", @@ -146840,10 +150229,10 @@ var ts; codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.factory.createToken(122 /* PublicKeyword */); + return ts.factory.createToken(123 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.factory.createToken(121 /* ProtectedKeyword */); + return ts.factory.createToken(122 /* ProtectedKeyword */); } return undefined; } @@ -146916,7 +150305,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -147032,7 +150421,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 161 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 162 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -147088,13 +150477,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 107 /* ThisKeyword */ && + node.expression.kind === 108 /* ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.factory.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 107 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -147109,7 +150498,7 @@ var ts; var type = typeChecker.getTypeFromTypeNode(typeNode); if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) { var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode]; - return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types), [ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)])); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)], false)); } } return typeNode; @@ -147168,7 +150557,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 204 /* CallExpression */ : 205 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 206 /* CallExpression */ : 207 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -147184,9 +150573,8 @@ var ts; ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated.code, ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1.code, - ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2.code, - ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2.code, - ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1.code, + ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3.code, + ts.Diagnostics._0_index_type_1_is_not_assignable_to_2_index_type_3.code, ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2.code, ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property.code, @@ -147213,8 +150601,8 @@ var ts; ts.addRange(fixes, getCodeFixesForImportDeclaration(context, relatedImport)); } if (ts.isExpression(expr) && !(ts.isNamedDeclaration(expr.parent) && expr.parent.name === expr)) { - var sourceFile_1 = context.sourceFile; - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(sourceFile_1, expr, ts.factory.createPropertyAccessExpression(expr, "default"), {}); }); + var sourceFile_2 = context.sourceFile; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(sourceFile_2, expr, ts.factory.createPropertyAccessExpression(expr, "default"), {}); }); fixes.push(codefix.createCodeFixActionWithoutFixAll(fixName, changes, ts.Diagnostics.Use_synthetic_default_member)); } return fixes; @@ -147287,7 +150675,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types)); @@ -147501,8 +150889,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 99 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 196 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 198 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -147521,10 +150909,6 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var jsx = context.program.getCompilerOptions().jsx; - if (jsx !== 2 /* React */ && jsx !== 3 /* ReactNative */) { - return undefined; - } var sourceFile = context.sourceFile, span = context.span; var node = findNodeToFix(sourceFile, span.start); if (!node) @@ -147598,7 +150982,7 @@ var ts; (function (codefix) { var fixIdAddMissingTypeof = "fixConvertToMappedObjectType"; var fixId = fixIdAddMissingTypeof; - var errorCodes = [ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead.code]; + var errorCodes = [ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { @@ -147634,11 +151018,11 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(142 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(143 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type); - var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container)), [ + var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [ mappedIntersectionType - ]), (otherMembers.length ? [ts.factory.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); + ], false), (otherMembers.length ? [ts.factory.createTypeLiteralNode(otherMembers)] : ts.emptyArray), true)); changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -147691,7 +151075,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 130 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 131 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -147702,7 +151086,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 102 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -147759,26 +151143,28 @@ var ts; errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, span = context.span, program = context.program; - var variableStatement = getVariableStatement(sourceFile, span.start, program); - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + var range = getConstTokenRange(sourceFile, span.start, program); + if (range === undefined) + return; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, range); }); return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; }, fixIds: [fixId] }); - function getVariableStatement(sourceFile, pos, program) { - var token = ts.getTokenAtPosition(sourceFile, pos); + function getConstTokenRange(sourceFile, pos, program) { + var _a; var checker = program.getTypeChecker(); - var symbol = checker.getSymbolAtLocation(token); - if (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) { - return symbol.valueDeclaration.parent.parent; - } - } - function doChange(changes, sourceFile, variableStatement) { - if (!variableStatement) { + var symbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, pos)); + var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.parent, ts.isVariableDeclarationList); + if (declaration === undefined) return; - } - var start = variableStatement.getStart(); - changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + var constToken = ts.findChildOfKind(declaration, 85 /* ConstKeyword */, sourceFile); + if (constToken === undefined) + return; + return ts.createRange(constToken.pos, constToken.end); + } + function doChange(changes, sourceFile, range) { + changes.replaceRangeWithText(sourceFile, range, "let"); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -147864,7 +151250,7 @@ var ts; // append ` | void` to type argument var typeArgument = typeArguments[0]; var needsParens = !ts.isUnionTypeNode(typeArgument) && !ts.isParenthesizedTypeNode(typeArgument) && - ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(113 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -147956,7 +151342,7 @@ var ts; ; function getInfo(context, considerPartialSpans) { if (considerPartialSpans === void 0) { considerPartialSpans = true; } - var file = context.file; + var file = context.file, program = context.program; var span = ts.getRefactorContextSpan(context); var token = ts.getTokenAtPosition(file, span.start); var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); @@ -147970,17 +151356,25 @@ var ts; if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } + var checker = program.getTypeChecker(); + var noSymbolError = function (id) { + return (ts.isIdentifier(id) && checker.getSymbolAtLocation(id)) ? undefined + : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; + }; switch (exportNode.kind) { - case 252 /* FunctionDeclaration */: - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - case 256 /* EnumDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 257 /* ModuleDeclaration */: { + case 254 /* FunctionDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + case 258 /* EnumDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 259 /* ModuleDeclaration */: { var node = exportNode; - return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + if (!node.name) + return undefined; + return noSymbolError(node.name) + || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 233 /* VariableStatement */: { + case 235 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -147990,12 +151384,15 @@ var ts; if (!decl.initializer) return undefined; ts.Debug.assert(!wasDefault, "Can't have a default flag here"); - return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + return noSymbolError(decl.name) + || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 267 /* ExportAssignment */: { + case 269 /* ExportAssignment */: { var node = exportNode; - var exp = node.expression; - return node.isExportEquals ? undefined : { exportNode: node, exportName: exp, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; + if (node.isExportEquals) + return undefined; + return noSymbolError(node.expression) + || { exportNode: node, exportName: node.expression, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } default: return undefined; @@ -148014,18 +151411,18 @@ var ts; changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports([spec]))); } else { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 87 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 92 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 252 /* FunctionDeclaration */: - case 253 /* ClassDeclaration */: - case 254 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(87 /* DefaultKeyword */)); + case 254 /* FunctionDeclaration */: + case 255 /* ClassDeclaration */: + case 256 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); break; - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: // If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;` var decl = ts.first(exportNode.declarationList.declarations); if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) { @@ -148034,9 +151431,9 @@ var ts; break; } // falls through - case 256 /* EnumDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 257 /* ModuleDeclaration */: + case 258 /* EnumDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 259 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text))); @@ -148063,18 +151460,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 266 /* ImportSpecifier */: - case 271 /* ExportSpecifier */: { + case 268 /* ImportSpecifier */: + case 273 /* ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 263 /* ImportClause */: { + case 265 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -148083,7 +151480,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 264 /* NamespaceImport */) { + else if (namedBindings.kind === 266 /* NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; @@ -148104,11 +151501,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 266 /* ImportSpecifier */: { + case 268 /* ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.factory.createIdentifier(parent.name.text); @@ -148121,7 +151518,7 @@ var ts; } break; } - case 271 /* ExportSpecifier */: { + case 273 /* ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -148167,7 +151564,7 @@ var ts; if (!info) return ts.emptyArray; if (!refactor.isRefactorErrorInfo(info)) { - var namespaceImport = info.kind === 264 /* NamespaceImport */; + var namespaceImport = info.kind === 266 /* NamespaceImport */; var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction; return [{ name: refactorName, description: action.description, actions: [action] }]; } @@ -148211,7 +151608,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 264 /* NamespaceImport */) { + if (toConvert.kind === 266 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -148268,14 +151665,35 @@ var ts; function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) { var importDecl = toConvert.parent.parent; var moduleSpecifier = importDecl.moduleSpecifier; - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ESNext */) : "module"; - var namespaceNameConflicts = toConvert.elements.some(function (element) { - return ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { - return !!checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); - }) || false; + var toConvertSymbols = new ts.Set(); + toConvert.elements.forEach(function (namedImport) { + var symbol = checker.getSymbolAtLocation(namedImport.name); + if (symbol) { + toConvertSymbols.add(symbol); + } }); + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ESNext */) : "module"; + function hasNamespaceNameConflict(namedImport) { + // We need to check if the preferred namespace name (`preferredName`) we'd like to use in the refactored code will present a name conflict. + // A name conflict means that, in a scope where we would like to use the preferred namespace name, there already exists a symbol with that name in that scope. + // We are going to use the namespace name in the scopes the named imports being refactored are referenced, + // so we look for conflicts by looking at every reference to those named imports. + return !!ts.FindAllReferences.Core.eachSymbolReferenceInFile(namedImport.name, checker, sourceFile, function (id) { + var symbol = checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + if (symbol) { // There already is a symbol with the same name as the preferred namespace name. + if (toConvertSymbols.has(symbol)) { // `preferredName` resolves to a symbol for one of the named import references we are going to transform into namespace import references... + return ts.isExportSpecifier(id.parent); // ...but if this reference is an export specifier, it will not be transformed, so it is a conflict; otherwise, it will be renamed and is not a conflict. + } + return true; // `preferredName` resolves to any other symbol, which will be present in the refactored code and so poses a name conflict. + } + return false; // There is no symbol with the same name as the preferred namespace name, so no conflict. + }); + } + var namespaceNameConflicts = toConvert.elements.some(hasNamespaceNameConflict); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; - var neededNamedImports = []; + // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics. + // More specifically, those are named imports that appear in named exports in the original code, e.g. `a` in `import { a } from "m"; export { a }`. + var neededNamedImports = new ts.Set(); var _loop_16 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { @@ -148283,10 +151701,8 @@ var ts; if (ts.isShorthandPropertyAssignment(id.parent)) { changes.replaceNode(sourceFile, id.parent, ts.factory.createPropertyAssignment(id.text, access)); } - else if (ts.isExportSpecifier(id.parent) && !id.parent.propertyName) { - if (!neededNamedImports.some(function (n) { return n.name === element.name; })) { - neededNamedImports.push(ts.factory.createImportSpecifier(element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text))); - } + else if (ts.isExportSpecifier(id.parent)) { + neededNamedImports.add(element); } else { changes.replaceNode(sourceFile, id, access); @@ -148298,8 +151714,11 @@ var ts; _loop_16(element); } changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName))); - if (neededNamedImports.length) { - changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + if (neededNamedImports.size) { + var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) { + return ts.factory.createImportSpecifier(element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text)); + }); + changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports)); } } function updateImport(old, defaultImportName, elements) { @@ -148612,27 +152031,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 165 /* MethodSignature */: { + case 166 /* MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 166 /* MethodDeclaration */: { + case 167 /* MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 170 /* CallSignature */: { + case 172 /* CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 167 /* Constructor */: { + case 169 /* Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 171 /* ConstructSignature */: { + case 173 /* ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 252 /* FunctionDeclaration */: { + case 254 /* FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -148664,7 +152083,7 @@ var ts; } function convertParameterToNamedTupleMember(p) { ts.Debug.assert(ts.isIdentifier(p.name)); // This is checked during refactoring applicability checking - var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); @@ -148684,12 +152103,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 165 /* MethodSignature */: - case 166 /* MethodDeclaration */: - case 170 /* CallSignature */: - case 167 /* Constructor */: - case 171 /* ConstructSignature */: - case 252 /* FunctionDeclaration */: + case 166 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 172 /* CallSignature */: + case 169 /* Constructor */: + case 173 /* ConstructSignature */: + case 254 /* FunctionDeclaration */: return true; } return false; @@ -148941,7 +152360,6 @@ var ts; Messages.cannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor"); Messages.cannotExtractAmbientBlock = createMessage("Cannot extract code from ambient contexts"); Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes"); - Messages.cannotExtractToOtherFunctionLike = createMessage("Cannot extract method to a function-like scope that is not a function"); Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS"); Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block"); })(Messages = extractSymbol.Messages || (extractSymbol.Messages = {})); @@ -149079,21 +152497,21 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 164 /* PropertyDeclaration */) { - if (ts.hasSyntacticModifier(current, 32 /* Static */)) { + if (current.kind === 165 /* PropertyDeclaration */) { + if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 161 /* Parameter */) { + else if (current.kind === 162 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 167 /* Constructor */) { + if (ctorOrMethod.kind === 169 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 166 /* MethodDeclaration */) { - if (ts.hasSyntacticModifier(current, 32 /* Static */)) { + else if (current.kind === 167 /* MethodDeclaration */) { + if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } } @@ -149135,7 +152553,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 250 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 252 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasSyntacticModifier(declaringNode, 1 /* Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! @@ -149147,16 +152565,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 204 /* CallExpression */) { + if (node.parent.kind === 206 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -149168,7 +152586,7 @@ var ts; rangeFacts |= RangeFacts.UsesThis; } break; - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -149182,39 +152600,39 @@ var ts; } }); // falls through - case 253 /* ClassDeclaration */: - case 252 /* FunctionDeclaration */: + case 255 /* ClassDeclaration */: + case 254 /* FunctionDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); } // falls through - case 222 /* ClassExpression */: - case 209 /* FunctionExpression */: - case 166 /* MethodDeclaration */: - case 167 /* Constructor */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: + case 224 /* ClassExpression */: + case 211 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 169 /* Constructor */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 235 /* IfStatement */: + case 237 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 248 /* TryStatement */: + case 250 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 231 /* Block */: - if (node.parent && node.parent.kind === 248 /* TryStatement */ && node.parent.finallyBlock === node) { + case 233 /* Block */: + if (node.parent && node.parent.kind === 250 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 286 /* DefaultClause */: - case 285 /* CaseClause */: + case 288 /* DefaultClause */: + case 287 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -149226,19 +152644,19 @@ var ts; break; } switch (node.kind) { - case 188 /* ThisType */: - case 107 /* ThisKeyword */: + case 190 /* ThisType */: + case 108 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 246 /* LabeledStatement */: { + case 248 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 242 /* BreakStatement */: - case 241 /* ContinueStatement */: { + case 244 /* BreakStatement */: + case 243 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -149247,20 +152665,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 242 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 244 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 214 /* AwaitExpression */: + case 216 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 220 /* YieldExpression */: + case 222 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 243 /* ReturnStatement */: + case 245 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -149326,7 +152744,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 161 /* Parameter */) { + if (current.kind === 162 /* Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -149337,7 +152755,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 298 /* SourceFile */) { + if (current.kind === 300 /* SourceFile */) { return scopes; } } @@ -149427,32 +152845,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 167 /* Constructor */: + case 169 /* Constructor */: return "constructor"; - case 209 /* FunctionExpression */: - case 252 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : ts.ANONYMOUS; - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return "arrow function"; - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 168 /* GetAccessor */: + case 170 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 169 /* SetAccessor */: + case 171 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 253 /* ClassDeclaration */ + return scope.kind === 255 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 258 /* ModuleBlock */ + return scope.kind === 260 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -149520,12 +152938,12 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(120 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(123 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(129 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(130 /* AsyncKeyword */)); } newFunction = ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, @@ -149533,7 +152951,7 @@ var ts; } else { newFunction = ts.factory.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(129 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(130 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -149678,9 +153096,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 150 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 151 /* UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); } } /** @@ -149705,11 +153123,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.factory.createModifier(120 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(123 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(142 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(143 /* ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -149741,7 +153159,7 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 234 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 236 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.factory.createVariableStatement( @@ -149760,7 +153178,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 234 /* ExpressionStatement */) { + if (node.parent.kind === 236 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -150087,9 +153505,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: new ts.Map(), typeParameterUsages: new ts.Map(), substitutions: new ts.Map() }); substitutionsPerScope.push(new ts.Map()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 252 /* FunctionDeclaration */ - ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] - : []); + functionErrorsPerScope.push([]); var constantErrors = []; if (expressionDiagnostic) { constantErrors.push(expressionDiagnostic); @@ -150406,37 +153822,37 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 292 /* EnumMember */: + case 294 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 262 /* ImportDeclaration */ && - parent.kind !== 266 /* ImportSpecifier */; - case 221 /* SpreadElement */: - case 197 /* ObjectBindingPattern */: - case 199 /* BindingElement */: + return parent.kind !== 264 /* ImportDeclaration */ && + parent.kind !== 268 /* ImportSpecifier */; + case 223 /* SpreadElement */: + case 199 /* ObjectBindingPattern */: + case 201 /* BindingElement */: return false; - case 78 /* Identifier */: - return parent.kind !== 199 /* BindingElement */ && - parent.kind !== 266 /* ImportSpecifier */ && - parent.kind !== 271 /* ExportSpecifier */; + case 79 /* Identifier */: + return parent.kind !== 201 /* BindingElement */ && + parent.kind !== 268 /* ImportSpecifier */ && + parent.kind !== 273 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 231 /* Block */: - case 298 /* SourceFile */: - case 258 /* ModuleBlock */: - case 285 /* CaseClause */: + case 233 /* Block */: + case 300 /* SourceFile */: + case 260 /* ModuleBlock */: + case 287 /* CaseClause */: return true; default: return false; } } function isInJSXContent(node) { - return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && ts.isJsxElement(node.parent); + return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent)); } })(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {})); })(refactor = ts.refactor || (ts.refactor = {})); @@ -150814,11 +154230,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return true; - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -150843,7 +154259,7 @@ var ts; var prologueDirectives = ts.takeWhile(oldFile.statements, ts.isPrologueDirective); if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) { deleteMovedStatements(oldFile, toMove.ranges, changes); - return __spreadArray(__spreadArray([], prologueDirectives), toMove.all); + return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true); } var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator; var quotePreference = ts.getQuotePreference(oldFile, preferences); @@ -150857,11 +154273,11 @@ var ts; var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference); var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax); if (imports.length && body.length) { - return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives), imports), [ + return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [ 4 /* NewLineTrivia */ - ]), body); + ], false), body, true); } - return __spreadArray(__spreadArray(__spreadArray([], prologueDirectives), imports), body); + return __spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), body, true); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { @@ -150914,12 +154330,12 @@ var ts; } function getNamespaceLikeImport(node) { switch (node.kind) { - case 262 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 264 /* NamespaceImport */ ? + case 264 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 266 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return node.name; - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); @@ -150950,20 +154366,20 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: return ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 262 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 261 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 264 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 263 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -151033,15 +154449,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -151054,7 +154470,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 264 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 266 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -151066,7 +154482,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 265 /* NamedImports */) { + else if (namedBindings.kind === 267 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -151079,14 +154495,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 198 /* ArrayBindingPattern */: + case 200 /* ArrayBindingPattern */: break; - case 197 /* ObjectBindingPattern */: + case 199 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -151126,7 +154542,7 @@ var ts; continue; var top = getTopLevelDeclarationStatement(decl); if (markSeenTop(top)) { - addExportToChanges(oldFile, top, changes, useEs6ModuleSyntax); + addExportToChanges(oldFile, top, name, changes, useEs6ModuleSyntax); } if (ts.hasSyntacticModifier(decl, 512 /* Default */)) { oldFileDefault = name; @@ -151216,14 +154632,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 261 /* ImportEqualsDeclaration */: - case 266 /* ImportSpecifier */: - case 263 /* ImportClause */: - case 264 /* NamespaceImport */: + case 263 /* ImportEqualsDeclaration */: + case 268 /* ImportSpecifier */: + case 265 /* ImportClause */: + case 266 /* NamespaceImport */: return true; - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 199 /* BindingElement */: + case 201 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -151235,7 +154651,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 262 /* ImportDeclaration */: { + case 264 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -151245,9 +154661,9 @@ var ts; ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 250 /* VariableDeclaration */: { + case 252 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -151256,7 +154672,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 264 /* NamespaceImport */) { + if (namedBindings.kind === 266 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -151266,11 +154682,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return keep(name) ? name : undefined; - case 198 /* ArrayBindingPattern */: + case 200 /* ArrayBindingPattern */: return name; - case 197 /* ObjectBindingPattern */: { + case 199 /* ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined; @@ -151327,13 +154743,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 252 /* FunctionDeclaration */: - case 253 /* ClassDeclaration */: - case 257 /* ModuleDeclaration */: - case 256 /* EnumDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 254 /* InterfaceDeclaration */: - case 261 /* ImportEqualsDeclaration */: + case 254 /* FunctionDeclaration */: + case 255 /* ClassDeclaration */: + case 259 /* ModuleDeclaration */: + case 258 /* EnumDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 256 /* InterfaceDeclaration */: + case 263 /* ImportEqualsDeclaration */: return true; default: return false; @@ -151341,17 +154757,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 252 /* FunctionDeclaration */: - case 253 /* ClassDeclaration */: - case 257 /* ModuleDeclaration */: - case 256 /* EnumDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 254 /* InterfaceDeclaration */: - case 261 /* ImportEqualsDeclaration */: + case 254 /* FunctionDeclaration */: + case 255 /* ClassDeclaration */: + case 259 /* ModuleDeclaration */: + case 258 /* EnumDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 256 /* InterfaceDeclaration */: + case 263 /* ImportEqualsDeclaration */: return cb(statement); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 234 /* ExpressionStatement */: { + case 236 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -151361,10 +154777,10 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 198 /* ArrayBindingPattern */: - case 197 /* ObjectBindingPattern */: + case 200 /* ArrayBindingPattern */: + case 199 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); @@ -151375,16 +154791,16 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 250 /* VariableDeclaration */: + case 252 /* VariableDeclaration */: return d.parent.parent; - case 199 /* BindingElement */: + case 201 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; } } - function addExportToChanges(sourceFile, decl, changes, useEs6Exports) { - if (isExported(sourceFile, decl, useEs6Exports)) + function addExportToChanges(sourceFile, decl, name, changes, useEs6Exports) { + if (isExported(sourceFile, decl, useEs6Exports, name)) return; if (useEs6Exports) { if (!ts.isExpressionStatement(decl)) @@ -151396,59 +154812,58 @@ var ts; changes.insertNodesAfter(sourceFile, decl, names.map(createExportAssignment)); } } - function isExported(sourceFile, decl, useEs6Exports) { + function isExported(sourceFile, decl, useEs6Exports, name) { + var _a; if (useEs6Exports) { - return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* Export */); - } - else { - return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); }); + return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); } + return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); }); } function addExport(decl, useEs6Exports) { return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.factory.createModifier(92 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 255 /* TypeAliasDeclaration */: + case 257 /* TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 254 /* InterfaceDeclaration */: + case 256 /* InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { - return __spreadArray([decl], getNamesToExportInCommonJS(decl).map(createExportAssignment)); + return __spreadArray([decl], getNamesToExportInCommonJS(decl).map(createExportAssignment), true); } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 252 /* FunctionDeclaration */: - case 253 /* ClassDeclaration */: + case 254 /* FunctionDeclaration */: + case 255 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 257 /* ModuleDeclaration */: - case 256 /* EnumDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 254 /* InterfaceDeclaration */: - case 261 /* ImportEqualsDeclaration */: + case 259 /* ModuleDeclaration */: + case 258 /* EnumDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 256 /* InterfaceDeclaration */: + case 263 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); @@ -151456,7 +154871,7 @@ var ts; } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 62 /* EqualsToken */, ts.factory.createIdentifier(name))); + return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* EqualsToken */, ts.factory.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -151645,7 +155060,7 @@ var ts; function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); var classNames = ts.isConstructorDeclaration(functionDeclaration) ? getClassNames(functionDeclaration) : []; - var names = ts.deduplicate(__spreadArray(__spreadArray([], functionNames), classNames), ts.equateValues); + var names = ts.deduplicate(__spreadArray(__spreadArray([], functionNames, true), classNames, true), ts.equateValues); var checker = program.getTypeChecker(); var references = ts.flatMap(names, /*mapfn*/ function (/*mapfn*/ name) { return ts.FindAllReferences.getReferenceEntriesForNode(-1, name, program, program.getSourceFiles(), cancellationToken); }); var groupedReferences = groupReferences(references); @@ -151791,15 +155206,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 204 /* CallExpression */: - case 205 /* NewExpression */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -151809,7 +155224,7 @@ var ts; } break; // x["foo"](...) - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -151828,14 +155243,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 202 /* PropertyAccessExpression */: + case 204 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 203 /* ElementAccessExpression */: + case 205 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -151881,16 +155296,16 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: if (ts.isObjectLiteralExpression(functionDeclaration.parent)) { var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker); // don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change return ((_a = contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 && isSingleImplementation(functionDeclaration, checker); } return isSingleImplementation(functionDeclaration, checker); - case 167 /* Constructor */: + case 169 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -151898,8 +155313,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -151909,7 +155324,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 87 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -152049,15 +155464,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 87 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 222 /* ClassExpression */: + case 224 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -152068,25 +155483,25 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 252 /* FunctionDeclaration */: + case 254 /* FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 87 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 166 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return [functionDeclaration.name]; - case 167 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 132 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 222 /* ClassExpression */) { + case 169 /* Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 133 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 224 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 209 /* FunctionExpression */: + case 211 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; @@ -152121,7 +155536,7 @@ var ts; var node = getNodeOrParentOfParentheses(file, startPosition); var maybeBinary = getParentBinaryExpression(node); var refactorInfo = { name: refactorName, description: refactorDescription, actions: [] }; - if (ts.isBinaryExpression(maybeBinary) && isStringConcatenationValid(maybeBinary)) { + if (ts.isBinaryExpression(maybeBinary) && treeToArray(maybeBinary).isValidConcatenation) { refactorInfo.actions.push(convertStringAction); return [refactorInfo]; } @@ -152134,7 +155549,7 @@ var ts; function getNodeOrParentOfParentheses(file, startPosition) { var node = ts.getTokenAtPosition(file, startPosition); var nestedBinary = getParentBinaryExpression(node); - var isNonStringBinary = !isStringConcatenationValid(nestedBinary); + var isNonStringBinary = !treeToArray(nestedBinary).isValidConcatenation; if (isNonStringBinary && ts.isParenthesizedExpression(nestedBinary.parent) && ts.isBinaryExpression(nestedBinary.parent.parent)) { @@ -152172,40 +155587,41 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 62 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 202 /* PropertyAccessExpression */: - case 203 /* ElementAccessExpression */: + case 204 /* PropertyAccessExpression */: + case 205 /* ElementAccessExpression */: return false; - case 219 /* TemplateExpression */: - case 217 /* BinaryExpression */: + case 221 /* TemplateExpression */: + case 219 /* BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; } }); - return container || expr; - } - function isStringConcatenationValid(node) { - var _a = treeToArray(node), containsString = _a.containsString, areOperatorsValid = _a.areOperatorsValid; - return containsString && areOperatorsValid; + return (container || expr); } function treeToArray(current) { - if (ts.isBinaryExpression(current)) { - var _a = treeToArray(current.left), nodes = _a.nodes, operators = _a.operators, leftHasString = _a.containsString, leftOperatorValid = _a.areOperatorsValid; - if (!leftHasString && !ts.isStringLiteral(current.right) && !ts.isTemplateExpression(current.right)) { - return { nodes: [current], operators: [], containsString: false, areOperatorsValid: true }; + var loop = function (current) { + if (!ts.isBinaryExpression(current)) { + return { nodes: [current], operators: [], validOperators: true, + hasString: ts.isStringLiteral(current) || ts.isNoSubstitutionTemplateLiteral(current) }; + } + var _a = loop(current.left), nodes = _a.nodes, operators = _a.operators, leftHasString = _a.hasString, leftOperatorValid = _a.validOperators; + if (!(leftHasString || ts.isStringLiteral(current.right) || ts.isTemplateExpression(current.right))) { + return { nodes: [current], operators: [], hasString: false, validOperators: true }; } var currentOperatorValid = current.operatorToken.kind === 39 /* PlusToken */; - var areOperatorsValid = leftOperatorValid && currentOperatorValid; + var validOperators = leftOperatorValid && currentOperatorValid; nodes.push(current.right); operators.push(current.operatorToken); - return { nodes: nodes, operators: operators, containsString: true, areOperatorsValid: areOperatorsValid }; - } - return { nodes: [current], operators: [], containsString: ts.isStringLiteral(current), areOperatorsValid: true }; + return { nodes: nodes, operators: operators, hasString: true, validOperators: validOperators }; + }; + var _a = loop(current), nodes = _a.nodes, operators = _a.operators, validOperators = _a.validOperators, hasString = _a.hasString; + return { nodes: nodes, operators: operators, isValidConcatenation: validOperators && hasString }; } // to copy comments following the operator // "foo" + /* comment */ "bar" @@ -152225,56 +155641,77 @@ var ts; } }; }; + function escapeRawStringForTemplate(s) { + // Escaping for $s in strings that are to be used in template strings + // Naive implementation: replace \x by itself and otherwise $ and ` by \$ and \`. + // But to complicate it a bit, this should work for raw strings too. + return s.replace(/\\.|[$`]/g, function (m) { return m[0] === "\\" ? m : "\\" + m; }); + // Finally, a less-backslash-happy version can work too, doing only ${ instead of all $s: + // s.replace(/\\.|\${|`/g, m => m[0] === "\\" ? m : "\\" + m); + // but `\$${foo}` is likely more clear than the more-confusing-but-still-working `$${foo}`. + } + function getRawTextOfTemplate(node) { + // in these cases the right side is ${ + var rightShaving = ts.isTemplateHead(node) || ts.isTemplateMiddle(node) ? -2 : -1; + return ts.getTextOfNode(node).slice(1, rightShaving); + } function concatConsecutiveString(index, nodes) { var indexes = []; - var text = ""; + var text = "", rawText = ""; while (index < nodes.length) { var node = nodes[index]; - if (ts.isStringLiteralLike(node)) { - text = text + node.text; + if (ts.isStringLiteralLike(node)) { // includes isNoSubstitutionTemplateLiteral(node) + text += node.text; + rawText += escapeRawStringForTemplate(ts.getTextOfNode(node).slice(1, -1)); indexes.push(index); index++; } else if (ts.isTemplateExpression(node)) { - text = text + node.head.text; + text += node.head.text; + rawText += getRawTextOfTemplate(node.head); break; } else { break; } } - return [index, text, indexes]; + return [index, text, rawText, indexes]; } function nodesToTemplate(_a, file) { var nodes = _a.nodes, operators = _a.operators; var copyOperatorComments = copyTrailingOperatorComments(operators, file); var copyCommentFromStringLiterals = copyCommentFromMultiNode(nodes, file, copyOperatorComments); - var _b = concatConsecutiveString(0, nodes), begin = _b[0], headText = _b[1], headIndexes = _b[2]; + var _b = concatConsecutiveString(0, nodes), begin = _b[0], headText = _b[1], rawHeadText = _b[2], headIndexes = _b[3]; if (begin === nodes.length) { - var noSubstitutionTemplateLiteral = ts.factory.createNoSubstitutionTemplateLiteral(headText); + var noSubstitutionTemplateLiteral = ts.factory.createNoSubstitutionTemplateLiteral(headText, rawHeadText); copyCommentFromStringLiterals(headIndexes, noSubstitutionTemplateLiteral); return noSubstitutionTemplateLiteral; } var templateSpans = []; - var templateHead = ts.factory.createTemplateHead(headText); + var templateHead = ts.factory.createTemplateHead(headText, rawHeadText); copyCommentFromStringLiterals(headIndexes, templateHead); var _loop_20 = function (i) { var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]); copyOperatorComments(i, currentNode); - var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], stringIndexes = _c[2]; + var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3]; i = newIndex - 1; var isLast = i === nodes.length - 1; if (ts.isTemplateExpression(currentNode)) { var spans = ts.map(currentNode.templateSpans, function (span, index) { copyExpressionComments(span); - var nextSpan = currentNode.templateSpans[index + 1]; - var text = span.literal.text + (nextSpan ? "" : subsequentText); - return ts.factory.createTemplateSpan(span.expression, isLast ? ts.factory.createTemplateTail(text) : ts.factory.createTemplateMiddle(text)); + var isLastSpan = index === currentNode.templateSpans.length - 1; + var text = span.literal.text + (isLastSpan ? subsequentText : ""); + var rawText = getRawTextOfTemplate(span.literal) + (isLastSpan ? rawSubsequentText : ""); + return ts.factory.createTemplateSpan(span.expression, isLast + ? ts.factory.createTemplateTail(text, rawText) + : ts.factory.createTemplateMiddle(text, rawText)); }); templateSpans.push.apply(templateSpans, spans); } else { - var templatePart = isLast ? ts.factory.createTemplateTail(subsequentText) : ts.factory.createTemplateMiddle(subsequentText); + var templatePart = isLast + ? ts.factory.createTemplateTail(subsequentText, rawSubsequentText) + : ts.factory.createTemplateMiddle(subsequentText, rawSubsequentText); copyCommentFromStringLiterals(stringIndexes, templatePart); templateSpans.push(ts.factory.createTemplateSpan(currentNode, templatePart)); } @@ -152425,14 +155862,15 @@ var ts; var token = ts.getTokenAtPosition(file, startPosition); var typeChecker = program.getTypeChecker(); var func = tryGetFunctionFromVariableDeclaration(file, typeChecker, token.parent); - if (func && !containingThis(func.body)) { + if (func && !containingThis(func.body) && !typeChecker.containsArgumentsReference(func)) { return { selectedVariableDeclaration: true, func: func }; } var maybeFunc = ts.getContainingFunction(token); if (maybeFunc && (ts.isFunctionExpression(maybeFunc) || ts.isArrowFunction(maybeFunc)) && !ts.rangeContainsRange(maybeFunc.body, token) && - !containingThis(maybeFunc.body)) { + !containingThis(maybeFunc.body) && + !typeChecker.containsArgumentsReference(maybeFunc)) { if (ts.isFunctionExpression(maybeFunc) && isFunctionReferencedInFile(file, typeChecker, maybeFunc)) return undefined; return { selectedVariableDeclaration: false, func: maybeFunc }; @@ -152455,7 +155893,11 @@ var ts; } function convertToBlock(body) { if (ts.isExpression(body)) { - return ts.factory.createBlock([ts.factory.createReturnStatement(body)], /* multiLine */ true); + var returnStatement = ts.factory.createReturnStatement(body); + var file = body.getSourceFile(); + ts.suppressLeadingAndTrailingTrivia(returnStatement); + ts.copyTrailingAsLeadingComments(body, returnStatement, file, /* commentKind */ undefined, /* hasTrailingNewLine */ true); + return ts.factory.createBlock([returnStatement], /* multiLine */ true); } else { return body; @@ -152602,10 +156044,10 @@ var ts; } function isConvertibleDeclaration(node) { switch (node.kind) { - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: - case 166 /* MethodDeclaration */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: + case 167 /* MethodDeclaration */: return true; default: return false; @@ -152632,8 +156074,8 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 78 /* Identifier */ ? new IdentifierObject(78 /* Identifier */, pos, end) : - kind === 79 /* PrivateIdentifier */ ? new PrivateIdentifierObject(79 /* PrivateIdentifier */, pos, end) : + kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : + kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; node.flags = parent.flags & 25358336 /* ContextFlags */; @@ -152707,8 +156149,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 302 /* FirstJSDocNode */ || kid.kind > 337 /* LastJSDocNode */; }); - return child.kind < 158 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 304 /* FirstJSDocNode */ || kid.kind > 342 /* LastJSDocNode */; }); + return child.kind < 159 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -152719,7 +156161,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 158 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 159 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -152765,7 +156207,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 78 /* Identifier */) { + if (token === 79 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -152777,7 +156219,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(338 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(343 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { @@ -152830,10 +156272,10 @@ var ts; return sourceFile.text.substring(this.getStart(sourceFile), this.getEnd()); }; TokenOrIdentifierObject.prototype.getChildCount = function () { - return 0; + return this.getChildren().length; }; - TokenOrIdentifierObject.prototype.getChildAt = function () { - return undefined; // TODO: GH#18217 + TokenOrIdentifierObject.prototype.getChildAt = function (index) { + return this.getChildren()[index]; }; TokenOrIdentifierObject.prototype.getChildren = function () { return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; @@ -152888,13 +156330,13 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 168 /* GetAccessor */: + case 170 /* GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = ts.emptyArray; this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 169 /* SetAccessor */: + case 171 /* SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = ts.emptyArray; this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); @@ -152925,7 +156367,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 78 /* Identifier */; + _this.kind = 79 /* Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -152937,7 +156379,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 78 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -152952,7 +156394,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 79 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -153086,7 +156528,7 @@ var ts; if (tags.length === 0 || hasJSDocInheritDocTag(declaration)) { var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; }); if (inheritedTags) { - tags = __spreadArray(__spreadArray([], inheritedTags), tags); + tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true); } } return tags; @@ -153113,7 +156555,12 @@ var ts; return doc; } function findBaseOfDeclaration(checker, declaration, cb) { - return ts.firstDefined(declaration.parent ? ts.getAllSuperTypeNodes(declaration.parent) : ts.emptyArray, function (superTypeNode) { + var _a; + var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 169 /* Constructor */ ? declaration.parent.parent : declaration.parent; + if (!classOrInterfaceDeclaration) { + return; + } + return ts.firstDefined(ts.getAllSuperTypeNodes(classOrInterfaceDeclaration), function (superTypeNode) { var symbol = checker.getPropertyOfType(checker.getTypeAtLocation(superTypeNode), declaration.symbol.name); return symbol ? cb(symbol) : undefined; }); @@ -153122,7 +156569,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 298 /* SourceFile */; + _this.kind = 300 /* SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -153181,10 +156628,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 252 /* FunctionDeclaration */: - case 209 /* FunctionExpression */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: + case 254 /* FunctionDeclaration */: + case 211 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -153204,31 +156651,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 253 /* ClassDeclaration */: - case 222 /* ClassExpression */: - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: - case 256 /* EnumDeclaration */: - case 257 /* ModuleDeclaration */: - case 261 /* ImportEqualsDeclaration */: - case 271 /* ExportSpecifier */: - case 266 /* ImportSpecifier */: - case 263 /* ImportClause */: - case 264 /* NamespaceImport */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 178 /* TypeLiteral */: + case 255 /* ClassDeclaration */: + case 224 /* ClassExpression */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: + case 258 /* EnumDeclaration */: + case 259 /* ModuleDeclaration */: + case 263 /* ImportEqualsDeclaration */: + case 273 /* ExportSpecifier */: + case 268 /* ImportSpecifier */: + case 265 /* ImportClause */: + case 266 /* NamespaceImport */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 180 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 161 /* Parameter */: + case 162 /* Parameter */: // Only consider parameter properties if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { break; } // falls through - case 250 /* VariableDeclaration */: - case 199 /* BindingElement */: { + case 252 /* VariableDeclaration */: + case 201 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -153239,12 +156686,12 @@ var ts; } } // falls through - case 292 /* EnumMember */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: + case 294 /* EnumMember */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: addDeclaration(node); break; - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -153257,7 +156704,7 @@ var ts; } } break; - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -153269,7 +156716,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 264 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 266 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -153278,7 +156725,7 @@ var ts; } } break; - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -153560,7 +157007,6 @@ var ts; }()); ts.ThrottledCancellationToken = ThrottledCancellationToken; var invalidOperationsInPartialSemanticMode = [ - "getSyntacticDiagnostics", "getSemanticDiagnostics", "getSuggestionDiagnostics", "getCompilerOptionsDiagnostics", @@ -153577,8 +157023,9 @@ var ts; "prepareCallHierarchy", "provideCallHierarchyIncomingCalls", "provideCallHierarchyOutgoingCalls", + "provideInlayHints" ]; - var invalidOperationsInSyntacticMode = __spreadArray(__spreadArray([], invalidOperationsInPartialSemanticMode), [ + var invalidOperationsInSyntacticMode = __spreadArray(__spreadArray([], invalidOperationsInPartialSemanticMode, true), [ "getCompletionsAtPosition", "getCompletionEntryDetails", "getCompletionEntrySymbol", @@ -153596,7 +157043,7 @@ var ts; "getRenameInfo", "findRenameLocations", "getApplicableRefactors", - ]); + ], false); function createLanguageService(host, documentRegistry, syntaxOnlyOrLanguageServiceMode) { var _a; if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } @@ -153910,7 +157357,7 @@ var ts; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return __spreadArray(__spreadArray([], semanticDiagnostics), declarationDiagnostics); + return __spreadArray(__spreadArray([], semanticDiagnostics, true), declarationDiagnostics, true); } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); @@ -153918,14 +157365,14 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return __spreadArray(__spreadArray([], program.getOptionsDiagnostics(cancellationToken)), program.getGlobalDiagnostics(cancellationToken)); + return __spreadArray(__spreadArray([], program.getOptionsDiagnostics(cancellationToken), true), program.getGlobalDiagnostics(cancellationToken), true); } function getCompletionsAtPosition(fileName, position, options) { if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); - return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); + return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter, options.triggerKind, cancellationToken); } function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences, data) { if (preferences === void 0) { preferences = ts.emptyOptions; } @@ -153983,16 +157430,16 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); - case 202 /* PropertyAccessExpression */: - case 158 /* QualifiedName */: + case 204 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 107 /* ThisKeyword */: - case 188 /* ThisType */: - case 105 /* SuperKeyword */: - case 193 /* NamedTupleMember */: + case 108 /* ThisKeyword */: + case 190 /* ThisType */: + case 106 /* SuperKeyword */: + case 195 /* NamedTupleMember */: return true; default: return false; @@ -154097,16 +157544,16 @@ var ts; return undefined; } switch (node.kind) { - case 202 /* PropertyAccessExpression */: - case 158 /* QualifiedName */: + case 204 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: case 10 /* StringLiteral */: - case 94 /* FalseKeyword */: - case 109 /* TrueKeyword */: - case 103 /* NullKeyword */: - case 105 /* SuperKeyword */: - case 107 /* ThisKeyword */: - case 188 /* ThisType */: - case 78 /* Identifier */: + case 95 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 104 /* NullKeyword */: + case 106 /* SuperKeyword */: + case 108 /* ThisKeyword */: + case 190 /* ThisType */: + case 79 /* Identifier */: break; // Cant create the text span default: @@ -154122,7 +157569,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 === 257 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 259 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -154475,14 +157922,14 @@ var ts; else { // If is not commenting then remove all comments found. for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) { - var pos_1 = positions_1[_i]; - var from = pos_1 - closeMultiline.length > 0 ? pos_1 - closeMultiline.length : 0; + var pos_2 = positions_1[_i]; + var from = pos_2 - closeMultiline.length > 0 ? pos_2 - closeMultiline.length : 0; var offset = text.substr(from, closeMultiline.length) === closeMultiline ? closeMultiline.length : 0; textChanges.push({ newText: "", span: { length: openMultiline.length, - start: pos_1 - offset + start: pos_2 - offset } }); } @@ -154675,6 +158122,16 @@ var ts; kind: kind }; } + function getInlayHintsContext(file, span, preferences) { + return { + file: file, + program: getProgram(), + host: host, + span: span, + preferences: preferences, + cancellationToken: cancellationToken, + }; + } function getSmartSelectionRange(fileName, position) { return ts.SmartSelectionRange.getSmartSelectionRange(position, syntaxTreeCache.getCurrentSourceFile(fileName)); } @@ -154717,6 +158174,12 @@ var ts; var declaration = ts.firstOrOnly(ts.CallHierarchy.resolveCallHierarchyDeclaration(program, position === 0 ? sourceFile : ts.getTouchingPropertyName(sourceFile, position))); return declaration ? ts.CallHierarchy.getOutgoingCalls(program, declaration) : []; } + function provideInlayHints(fileName, span, preferences) { + if (preferences === void 0) { preferences = ts.emptyOptions; } + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + return ts.InlayHints.provideInlayHints(getInlayHintsContext(sourceFile, span, preferences)); + } var ls = { dispose: dispose, cleanupSemanticCache: cleanupSemanticCache, @@ -154782,6 +158245,7 @@ var ts; toggleMultilineComment: toggleMultilineComment, commentSelection: commentSelection, uncommentSelection: uncommentSelection, + provideInlayHints: provideInlayHints, }; switch (languageServiceMode) { case ts.LanguageServiceMode.Semantic: @@ -154843,7 +158307,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 273 /* ExternalModuleReference */ || + node.parent.kind === 275 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -154861,13 +158325,13 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 159 /* ComputedPropertyName */) { + if (node.parent.kind === 160 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 201 /* ObjectLiteralExpression */ || node.parent.parent.kind === 282 /* JsxAttributes */) && + (node.parent.parent.kind === 203 /* ObjectLiteralExpression */ || node.parent.parent.kind === 284 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -154909,7 +158373,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 203 /* ElementAccessExpression */ && + node.parent.kind === 205 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -154989,114 +158453,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 233 /* VariableStatement */: + case 235 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 250 /* VariableDeclaration */: - case 164 /* PropertyDeclaration */: - case 163 /* PropertySignature */: + case 252 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return spanInVariableDeclaration(node); - case 161 /* Parameter */: + case 162 /* Parameter */: return spanInParameterDeclaration(node); - case 252 /* FunctionDeclaration */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 167 /* Constructor */: - case 209 /* FunctionExpression */: - case 210 /* ArrowFunction */: + case 254 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 169 /* Constructor */: + case 211 /* FunctionExpression */: + case 212 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 231 /* Block */: + case 233 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 258 /* ModuleBlock */: + case 260 /* ModuleBlock */: return spanInBlock(node); - case 288 /* CatchClause */: + case 290 /* CatchClause */: return spanInBlock(node.block); - case 234 /* ExpressionStatement */: + case 236 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 243 /* ReturnStatement */: + case 245 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 237 /* WhileStatement */: + case 239 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 236 /* DoStatement */: + case 238 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 249 /* DebuggerStatement */: + case 251 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 235 /* IfStatement */: + case 237 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 246 /* LabeledStatement */: + case 248 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 242 /* BreakStatement */: - case 241 /* ContinueStatement */: + case 244 /* BreakStatement */: + case 243 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 238 /* ForStatement */: + case 240 /* ForStatement */: return spanInForStatement(node); - case 239 /* ForInStatement */: + case 241 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 240 /* ForOfStatement */: + case 242 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 245 /* SwitchStatement */: + case 247 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 285 /* CaseClause */: - case 286 /* DefaultClause */: + case 287 /* CaseClause */: + case 288 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 248 /* TryStatement */: + case 250 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 247 /* ThrowStatement */: + case 249 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 267 /* ExportAssignment */: + case 269 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 261 /* ImportEqualsDeclaration */: + case 263 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 262 /* ImportDeclaration */: + case 264 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 268 /* ExportDeclaration */: + case 270 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 253 /* ClassDeclaration */: - case 256 /* EnumDeclaration */: - case 292 /* EnumMember */: - case 199 /* BindingElement */: + case 255 /* ClassDeclaration */: + case 258 /* EnumDeclaration */: + case 294 /* EnumMember */: + case 201 /* BindingElement */: // span on complete node return textSpan(node); - case 244 /* WithStatement */: + case 246 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 162 /* Decorator */: + case 163 /* Decorator */: return spanInNodeArray(parent.decorators); - case 197 /* ObjectBindingPattern */: - case 198 /* ArrayBindingPattern */: + case 199 /* ObjectBindingPattern */: + case 200 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 254 /* InterfaceDeclaration */: - case 255 /* TypeAliasDeclaration */: + case 256 /* InterfaceDeclaration */: + case 257 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -155120,13 +158584,13 @@ var ts; case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 114 /* WhileKeyword */: + case 115 /* WhileKeyword */: return spanInWhileKeyword(node); - case 90 /* ElseKeyword */: - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 91 /* ElseKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return spanInNextNode(node); - case 157 /* OfKeyword */: + case 158 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -155138,14 +158602,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 78 /* Identifier */ || - node.kind === 221 /* SpreadElement */ || - node.kind === 289 /* PropertyAssignment */ || - node.kind === 290 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* Identifier */ || + node.kind === 223 /* SpreadElement */ || + node.kind === 291 /* PropertyAssignment */ || + node.kind === 292 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 217 /* BinaryExpression */) { + if (node.kind === 219 /* BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -155154,7 +158618,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -155167,22 +158631,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 236 /* DoStatement */: + case 238 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 162 /* Decorator */: + case 163 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 238 /* ForStatement */: - case 240 /* ForOfStatement */: + case 240 /* ForStatement */: + case 242 /* ForOfStatement */: return textSpan(node); - case 217 /* BinaryExpression */: + case 219 /* BinaryExpression */: if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 210 /* ArrowFunction */: + case 212 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -155191,21 +158655,21 @@ var ts; } } switch (node.parent.kind) { - case 289 /* PropertyAssignment */: + case 291 /* PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 207 /* TypeAssertionExpression */: + case 209 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 250 /* VariableDeclaration */: - case 161 /* Parameter */: { + case 252 /* VariableDeclaration */: + case 162 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -155213,7 +158677,7 @@ var ts; } break; } - case 217 /* BinaryExpression */: { + case 219 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -155243,7 +158707,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 239 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 241 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -155255,7 +158719,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 240 /* ForOfStatement */) { + parent.parent.kind === 242 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -155296,7 +158760,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 253 /* ClassDeclaration */ && functionDeclaration.kind !== 167 /* Constructor */); + (functionDeclaration.parent.kind === 255 /* ClassDeclaration */ && functionDeclaration.kind !== 169 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -155319,26 +158783,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 257 /* ModuleDeclaration */: + case 259 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 237 /* WhileStatement */: - case 235 /* IfStatement */: - case 239 /* ForInStatement */: + case 239 /* WhileStatement */: + case 237 /* IfStatement */: + case 241 /* ForInStatement */: 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 238 /* ForStatement */: - case 240 /* ForOfStatement */: + case 240 /* ForStatement */: + case 242 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 251 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 253 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -155363,21 +158827,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 223 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 225 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 199 /* BindingElement */) { + if (bindingPattern.parent.kind === 201 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 198 /* ArrayBindingPattern */ && node.kind !== 197 /* ObjectBindingPattern */); - var elements = node.kind === 200 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 223 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 200 /* ArrayBindingPattern */ && node.kind !== 199 /* ObjectBindingPattern */); + var elements = node.kind === 202 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 225 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -155385,18 +158849,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 217 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 219 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 256 /* EnumDeclaration */: + case 258 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 253 /* ClassDeclaration */: + case 255 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 259 /* CaseBlock */: + case 261 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -155404,25 +158868,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 258 /* ModuleBlock */: + case 260 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 256 /* EnumDeclaration */: - case 253 /* ClassDeclaration */: + case 258 /* EnumDeclaration */: + case 255 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 231 /* Block */: + case 233 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 288 /* CatchClause */: + case 290 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 259 /* CaseBlock */: + case 261 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -155430,7 +158894,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 197 /* ObjectBindingPattern */: + case 199 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -155446,7 +158910,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 198 /* ArrayBindingPattern */: + case 200 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -155461,12 +158925,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 236 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 204 /* CallExpression */ || - node.parent.kind === 205 /* NewExpression */) { + if (node.parent.kind === 238 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 206 /* CallExpression */ || + node.parent.kind === 207 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 208 /* ParenthesizedExpression */) { + if (node.parent.kind === 210 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -155475,21 +158939,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 209 /* FunctionExpression */: - case 252 /* FunctionDeclaration */: - case 210 /* ArrowFunction */: - case 166 /* MethodDeclaration */: - case 165 /* MethodSignature */: - case 168 /* GetAccessor */: - case 169 /* SetAccessor */: - case 167 /* Constructor */: - case 237 /* WhileStatement */: - case 236 /* DoStatement */: - case 238 /* ForStatement */: - case 240 /* ForOfStatement */: - case 204 /* CallExpression */: - case 205 /* NewExpression */: - case 208 /* ParenthesizedExpression */: + case 211 /* FunctionExpression */: + case 254 /* FunctionDeclaration */: + case 212 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 170 /* GetAccessor */: + case 171 /* SetAccessor */: + case 169 /* Constructor */: + case 239 /* WhileStatement */: + case 238 /* DoStatement */: + case 240 /* ForStatement */: + case 242 /* ForOfStatement */: + case 206 /* CallExpression */: + case 207 /* NewExpression */: + case 210 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -155499,20 +158963,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 289 /* PropertyAssignment */ || - node.parent.kind === 161 /* Parameter */) { + node.parent.kind === 291 /* PropertyAssignment */ || + node.parent.kind === 162 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 207 /* TypeAssertionExpression */) { + if (node.parent.kind === 209 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 236 /* DoStatement */) { + if (node.parent.kind === 238 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -155520,7 +158984,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 240 /* ForOfStatement */) { + if (node.parent.kind === 242 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -156128,6 +159592,10 @@ var ts; var _this = this; return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); }; + LanguageServiceShimObject.prototype.provideInlayHints = function (fileName, span, preference) { + var _this = this; + return this.forwardJSONCall("provideInlayHints('" + fileName + "', '" + JSON.stringify(span) + "', " + JSON.stringify(preference) + ")", function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); + }; /// Emit LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { var _this = this; @@ -156278,7 +159746,7 @@ var ts; typeAcquisition: configFile.typeAcquisition, files: configFile.fileNames, raw: configFile.raw, - errors: realizeDiagnostics(__spreadArray(__spreadArray([], result.parseDiagnostics), configFile.errors), "\r\n") + errors: realizeDiagnostics(__spreadArray(__spreadArray([], result.parseDiagnostics, true), configFile.errors, true), "\r\n") }; }); }; @@ -157103,7 +160571,7 @@ var ts; } else { type = operatorOrType; - operator = 138 /* KeyOfKeyword */; + operator = 139 /* KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -157281,9 +160749,9 @@ var ts; ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) { if (pos === void 0) { pos = 0; } if (end === void 0) { end = 0; } - return ts.setTextRangePosEnd(kind === 298 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 78 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 79 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 300 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : !ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) : ts.parseBaseNodeFactory.createBaseNode(kind), pos, end); }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." }); @@ -157310,7 +160778,7 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 207 /* TypeAssertionExpression */; + return node.kind === 209 /* TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", diff --git a/packages/schematics/angular/utility/latest-versions/package.json b/packages/schematics/angular/utility/latest-versions/package.json index 5660a7cb5ebf..e8bf54167daa 100644 --- a/packages/schematics/angular/utility/latest-versions/package.json +++ b/packages/schematics/angular/utility/latest-versions/package.json @@ -14,7 +14,7 @@ "ng-packagr": "~13.0.0-next.0", "rxjs": "~7.3.0", "tslib": "^2.3.0", - "typescript": "~4.3.5", + "typescript": "~4.4.3", "zone.js": "~0.11.4" } } diff --git a/tsconfig.json b/tsconfig.json index d3e72fae5560..8bcae91cab79 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "noImplicitOverride": true, "noUnusedParameters": false, "noUnusedLocals": false, + "useUnknownInCatchVariables": false, "outDir": "./dist", "rootDir": ".", "skipLibCheck": true, diff --git a/yarn.lock b/yarn.lock index 511492f37c0d..68729157bf7d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -115,7 +115,6 @@ "@angular/dev-infra-private@https://github.com/angular/dev-infra-private-builds.git#66f3d762e79e729464ec26685d8ab784d4876e94": version "0.0.0" - uid "66f3d762e79e729464ec26685d8ab784d4876e94" resolved "https://github.com/angular/dev-infra-private-builds.git#66f3d762e79e729464ec26685d8ab784d4876e94" dependencies: "@actions/core" "^1.4.0" @@ -9117,7 +9116,6 @@ sass@1.42.1, sass@^1.32.8: "sauce-connect-proxy@https://saucelabs.com/downloads/sc-4.6.4-linux.tar.gz": version "0.0.0" - uid "992e2cb0d91e54b27a4f5bbd2049f3b774718115" resolved "https://saucelabs.com/downloads/sc-4.6.4-linux.tar.gz#992e2cb0d91e54b27a4f5bbd2049f3b774718115" saucelabs@^1.5.0: @@ -10270,7 +10268,7 @@ typescript@4.3.5: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4" integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA== -typescript@~4.4.0, typescript@~4.4.2: +typescript@4.4.3, typescript@~4.4.0, typescript@~4.4.2: version "4.4.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.3.tgz#bdc5407caa2b109efd4f82fe130656f977a29324" integrity sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==